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

Unified Diff: third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp

Issue 2379453002: Use SkPaintImageFilter of a bitmap to implement box reflection masks. (Closed)
Patch Set: Merge branch 'master' into fixboxreflect Created 4 years, 3 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 | « third_party/WebKit/Source/platform/graphics/BoxReflection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp b/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
index 52c3bc5291361394e516ce4fa468b3ba686ba925..5f2b9b9573a1c1609e1ee63d339c085ac9aeeb3b 100644
--- a/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
+++ b/third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp
@@ -34,6 +34,8 @@
#include "platform/graphics/skia/SkiaUtils.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkXfermode.h"
+#include "third_party/skia/include/effects/SkImageSource.h"
+#include "third_party/skia/include/effects/SkOffsetImageFilter.h"
#include "third_party/skia/include/effects/SkPictureImageFilter.h"
#include "third_party/skia/include/effects/SkXfermodeImageFilter.h"
@@ -96,13 +98,24 @@ sk_sp<SkImageFilter> buildBoxReflectFilter(const BoxReflection& reflection, sk_s
{
sk_sp<SkImageFilter> maskedInput;
if (SkPicture* maskPicture = reflection.mask()) {
+ // Since SkPictures can't be serialized to the browser process, first raster the mask to a bitmap, then
+ // encode it in an SkImageSource, which can be serialized.
+ SkBitmap bitmap;
+ const SkRect cullRect = maskPicture->cullRect();
+ bitmap.allocPixels(SkImageInfo::MakeN32Premul(cullRect.width(), cullRect.height()));
+ SkCanvas canvas(bitmap);
+ canvas.clear(SK_ColorTRANSPARENT);
+ canvas.translate(-cullRect.x(), -cullRect.y());
+ canvas.drawPicture(maskPicture);
+ sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
+
// SkXfermodeImageFilter can choose an excessively large size if the
// mask is smaller than the filtered contents (due to overflow).
// http://skbug.com/5210
SkImageFilter::CropRect cropRect(maskPicture->cullRect());
maskedInput = SkXfermodeImageFilter::Make(
SkXfermode::Make(SkXfermode::kSrcIn_Mode),
- SkPictureImageFilter::Make(sk_ref_sp(maskPicture)),
+ SkOffsetImageFilter::Make(cullRect.x(), cullRect.y(), SkImageSource::Make(image)),
input, &cropRect);
} else {
maskedInput = input;
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/BoxReflection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698