Changeset 207591 in webkit
- Timestamp:
- Oct 20, 2016 2:03:29 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207590 r207591 1 2016-10-20 Per Arne Vollan <pvollan@apple.com> 2 3 [Win][Direct2D] Implement ImageBufferData::getData. 4 https://bugs.webkit.org/show_bug.cgi?id=163668 5 6 Reviewed by Brent Fulgham. 7 8 Render data to a bitmap in system memory, which data can be read from. 9 10 * platform/graphics/win/ImageBufferDataDirect2D.cpp: 11 (WebCore::ImageBufferData::getData): 12 * platform/graphics/win/ImageBufferDirect2D.cpp: 13 (WebCore::ImageBuffer::ImageBuffer): 14 1 15 2016-10-20 Carlos Garcia Campos <cgarcia@igalia.com> 2 16 -
trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp
r206742 r207591 29 29 #if USE(DIRECT2D) 30 30 31 #include "BitmapInfo.h" 31 32 #include "GraphicsContext.h" 33 #include "HWndDC.h" 32 34 #include "IntRect.h" 33 35 #include "NotImplemented.h" … … 40 42 namespace WebCore { 41 43 42 RefPtr<Uint8ClampedArray> ImageBufferData::getData(const IntRect& , const IntSize&, bool /* accelerateRendering */, bool /* unmultiplied */, float /* resolutionScale */) const44 RefPtr<Uint8ClampedArray> ImageBufferData::getData(const IntRect& rect, const IntSize& size, bool /* accelerateRendering */, bool /* unmultiplied */, float /* resolutionScale */) const 43 45 { 44 notImplemented(); 45 return nullptr; 46 auto platformContext = context->platformContext(); 47 48 Checked<unsigned, RecordOverflow> area = 4 * rect.area(); 49 if (area.hasOverflowed()) 50 return nullptr; 51 52 auto result = Uint8ClampedArray::createUninitialized(area.unsafeGet()); 53 unsigned char* resultData = result ? result->data() : nullptr; 54 if (!resultData) 55 return nullptr; 56 57 BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(size); 58 59 void* pixels = nullptr; 60 auto bitmap = adoptGDIObject(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0)); 61 62 HWndDC windowDC(nullptr); 63 auto bitmapDC = adoptGDIObject(::CreateCompatibleDC(windowDC)); 64 HGDIOBJ oldBitmap = ::SelectObject(bitmapDC.get(), bitmap.get()); 65 66 HRESULT hr; 67 68 COMPtr<ID2D1GdiInteropRenderTarget> gdiRenderTarget; 69 hr = platformContext->QueryInterface(__uuidof(ID2D1GdiInteropRenderTarget), (void**)&gdiRenderTarget); 70 if (FAILED(hr)) 71 return nullptr; 72 73 platformContext->BeginDraw(); 74 75 HDC hdc = nullptr; 76 hr = gdiRenderTarget->GetDC(D2D1_DC_INITIALIZE_MODE_COPY, &hdc); 77 78 BOOL ok = ::BitBlt(bitmapDC.get(), 0, 0, rect.width(), rect.height(), hdc, rect.x(), rect.y(), SRCCOPY); 79 80 hr = gdiRenderTarget->ReleaseDC(nullptr); 81 82 hr = platformContext->EndDraw(); 83 84 if (!ok) 85 return nullptr; 86 87 memcpy(result->data(), pixels, 4 * rect.area()); 88 89 return result; 46 90 } 47 91 -
trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp
r207357 r207591 108 108 109 109 COMPtr<ID2D1BitmapRenderTarget> bitmapContext; 110 HRESULT hr = renderTarget->CreateCompatibleRenderTarget(FloatSize(m_logicalSize), &bitmapContext); 110 D2D1_SIZE_F desiredSize = FloatSize(m_logicalSize); 111 D2D1_SIZE_U pixelSize = IntSize(m_logicalSize); 112 HRESULT hr = renderTarget->CreateCompatibleRenderTarget(&desiredSize, &pixelSize, nullptr, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE, &bitmapContext); 111 113 if (!bitmapContext || !SUCCEEDED(hr)) 112 114 return;
Note: See TracChangeset
for help on using the changeset viewer.