Changeset 83960 in webkit
- Timestamp:
- Apr 15, 2011, 2:28:50 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r83959 r83960 1 2011-04-15 Andrey Kosyakov <caseq@chromium.org> 2 3 Unreviewed, rolling out r83949. 4 http://trac.webkit.org/changeset/83949 5 https://bugs.webkit.org/show_bug.cgi?id=57960 6 7 broke 31 tests in chromium win & linux 8 9 * platform/chromium/test_expectations.txt: 10 1 11 2011-04-15 Philippe Normand <pnormand@igalia.com> 2 12 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r83949 r83960 699 699 // selection 700 700 BUGCR10369 LINUX : editing/selection/5354455-2.html = FAIL 701 702 BUGCR79477 LINUX WIN : canvas/philip/tests/2d.gradient.interpolate.colouralpha.html = TEXT703 701 704 702 // TODO(erg): Attempted to rebaseline these tests as part of the above -
trunk/Source/WebCore/ChangeLog
r83957 r83960 1 2011-04-15 Andrey Kosyakov <caseq@chromium.org> 2 3 Unreviewed, rolling out r83949. 4 http://trac.webkit.org/changeset/83949 5 https://bugs.webkit.org/show_bug.cgi?id=57960 6 7 broke 31 tests in chromium win & linux 8 9 * platform/graphics/chromium/GLES2Canvas.cpp: 10 (WebCore::GLES2Canvas::drawTexturedRect): 11 * platform/graphics/chromium/GLES2Canvas.h: 12 * platform/graphics/gpu/Texture.cpp: 13 (WebCore::copySubRect): 14 (WebCore::Texture::load): 15 (WebCore::Texture::updateSubRect): 16 * platform/graphics/gpu/Texture.h: 17 * platform/graphics/skia/ImageBufferSkia.cpp: 18 (WebCore::getImageData): 19 (WebCore::putImageData): 20 (WebCore::ImageBuffer::putUnmultipliedImageData): 21 (WebCore::ImageBuffer::putPremultipliedImageData): 22 1 23 2011-04-15 Ben Taylor <bentaylor.solx86@gmail.com> 2 24 -
trunk/Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
r83949 r83960 33 33 #include "GLES2Canvas.h" 34 34 35 #include "ByteArray.h"36 35 #include "DrawingBuffer.h" 37 36 #include "FloatRect.h" … … 59 58 namespace WebCore { 60 59 61 using WTF::ByteArray;62 63 60 // Number of line segments used to approximate bezier curves. 64 61 const int pathTesselation = 30; … … 410 407 void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp) 411 408 { 412 drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp, m_state->clippingEnabled() ? ApplyClipping : 0); 413 } 414 415 void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp, unsigned drawTextureFlags) 409 drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp, m_state->clippingEnabled()); 410 } 411 412 413 void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp, bool clip) 416 414 { 417 415 bindFramebuffer(); 418 419 if (drawTextureFlags & MultiplySourceAlpha) { 420 // The multiply option hijacks the blend func, so it can't be combined with a compositing op 421 ASSERT(CompositeCopy == compositeOp); 422 // Custom composite operation that performs alpha multiplication on color components 423 m_context->graphicsContext3D()->enable(GraphicsContext3D::BLEND); 424 m_context->graphicsContext3D()->blendFuncSeparate(GraphicsContext3D::SRC_ALPHA, GraphicsContext3D::ZERO, GraphicsContext3D::ONE, GraphicsContext3D::ZERO); 425 } else 426 m_context->applyCompositeOperator(compositeOp); 427 applyClipping(drawTextureFlags & ApplyClipping); 416 m_context->applyCompositeOperator(compositeOp); 417 applyClipping(clip); 428 418 const TilingData& tiles = texture->tiles(); 429 419 IntRect tileIdxRect = tiles.overlappedTileIndices(srcRect); … … 914 904 } 915 905 916 void GLES2Canvas::putImageData(void* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, Texture::Format format, float alpha, ColorSpace colorSpace, CompositeOperator op, unsigned drawTextureFlags)917 {918 ASSERT(source);919 IntRect clippedSourceRect(0, 0, sourceSize.width(), sourceSize.height());920 clippedSourceRect.intersect(sourceRect);921 int deltaX = clippedSourceRect.x() - sourceRect.x();922 int deltaY = clippedSourceRect.y() - sourceRect.y();923 IntPoint adjustedDestPoint(destPoint.x() + deltaX, destPoint.y() + deltaY);924 IntRect destRect(adjustedDestPoint, clippedSourceRect.size());925 IntRect canvasRect(0, 0, m_size.width(), m_size.height());926 destRect.intersect(canvasRect);927 deltaX = destRect.x() - adjustedDestPoint.x();928 deltaY = destRect.y() - adjustedDestPoint.y();929 clippedSourceRect.move(deltaX, deltaY);930 clippedSourceRect.setSize(destRect.size());931 if (!clippedSourceRect.width() || !clippedSourceRect.height())932 return;933 RefPtr<Texture> uploadTexture = m_context->createTexture(format, clippedSourceRect.width(), clippedSourceRect.height());934 IntRect texUpdateRect(0, 0, clippedSourceRect.width(), clippedSourceRect.height());935 // To get the row stride right, we still take the width of the full buffer for the source size.936 IntSize adjustedSourceSize(sourceSize.width(), texUpdateRect.height());937 uploadTexture->updateSubRect(((char*)source) + (clippedSourceRect.y() * sourceSize.width() + clippedSourceRect.x()) * 4, adjustedSourceSize, texUpdateRect);938 AffineTransform identity;939 drawTexturedRect(uploadTexture.get(), texUpdateRect, destRect, identity, alpha, colorSpace, op, drawTextureFlags);940 }941 942 void GLES2Canvas::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)943 {944 IntPoint newDestPoint(destPoint.x() + sourceRect.x(), destPoint.y() + sourceRect.y());945 putImageData(source->data(), sourceSize, sourceRect, newDestPoint, Texture::RGBA8, 1.0f, ColorSpaceDeviceRGB, CompositeCopy, MultiplySourceAlpha);946 }947 948 void GLES2Canvas::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)949 {950 IntPoint newDestPoint(destPoint.x() + sourceRect.x(), destPoint.y() + sourceRect.y());951 putImageData(source->data(), sourceSize, sourceRect, newDestPoint, Texture::RGBA8, 1.0f, ColorSpaceDeviceRGB, CompositeCopy, 0);952 }953 954 906 void GLES2Canvas::checkGLError(const char* header) 955 907 { -
trunk/Source/WebCore/platform/graphics/chromium/GLES2Canvas.h
r83949 r83960 44 44 #include <wtf/Vector.h> 45 45 46 namespace WTF {47 class ByteArray;48 }49 50 46 namespace WebCore { 51 47 … … 60 56 WTF_MAKE_NONCOPYABLE(GLES2Canvas); 61 57 public: 62 enum DrawTextureFlags {63 ApplyClipping = 1 << 0,64 MultiplySourceAlpha = 1 << 165 };66 67 58 GLES2Canvas(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&); 68 59 ~GLES2Canvas(); … … 98 89 // This version is called by BitmapImage::draw(). 99 90 void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator); 100 // This version is called by the above, by putImageData,and by the software->hardware uploads.101 void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator, unsigned drawTextureFlags);91 // This version is called by the above, and by the software->hardware uploads. 92 void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator, bool clip); 102 93 Texture* createTexture(NativeImagePtr, Texture::Format, int width, int height); 103 94 Texture* getTexture(NativeImagePtr); 104 void putImageData(void* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, Texture::Format, float alpha, ColorSpace, CompositeOperator, unsigned drawTextureFlags);105 void putUnmultipliedImageData(WTF::ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint);106 void putPremultipliedImageData(WTF::ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint);107 95 108 96 SharedGraphicsContext3D* context() const { return m_context; } -
trunk/Source/WebCore/platform/graphics/gpu/Texture.cpp
r83949 r83960 121 121 122 122 template <bool swizzle> 123 static voidcopySubRect(uint32_t* src, int srcX, int srcY, uint32_t* dst, int width, int height, int srcStride)123 static uint32_t* copySubRect(uint32_t* src, int srcX, int srcY, uint32_t* dst, int width, int height, int srcStride) 124 124 { 125 125 uint32_t* srcOffset = src + srcX + srcY * srcStride; 126 127 if (!swizzle && width == srcStride) 128 return srcOffset; 129 126 130 if (swizzle) { 127 131 uint32_t* dstPixel = dst; … … 138 142 } 139 143 } 144 return dst; 140 145 } 141 146 142 147 void Texture::load(void* pixels) 143 148 { 144 updateSubRect(pixels, Int Size(m_tiles.totalSizeX(), m_tiles.totalSizeY()), IntRect(0, 0, m_tiles.totalSizeX(), m_tiles.totalSizeY()));149 updateSubRect(pixels, IntRect(0, 0, m_tiles.totalSizeX(), m_tiles.totalSizeY())); 145 150 } 146 151 147 152 void Texture::updateSubRect(void* pixels, const IntRect& updateRect) 148 153 { 149 updateSubRect(pixels, IntSize(m_tiles.totalSizeX(), m_tiles.totalSizeY()), updateRect);150 }151 152 void Texture::updateSubRect(void* pixels, const IntSize& pixelBufferSize, const IntRect& updateRect)153 {154 IntSize updateBounds = pixelBufferSize.shrunkTo(IntSize(m_tiles.totalSizeX(), m_tiles.totalSizeY()));155 154 IntRect updateRectSanitized(updateRect); 156 updateRectSanitized.intersect(IntRect(0, 0, updateBounds.width(), updateBounds.height()));155 updateRectSanitized.intersect(IntRect(0, 0, m_tiles.totalSizeX(), m_tiles.totalSizeY())); 157 156 158 157 uint32_t* pixels32 = static_cast<uint32_t*>(pixels); … … 165 164 // FIXME: This could use PBO's to save doing an extra copy here. 166 165 } 167 168 166 int tempBuffSize = // Temporary buffer size is the smaller of the max texture size or the updateRectSanitized 169 167 min(m_tiles.maxTextureSize(), m_tiles.borderTexels() + updateRectSanitized.width()) * 170 168 min(m_tiles.maxTextureSize(), m_tiles.borderTexels() + updateRectSanitized.height()); 171 bool needTempBuff = swizzle || updateRect.width() != m_tiles.totalSizeX() || updateRect.width() != pixelBufferSize.width() || m_tiles.numTilesX() > 1; 172 OwnArrayPtr<uint32_t> tempBuff; 173 if (needTempBuff) 174 tempBuff = adoptArrayPtr(new uint32_t[tempBuffSize]); 169 OwnArrayPtr<uint32_t> tempBuff = adoptArrayPtr(new uint32_t[tempBuffSize]); 175 170 176 171 for (int tile = 0; tile < m_tiles.numTiles(); tile++) { … … 187 182 continue; 188 183 184 // Copy sub rectangle out of larger pixel data 189 185 uint32_t* uploadBuff = 0; 190 if (needTempBuff) { 191 uploadBuff = tempBuff.get(); 192 // Copy sub rectangle out of larger pixel data 193 if (swizzle) { 194 copySubRect<true>( 195 pixels32, updateRectIntersected.x(), updateRectIntersected.y(), 196 uploadBuff, updateRectIntersected.width(), updateRectIntersected.height(), pixelBufferSize.width()); 197 } else { 198 copySubRect<false>( 199 pixels32, updateRectIntersected.x(), updateRectIntersected.y(), 200 uploadBuff, updateRectIntersected.width(), updateRectIntersected.height(), pixelBufferSize.width()); 201 } 186 if (swizzle) { 187 uploadBuff = copySubRect<true>( 188 pixels32, updateRectIntersected.x(), updateRectIntersected.y(), 189 tempBuff.get(), updateRectIntersected.width(), updateRectIntersected.height(), m_tiles.totalSizeX()); 202 190 } else { 203 uploadBuff = pixels32 + updateRectIntersected.x() + updateRectIntersected.y() * pixelBufferSize.width(); 191 uploadBuff = copySubRect<false>( 192 pixels32, updateRectIntersected.x(), updateRectIntersected.y(), 193 tempBuff.get(), updateRectIntersected.width(), updateRectIntersected.height(), m_tiles.totalSizeX()); 204 194 } 205 195 -
trunk/Source/WebCore/platform/graphics/gpu/Texture.h
r83949 r83960 43 43 44 44 class IntRect; 45 class IntSize;46 45 47 46 class Texture : public RefCounted<Texture> { … … 53 52 void load(void* pixels); 54 53 void updateSubRect(void* pixels, const IntRect&); 55 void updateSubRect(void* pixels, const IntSize&, const IntRect&);56 54 Format format() const { return m_format; } 57 55 const TilingData& tiles() const { return m_tiles; } -
trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
r83949 r83960 232 232 if (multiplied == Unmultiplied) { 233 233 unsigned char a = SkGetPackedA32(srcPMColor); 234 unsigned char halfA = a >> 1; 235 destPixel[0] = a ? (SkGetPackedR32(srcPMColor) * 255 + halfA) / a : 0; 236 destPixel[1] = a ? (SkGetPackedG32(srcPMColor) * 255 + halfA) / a : 0; 237 destPixel[2] = a ? (SkGetPackedB32(srcPMColor) * 255 + halfA) / a : 0; 234 destPixel[0] = a ? SkGetPackedR32(srcPMColor) * 255 / a : 0; 235 destPixel[1] = a ? SkGetPackedG32(srcPMColor) * 255 / a : 0; 236 destPixel[2] = a ? SkGetPackedB32(srcPMColor) * 255 / a : 0; 238 237 destPixel[3] = a; 239 238 } else { … … 319 318 if (multiplied == Unmultiplied) { 320 319 unsigned char alpha = srcPixel[3]; 321 unsigned char r = SkMulDiv255 Round(srcPixel[0], alpha);322 unsigned char g = SkMulDiv255 Round(srcPixel[1], alpha);323 unsigned char b = SkMulDiv255 Round(srcPixel[2], alpha);320 unsigned char r = SkMulDiv255Ceiling(srcPixel[0], alpha); 321 unsigned char g = SkMulDiv255Ceiling(srcPixel[1], alpha); 322 unsigned char b = SkMulDiv255Ceiling(srcPixel[2], alpha); 324 323 destRow[x] = SkPackARGB32(alpha, r, g, b); 325 324 } else … … 336 335 void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint) 337 336 { 338 PlatformContextSkia* platformContext = context()->platformContext(); 339 if (platformContext->useGPU()) { 340 platformContext->prepareForHardwareDraw(); 341 platformContext->gpuCanvas()->putUnmultipliedImageData(source, sourceSize, sourceRect, destPoint); 342 return; 343 } 344 putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, platformContext->canvas()->getDevice(), m_size); 337 context()->platformContext()->syncSoftwareCanvas(); 338 putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas()->getDevice(), m_size); 345 339 } 346 340 347 341 void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint) 348 342 { 349 PlatformContextSkia* platformContext = context()->platformContext(); 350 if (platformContext->useGPU()) { 351 platformContext->prepareForHardwareDraw(); 352 platformContext->gpuCanvas()->putPremultipliedImageData(source, sourceSize, sourceRect, destPoint); 353 return; 354 } 343 context()->platformContext()->syncSoftwareCanvas(); 355 344 putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, context()->platformContext()->canvas()->getDevice(), m_size); 356 345 }
Note:
See TracChangeset
for help on using the changeset viewer.