Index: third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
index 25580c042d55adc9947c3ec02bbd6ce6dcb5d34a..e918ddac939afee021cc0906d183ed7b8676e7c9 100644 |
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp |
@@ -94,7 +94,12 @@ ImageBitmap::ImageBitmap(ImageData* data, const IntRect& cropRect, const ImageBi |
dstPoint.setX(-cropRect.x()); |
if (cropRect.y() < 0) |
dstPoint.setY(-cropRect.y()); |
- buffer->putByteArray(Unmultiplied, data->data()->data(), data->size(), srcRect, dstPoint); |
+ if (options.orientation() == "flipY" || options.orientation() == "bottomLeft") { |
+ OwnPtr<uint8_t[]> flippedData = copyFlippedSourceData(data->data()->data(), data->width(), data->height()); |
+ buffer->putByteArray(Unmultiplied, flippedData.get(), data->size(), srcRect, dstPoint); |
+ } else { |
+ buffer->putByteArray(Unmultiplied, data->data()->data(), data->size(), srcRect, dstPoint); |
+ } |
m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration)); |
} |
@@ -115,6 +120,18 @@ ImageBitmap::ImageBitmap(PassRefPtr<StaticBitmapImage> image) |
m_image = image; |
} |
+PassOwnPtr<uint8_t[]> ImageBitmap::copyFlippedSourceData(const unsigned char* source, int width, int height) |
jbroman
2016/01/26 17:03:37
This assumes 4-byte pixels, and that the row size
xidachen
2016/02/03 02:17:19
This function won't be needed anymore because we d
|
+{ |
+ const size_t bytesPerRow = 4 * width; |
+ OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[width * height * 4]); |
+ for (int i = 0; i < height; i++) { |
+ const unsigned char* srcAddr = source + i * bytesPerRow; |
+ unsigned char* dstAddr = dstPixels.get() + (height - 1 - i) * bytesPerRow; |
+ memcpy(dstAddr, srcAddr, bytesPerRow); |
+ } |
+ return dstPixels.release(); |
+} |
+ |
PassRefPtr<StaticBitmapImage> ImageBitmap::transfer() |
{ |
ASSERT(!isNeutered()); |