Modified: trunk/Source/WebCore/ChangeLog (208074 => 208075)
--- trunk/Source/WebCore/ChangeLog 2016-10-28 21:57:44 UTC (rev 208074)
+++ trunk/Source/WebCore/ChangeLog 2016-10-28 22:10:35 UTC (rev 208075)
@@ -1,3 +1,14 @@
+2016-10-28 Per Arne Vollan <pvol...@apple.com>
+
+ [Win][Direct2D] Implement ImageBufferData::putData.
+ https://bugs.webkit.org/show_bug.cgi?id=164151
+
+ Reviewed by Brent Fulgham.
+
+ * platform/graphics/win/ImageBufferDataDirect2D.cpp:
+ (WebCore::ImageBufferData::getData):
+ (WebCore::ImageBufferData::putData):
+
2016-10-28 Dave Hyatt <hy...@apple.com>
[CSS Parser] Support hanging-punctuation
Modified: trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp (208074 => 208075)
--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp 2016-10-28 21:57:44 UTC (rev 208074)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDataDirect2D.cpp 2016-10-28 22:10:35 UTC (rev 208075)
@@ -79,7 +79,8 @@
ok = ::BitBlt(bitmapDC.get(), 0, 0, rect.width(), rect.height(), hdc, rect.x(), rect.y(), SRCCOPY);
- hr = gdiRenderTarget->ReleaseDC(nullptr);
+ RECT updateRect = { 0, 0, 0, 0 };
+ hr = gdiRenderTarget->ReleaseDC(&updateRect);
}
if (!ok)
@@ -90,9 +91,79 @@
return result;
}
-void ImageBufferData::putData(Uint8ClampedArray*& /* source */, const IntSize& /* sourceSize */, const IntRect& /* sourceRect */, const IntPoint& /* destPoint */, const IntSize& /* size */, bool /* accelerateRendering */, bool /* unmultiplied */, float /* resolutionScale */)
+void ImageBufferData::putData(Uint8ClampedArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool /* accelerateRendering */, bool unmultiplied, float resolutionScale)
{
- notImplemented();
+ auto platformContext = context->platformContext();
+ COMPtr<ID2D1BitmapRenderTarget> renderTarget(Query, platformContext);
+ if (!renderTarget)
+ return;
+
+ COMPtr<ID2D1Bitmap> bitmap;
+ HRESULT hr = renderTarget->GetBitmap(&bitmap);
+ ASSERT(SUCCEEDED(hr));
+
+ ASSERT(sourceRect.width() > 0);
+ ASSERT(sourceRect.height() > 0);
+
+ Checked<int> originx = sourceRect.x();
+ Checked<int> destx = (Checked<int>(destPoint.x()) + sourceRect.x());
+ destx *= resolutionScale;
+ ASSERT(destx.unsafeGet() >= 0);
+ ASSERT(destx.unsafeGet() < size.width());
+ ASSERT(originx.unsafeGet() >= 0);
+ ASSERT(originx.unsafeGet() <= sourceRect.maxX());
+
+ Checked<int> endx = (Checked<int>(destPoint.x()) + sourceRect.maxX());
+ endx *= resolutionScale;
+ ASSERT(endx.unsafeGet() <= size.width());
+
+ Checked<int> width = sourceRect.width();
+ Checked<int> destw = endx - destx;
+
+ Checked<int> originy = sourceRect.y();
+ Checked<int> desty = (Checked<int>(destPoint.y()) + sourceRect.y());
+ desty *= resolutionScale;
+ ASSERT(desty.unsafeGet() >= 0);
+ ASSERT(desty.unsafeGet() < size.height());
+ ASSERT(originy.unsafeGet() >= 0);
+ ASSERT(originy.unsafeGet() <= sourceRect.maxY());
+
+ Checked<int> endy = (Checked<int>(destPoint.y()) + sourceRect.maxY());
+ endy *= resolutionScale;
+ ASSERT(endy.unsafeGet() <= size.height());
+
+ Checked<int> height = sourceRect.height();
+ Checked<int> desth = endy - desty;
+
+ if (width <= 0 || height <= 0)
+ return;
+
+ unsigned srcBytesPerRow = 4 * sourceSize.width();
+ unsigned char* srcRows = source->data() + (originy * srcBytesPerRow + originx * 4).unsafeGet();
+
+ unsigned char* row = new unsigned char[srcBytesPerRow];
+
+ for (int y = 0; y < height.unsafeGet(); ++y) {
+ for (int x = 0; x < width.unsafeGet(); x++) {
+ int basex = x * 4;
+ unsigned char alpha = srcRows[basex + 3];
+ if (unmultiplied && alpha != 255) {
+ row[basex] = (srcRows[basex] * alpha + 254) / 255;
+ row[basex + 1] = (srcRows[basex + 1] * alpha + 254) / 255;
+ row[basex + 2] = (srcRows[basex + 2] * alpha + 254) / 255;
+ row[basex + 3] = alpha;
+ } else
+ reinterpret_cast<uint32_t*>(row + basex)[0] = reinterpret_cast<uint32_t*>(srcRows + basex)[0];
+ }
+
+ D2D1_RECT_U dstRect = D2D1::RectU(destPoint.x(), destPoint.y() + y, destPoint.x() + size.width(), destPoint.y() + y + 1);
+ hr = bitmap->CopyFromMemory(&dstRect, row, srcBytesPerRow);
+ ASSERT(SUCCEEDED(hr));
+
+ srcRows += srcBytesPerRow;
+ }
+
+ delete[] row;
}
} // namespace WebCore