Bug 163668 - [Win][Direct2D] Implement ImageBufferData::getData.
Summary: [Win][Direct2D] Implement ImageBufferData::getData.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-19 10:11 PDT by Per Arne Vollan
Modified: 2016-10-20 02:09 PDT (History)
3 users (show)

See Also:


Attachments
Patch (4.32 KB, patch)
2016-10-19 10:14 PDT, Per Arne Vollan
bfulgham: review+
bfulgham: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2016-10-19 10:11:04 PDT
This method is not yet implemented for Direct2D.
Comment 1 Per Arne Vollan 2016-10-19 10:14:20 PDT
Created attachment 292078 [details]
Patch
Comment 2 WebKit Commit Bot 2016-10-19 10:15:21 PDT
Attachment 292078 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:78:  Use the class HWndDC instead of calling GetDC to avoid potential memory leaks.  [runtime/leaky_pattern] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Brent Fulgham 2016-10-19 10:38:32 PDT
Comment on attachment 292078 [details]
Patch

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

Thanks for getting this to work! I had a few minor comments I'd like you to address when landing.

> Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:50
> +    area *= rect.height();

You should use the "area()" method:  area = 4 * rect.area();

> Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:71
> +    hr = platformContext->QueryInterface(__uuidof(ID2D1GdiInteropRenderTarget), (void**)&gdiRenderTarget);

I think we should retain this in the GraphicsContextPlatformPrivate, since there will be other times we want to get a GDI HBITMAP or similar out of our D2D context.

You can do this as a separate patch.

> Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:89
> +    memcpy(result->data(), pixels, 4 * rect.width() * rect.height());

Can we avoid this extra copy by somehow using result->data() as the pixel source?
Comment 4 Per Arne Vollan 2016-10-20 01:50:04 PDT
(In reply to comment #3)
> Comment on attachment 292078 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=292078&action=review
> 
> Thanks for getting this to work! I had a few minor comments I'd like you to
> address when landing.
> 
> > Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:50
> > +    area *= rect.height();
> 
> You should use the "area()" method:  area = 4 * rect.area();
> 
> > Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:71
> > +    hr = platformContext->QueryInterface(__uuidof(ID2D1GdiInteropRenderTarget), (void**)&gdiRenderTarget);
> 
> I think we should retain this in the GraphicsContextPlatformPrivate, since
> there will be other times we want to get a GDI HBITMAP or similar out of our
> D2D context.
> 
> You can do this as a separate patch.
> 
> > Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp:89
> > +    memcpy(result->data(), pixels, 4 * rect.width() * rect.height());
> 
> Can we avoid this extra copy by somehow using result->data() as the pixel
> source?

I haven't found a way to do this yet, since the system is allocating the bitmap pixel data for us.

Thanks for reviewing!
Comment 5 Per Arne Vollan 2016-10-20 02:09:14 PDT
Committed r207591: <http://trac.webkit.org/changeset/207591>