Changeset 228052 in webkit
- Timestamp:
- Feb 4, 2018 12:18:23 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228049 r228052 1 2018-02-04 Zan Dobersek <zdobersek@igalia.com> 2 3 Simplify GraphicsContext3D::paintToCanvas() 4 https://bugs.webkit.org/show_bug.cgi?id=182459 5 6 Reviewed by Michael Catanzaro. 7 8 Cairo-specific paintToCanvas() method is dropped in favor of the more 9 common one that operates on a GraphicsContext object. The platform 10 context object is then retrieved inside the Cairo-speficic 11 paintToCanvas() implementation, and not at the call site in 12 GraphicsContext3D::paintRenderingResultsToCanvas(). 13 14 GraphicsContext3D::paintToCanvas() is also modified so that the image 15 and canvas sizes are passed through IntSize objects, and not through 16 a width-and-height pair of integer values. 17 18 No new tests -- no change in behavior. 19 20 * platform/graphics/GraphicsContext3D.h: 21 * platform/graphics/cairo/GraphicsContext3DCairo.cpp: 22 (WebCore::GraphicsContext3D::paintToCanvas): 23 * platform/graphics/cg/GraphicsContext3DCG.cpp: 24 (WebCore::GraphicsContext3D::paintToCanvas): 25 * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: 26 (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas): 27 1 28 2018-02-03 Alexey Proskuryakov <ap@apple.com> 2 29 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r226581 r228052 99 99 class IntSize; 100 100 class WebGLRenderingContextBase; 101 #if USE(CAIRO)102 class PlatformContextCairo;103 #endif104 101 #if USE(TEXTURE_MAPPER) 105 102 class TextureMapperGC3DPlatformLayer; … … 1131 1128 void bindVertexArray(Platform3DObject); 1132 1129 1133 #if PLATFORM(GTK) || USE(CAIRO) 1134 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, 1135 int canvasWidth, int canvasHeight, PlatformContextCairo* context); 1136 #elif USE(CG) 1137 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, GraphicsContext&); 1138 #endif 1130 void paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext&); 1139 1131 1140 1132 void markContextChanged(); -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r225638 r228052 344 344 } 345 345 346 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo*context)347 { 348 if (!imagePixels || image Width <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0 || !context)346 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext& context) 347 { 348 if (!imagePixels || imageSize.isEmpty() || canvasSize.isEmpty()) 349 349 return; 350 350 351 cairo_t *cr = context->cr(); 352 context->save(); 353 354 cairo_rectangle(cr, 0, 0, canvasWidth, canvasHeight); 351 PlatformContextCairo* platformContext = context.platformContext(); 352 if (!platformContext) 353 return; 354 355 cairo_t* cr = platformContext->cr(); 356 platformContext->save(); 357 358 cairo_rectangle(cr, 0, 0, canvasSize.width(), canvasSize.height()); 355 359 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); 356 360 cairo_paint(cr); 357 361 358 362 RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data( 359 const_cast<unsigned char*>(imagePixels), CAIRO_FORMAT_ARGB32, image Width, imageHeight, imageWidth* 4));363 const_cast<unsigned char*>(imagePixels), CAIRO_FORMAT_ARGB32, imageSize.width(), imageSize.height(), imageSize.width() * 4)); 360 364 361 365 // OpenGL keeps the pixels stored bottom up, so we need to flip the image here. 362 cairo_translate(cr, 0, image Height);366 cairo_translate(cr, 0, imageSize.height()); 363 367 cairo_scale(cr, 1, -1); 364 368 365 369 cairo_set_operator(cr, CAIRO_OPERATOR_OVER); 366 370 cairo_set_source_surface(cr, imageSurface.get(), 0, 0); 367 cairo_rectangle(cr, 0, 0, canvas Width, -canvasHeight);371 cairo_rectangle(cr, 0, 0, canvasSize.width(), -canvasSize.height()); 368 372 369 373 cairo_fill(cr); 370 context->restore();374 platformContext->restore(); 371 375 } 372 376 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
r225428 r228052 501 501 } 502 502 503 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, GraphicsContext& context)504 { 505 if (!imagePixels || image Width <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0)503 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext& context) 504 { 505 if (!imagePixels || imageSize.isEmpty() || canvasSize.isEmpty()) 506 506 return; 507 int rowBytes = image Width* 4;507 int rowBytes = imageSize.width() * 4; 508 508 RetainPtr<CGDataProviderRef> dataProvider; 509 509 … … 511 511 unsigned char* copiedPixels; 512 512 513 if (!tryFastCalloc(image Height, rowBytes).getValue(copiedPixels))513 if (!tryFastCalloc(imageSize.height(), rowBytes).getValue(copiedPixels)) 514 514 return; 515 515 516 memcpy(copiedPixels, imagePixels, rowBytes * image Height);517 dataProvider = adoptCF(CGDataProviderCreateWithData(0, copiedPixels, rowBytes * image Height, releaseImageData));516 memcpy(copiedPixels, imagePixels, rowBytes * imageSize.height()); 517 dataProvider = adoptCF(CGDataProviderCreateWithData(0, copiedPixels, rowBytes * imageSize.height(), releaseImageData)); 518 518 } else 519 dataProvider = adoptCF(CGDataProviderCreateWithData(0, imagePixels, rowBytes * image Height, 0));520 521 RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(image Width, imageHeight, 8, 32, rowBytes, sRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,519 dataProvider = adoptCF(CGDataProviderCreateWithData(0, imagePixels, rowBytes * imageSize.height(), 0)); 520 521 RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(imageSize.width(), imageSize.height(), 8, 32, rowBytes, sRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, 522 522 dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 523 523 … … 525 525 // the page. Go back to the Canvas to figure out the correct 526 526 // width and height to draw. 527 FloatRect canvasRect(0, 0, canvasWidth, canvasHeight); 528 FloatSize imageSize(imageWidth, imageHeight); 527 FloatRect canvasRect(FloatPoint(), canvasSize); 529 528 // We want to completely overwrite the previous frame's 530 529 // rendering results. … … 532 531 GraphicsContextStateSaver stateSaver(context); 533 532 context.scale(FloatSize(1, -1)); 534 context.translate(0, -image Height);533 context.translate(0, -imageSize.height()); 535 534 context.setImageInterpolationQuality(InterpolationNone); 536 535 context.drawNativeImage(cgImage, imageSize, canvasRect, FloatRect(FloatPoint(), imageSize), CompositeCopy); -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r226581 r228052 178 178 } 179 179 180 #if USE(CG) 181 paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, 182 imageBuffer->internalSize().width(), imageBuffer->internalSize().height(), imageBuffer->context()); 183 #else 184 paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, imageBuffer->internalSize().width(), imageBuffer->internalSize().height(), imageBuffer->context().platformContext()); 185 #endif 180 paintToCanvas(pixels.get(), IntSize(m_currentWidth, m_currentHeight), imageBuffer->internalSize(), imageBuffer->context()); 186 181 187 182 #if PLATFORM(IOS)
Note: See TracChangeset
for help on using the changeset viewer.