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

Unified Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp

Issue 2837273003: ShapeDetection: use makeNonTextureImage() to support texture-backed sources (Closed)
Patch Set: removed unused specific ImagBitmap case Created 3 years, 8 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/modules/shapedetection/ShapeDetector.cpp
diff --git a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
index 437ecae99a7c8b05f3439e40a38a56bbee1ea8ec..98791a53f4bfeca34848c9177712e964dbc9c86c 100644
--- a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
+++ b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
@@ -116,19 +116,13 @@ ScriptPromise ShapeDetector::detect(
uint8_t* pixel_data_ptr = nullptr;
WTF::CheckedNumeric<int> allocation_size = 0;
- sk_sp<SkImage> sk_image = image->ImageForCurrentFrame();
- // Use |skImage|'s pixels if it has direct access to them.
- if (sk_image->peekPixels(&pixmap)) {
+ // makeNonTextureImage() will make a raster copy of ImageForCurrentFrame() if
+ // needed, otherwise returning the original SkImage.
+ const sk_sp<SkImage> sk_image =
+ image->ImageForCurrentFrame()->makeNonTextureImage();
+ if (sk_image && sk_image->peekPixels(&pixmap)) {
pixel_data_ptr = static_cast<uint8_t*>(pixmap.writable_addr());
allocation_size = pixmap.getSafeSize();
- } else if (image_source.isImageBitmap()) {
- ImageBitmap* image_bitmap = image_source.getAsImageBitmap();
- pixel_data = image_bitmap->CopyBitmapData(image_bitmap->IsPremultiplied()
- ? kPremultiplyAlpha
- : kDontPremultiplyAlpha,
- kN32ColorType);
- pixel_data_ptr = pixel_data->Data();
- allocation_size = image_bitmap->Size().Area() * 4 /* bytes per pixel */;
} else {
// TODO(mcasas): retrieve the pixels from elsewhere.
NOTREACHED();
« 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