Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 2202143002: Fix tests: conformance_textures_image_bitmap_from_image_data on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64f5b0a215e0cdaf9ee2ad44d64f257cfb7b1939..626c30b4a452a6ac27ddf082ed288d69a893ba3f 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -124,16 +124,21 @@ static void swizzleImageData(unsigned char* srcAddr, int height, int bytesPerRow
for (int i = 0; i < height / 2; i++) {
int topRowStartPosition = i * bytesPerRow;
int bottomRowStartPosition = (height - 1 - i) * bytesPerRow;
- for (int j = 0; j < bytesPerRow; j += 4) {
- std::swap(srcAddr[topRowStartPosition + j], srcAddr[bottomRowStartPosition + j + 2]);
- std::swap(srcAddr[topRowStartPosition + j + 1], srcAddr[bottomRowStartPosition + j + 1]);
- std::swap(srcAddr[topRowStartPosition + j + 2], srcAddr[bottomRowStartPosition + j]);
- std::swap(srcAddr[topRowStartPosition + j + 3], srcAddr[bottomRowStartPosition + j + 3]);
+ if (kN32_SkColorType == kBGRA_8888_SkColorType) { // needs to swizzle
+ for (int j = 0; j < bytesPerRow; j += 4) {
+ std::swap(srcAddr[topRowStartPosition + j], srcAddr[bottomRowStartPosition + j + 2]);
+ std::swap(srcAddr[topRowStartPosition + j + 1], srcAddr[bottomRowStartPosition + j + 1]);
+ std::swap(srcAddr[topRowStartPosition + j + 2], srcAddr[bottomRowStartPosition + j]);
+ std::swap(srcAddr[topRowStartPosition + j + 3], srcAddr[bottomRowStartPosition + j + 3]);
+ }
+ } else {
+ std::swap_ranges(srcAddr + topRowStartPosition, srcAddr + topRowStartPosition + bytesPerRow, srcAddr + bottomRowStartPosition);
}
}
} else {
- for (int i = 0; i < height * bytesPerRow; i += 4)
- std::swap(srcAddr[i], srcAddr[i + 2]);
+ if (kN32_SkColorType == kBGRA_8888_SkColorType) // needs to swizzle
+ for (int i = 0; i < height * bytesPerRow; i += 4)
+ std::swap(srcAddr[i], srcAddr[i + 2]);
}
}
@@ -401,12 +406,10 @@ ImageBitmap::ImageBitmap(ImageData* data, Optional<IntRect> cropRect, const Imag
int dstPixelBytesPerRow = info.bytesPerPixel() * parsedOptions.cropRect.width();
RefPtr<SkImage> skImage;
if (parsedOptions.cropRect == IntRect(IntPoint(), data->size())) {
- if (kN32_SkColorType == kBGRA_8888_SkColorType)
- swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, parsedOptions.flipY);
+ swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, parsedOptions.flipY);
skImage = fromSkSp(SkImage::MakeRasterCopy(SkPixmap(info, srcAddr, dstPixelBytesPerRow)));
// restore the original ImageData
- if (kN32_SkColorType == kBGRA_8888_SkColorType)
- swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, parsedOptions.flipY);
+ swizzleImageData(srcAddr, srcHeight, srcPixelBytesPerRow, parsedOptions.flipY);
} else {
std::unique_ptr<uint8_t[]> copiedDataBuffer = wrapArrayUnique(new uint8_t[dstHeight * dstPixelBytesPerRow]());
if (!srcRect.isEmpty()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698