Bug 157580 - [Cairo] GraphicsContext3D::ImageExtractor should use the correct size for copying non-image surfaces
Summary: [Cairo] GraphicsContext3D::ImageExtractor should use the correct size for cop...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-11 12:10 PDT by Zan Dobersek
Modified: 2016-05-16 03:27 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.65 KB, patch)
2016-05-11 12:16 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch for landing (2.67 KB, patch)
2016-05-16 01:16 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-yosemite (1.14 MB, application/zip)
2016-05-16 01:38 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2016-05-11 12:10:47 PDT
[Cairo] GraphicsContext3D::ImageExtractor::extractImage() should use the correct size for copying
Comment 1 Zan Dobersek 2016-05-11 12:16:47 PDT
Created attachment 278651 [details]
Patch
Comment 2 Alex Christensen 2016-05-11 12:59:00 PDT
Comment on attachment 278651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278651&action=review

> Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp:229
> +            IntSize surfaceSize = cairoSurfaceSize(m_imageSurface.get());

This now has two calls to cairoSurfaceSize, one here and one on line 241.  Could the size change between these calls?
Comment 3 Darin Adler 2016-05-12 09:03:04 PDT
Comment on attachment 278651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278651&action=review

>> Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp:229
>> +            IntSize surfaceSize = cairoSurfaceSize(m_imageSurface.get());
> 
> This now has two calls to cairoSurfaceSize, one here and one on line 241.  Could the size change between these calls?

The two calls are calling cairoSurfaceSize on two different surfaces so I am not sure exactly what the point of your question is. Perhaps the idea is that since we create the surface in this code path, we already know the size, so we could slightly optimize by not calling cairoSurfaceSize compute it below, but that does not seem an important optimization to me.

> Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp:230
> +            RefPtr<cairo_surface_t> tmpSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, surfaceSize.width(), surfaceSize.height()));

I think we should prefer auto when storing the result of adoptRef. This code seems to also assume that cairo_image_surface_create will never return null. If that’s true, then we would typically prefer to use * so that adoptRef makes a Ref instead of a RefPtr.

> Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp:232
>              m_imageSurface = tmpSurface.release();

Should probably use WTFMove, not release.
Comment 4 Zan Dobersek 2016-05-16 01:15:16 PDT
Comment on attachment 278651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278651&action=review

>> Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp:230
>> +            RefPtr<cairo_surface_t> tmpSurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, surfaceSize.width(), surfaceSize.height()));
> 
> I think we should prefer auto when storing the result of adoptRef. This code seems to also assume that cairo_image_surface_create will never return null. If that’s true, then we would typically prefer to use * so that adoptRef makes a Ref instead of a RefPtr.

Ref<> doesn't use the refIfNotNull<>()/deferIfNotNull<>() templates to ref/deref the object, but directly calls the ::ref() and ::deref() methods on the class. We overload those template helpers for Cairo objects (and objects from other APIs) to use appropriate ref/deref functions.

We also avoid using C++ references with forward-declared C API pointers, which would be the case with Ref<>.
Comment 5 Zan Dobersek 2016-05-16 01:16:17 PDT
Created attachment 279008 [details]
Patch for landing
Comment 6 Build Bot 2016-05-16 01:38:20 PDT
Comment on attachment 279008 [details]
Patch for landing

Attachment 279008 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1329429

Number of test failures exceeded the failure limit.
Comment 7 Build Bot 2016-05-16 01:38:23 PDT
Created attachment 279009 [details]
Archive of layout-test-results from ews102 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 8 Zan Dobersek 2016-05-16 03:27:25 PDT
Comment on attachment 279008 [details]
Patch for landing

Clearing flags on attachment: 279008

Committed r200940: <http://trac.webkit.org/changeset/200940>
Comment 9 Zan Dobersek 2016-05-16 03:27:35 PDT
All reviewed patches have been landed.  Closing bug.