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

Unified Diff: gm/drawbitmaprect.cpp

Issue 2286873002: drawBitmapRect() should not touch the CTM when mask filters are present (Closed)
Patch Set: GM cleanup 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 | src/core/SkBitmapDevice.cpp » ('j') | src/core/SkBitmapDevice.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/drawbitmaprect.cpp
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 0747ab0910e36aea612bf346d38ae88a931ebd0f..ea9a09fe0a779fea70e9569e01fd52aa57b1b333 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -93,17 +93,43 @@ static sk_sp<SkImage> makebm(SkCanvas* origCanvas, SkBitmap* resultBM, int w, in
return image;
}
-static void canvasproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkIRect& srcR,
- const SkRect& dstR) {
- canvas->drawBitmapRect(bm, srcR, dstR, nullptr);
+static void bitmapproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkIRect& srcR,
+ const SkRect& dstR, const SkPaint* paint) {
+ canvas->drawBitmapRect(bm, srcR, dstR, paint);
+}
+
+static void bitmapsubsetproc(SkCanvas* canvas, SkImage*, const SkBitmap& bm, const SkIRect& srcR,
+ const SkRect& dstR, const SkPaint* paint) {
+ if (!bm.bounds().contains(srcR)) {
+ bitmapproc(canvas, nullptr, bm, srcR, dstR, paint);
+ return;
+ }
+
+ SkBitmap subset;
+ if (bm.extractSubset(&subset, srcR)) {
+ canvas->drawBitmapRect(subset, dstR, paint);
+ }
}
static void imageproc(SkCanvas* canvas, SkImage* image, const SkBitmap&, const SkIRect& srcR,
- const SkRect& dstR) {
- canvas->drawImageRect(image, srcR, dstR, nullptr);
+ const SkRect& dstR, const SkPaint* paint) {
+ canvas->drawImageRect(image, srcR, dstR, paint);
}
-typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRect&, const SkRect&);
+static void imagesubsetproc(SkCanvas* canvas, SkImage* image, const SkBitmap& bm,
+ const SkIRect& srcR, const SkRect& dstR, const SkPaint* paint) {
+ if (!image->bounds().contains(srcR)) {
+ imageproc(canvas, image, bm, srcR, dstR, paint);
+ return;
+ }
+
+ if (sk_sp<SkImage> subset = image->makeSubset(srcR)) {
+ canvas->drawImageRect(subset, dstR, paint);
+ }
+}
+
+typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRect&, const SkRect&,
+ const SkPaint*);
static const int gSize = 1024;
static const int gBmpSize = 2048;
@@ -164,7 +190,7 @@ protected:
for (int h = 1; h <= kMaxSrcRectSize; h *= 4) {
SkIRect srcRect = SkIRect::MakeXYWH((gBmpSize - w) / 2, (gBmpSize - h) / 2, w, h);
- fProc(canvas, fImage.get(), fLargeBitmap, srcRect, dstRect);
+ fProc(canvas, fImage.get(), fLargeBitmap, srcRect, dstRect, nullptr);
SkString label;
label.appendf("%d x %d", w, h);
@@ -206,9 +232,10 @@ protected:
paint.setMaskFilter(SkBlurMaskFilter::Make(
kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
- SkBlurMaskFilter::kHighQuality_BlurFlag |
- SkBlurMaskFilter::kIgnoreTransform_BlurFlag));
- canvas->drawBitmapRect(bm, srcRect, dstRect, &paint);
+ SkBlurMaskFilter::kHighQuality_BlurFlag));
+
+ sk_sp<SkImage> image(SkImage::MakeFromBitmap(bm));
+ fProc(canvas, image.get(), bm, srcRect, dstRect, &paint);
}
}
@@ -216,5 +243,7 @@ private:
typedef skiagm::GM INHERITED;
};
-DEF_GM( return new DrawBitmapRectGM(canvasproc, nullptr); )
-DEF_GM( return new DrawBitmapRectGM(imageproc, "-imagerect"); )
+DEF_GM( return new DrawBitmapRectGM(bitmapproc , nullptr); )
+DEF_GM( return new DrawBitmapRectGM(bitmapsubsetproc, "-subset"); )
+DEF_GM( return new DrawBitmapRectGM(imageproc , "-imagerect"); )
+DEF_GM( return new DrawBitmapRectGM(imagesubsetproc , "-imagerect-subset"); )
« no previous file with comments | « no previous file | src/core/SkBitmapDevice.cpp » ('j') | src/core/SkBitmapDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698