Changeset 208013 in webkit


Ignore:
Timestamp:
Oct 27, 2016 3:37:21 PM (7 years ago)
Author:
pvollan@apple.com
Message:

[Win][Direct2D] Implement GraphicsContext::releaseWindowsContext.
https://bugs.webkit.org/show_bug.cgi?id=163988

Reviewed by Brent Fulgham.

This method is needed to draw native controls.

  • platform/graphics/win/GraphicsContextDirect2D.cpp:

(WebCore::GraphicsContext::releaseWindowsContext):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r208011 r208013  
     12016-10-27  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Win][Direct2D] Implement GraphicsContext::releaseWindowsContext.
     4        https://bugs.webkit.org/show_bug.cgi?id=163988
     5
     6        Reviewed by Brent Fulgham.
     7
     8        This method is needed to draw native controls.
     9
     10        * platform/graphics/win/GraphicsContextDirect2D.cpp:
     11        (WebCore::GraphicsContext::releaseWindowsContext):
     12
    1132016-10-27  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextDirect2D.cpp

    r207863 r208013  
    258258void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
    259259{
     260    bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer());
     261    if (!createdBitmap) {
     262        m_data->restore();
     263        return;
     264    }
     265
     266    if (!hdc || dstRect.isEmpty())
     267        return;
     268
     269    auto sourceBitmap = adoptGDIObject(static_cast<HBITMAP>(::GetCurrentObject(hdc, OBJ_BITMAP)));
     270
     271    DIBPixelData pixelData(sourceBitmap.get());
     272    ASSERT(pixelData.bitsPerPixel() == 32);
     273
     274    auto bitmapProperties = D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE));
     275
     276    COMPtr<ID2D1Bitmap> bitmap;
     277    HRESULT hr = platformContext()->CreateBitmap(pixelData.size(), pixelData.buffer(), pixelData.bytesPerRow(), &bitmapProperties, &bitmap);
     278    ASSERT(SUCCEEDED(hr));
     279
     280    if (!didBeginDraw())
     281        platformContext()->BeginDraw();
     282
     283    platformContext()->DrawBitmap(bitmap.get(), dstRect);
     284
     285    if (!didBeginDraw())
     286        hr = platformContext()->EndDraw();
     287
     288    ::DeleteDC(hdc);
    260289}
    261290
Note: See TracChangeset for help on using the changeset viewer.