aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-05-23 16:39:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-24 17:42:38 +0000
commita0047bcff704a9121a6d82a6f97d6124463a2e54 (patch)
treeb8c6b0e17a17ec95b779482609490b82fb4c8a35 /gm
parent6ddbafcc898d1f487f147c651a3b6519b7210802 (diff)
Add support for SkCanvas::kStrict_SrcRectConstraint to GrTextureOp.
Change-Id: I8faa2838b3110b8080ac48bbe223240e3fb22998 Reviewed-on: https://skia-review.googlesource.com/129762 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/perspimages.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/gm/perspimages.cpp b/gm/perspimages.cpp
index a4242cf6f2..b4ad5eb9ae 100644
--- a/gm/perspimages.cpp
+++ b/gm/perspimages.cpp
@@ -28,7 +28,7 @@ public:
protected:
SkString onShortName() override { return SkString("persp_images"); }
- SkISize onISize() override { return SkISize::Make(1150, 880); }
+ SkISize onISize() override { return SkISize::Make(1150, 1280); }
void onOnceBeforeDraw() override {
fImages.push_back(make_image1());
@@ -60,7 +60,13 @@ protected:
}
canvas->translate(-bounds.fLeft + 10.f, -bounds.fTop + 10.f);
canvas->save();
- for (auto subrect : {false, true}) {
+ enum class DrawType {
+ kDrawImage,
+ kDrawImageRectStrict,
+ kDrawImageRectFast,
+ };
+ for (auto type :
+ {DrawType::kDrawImage, DrawType::kDrawImageRectStrict, DrawType::kDrawImageRectFast}) {
for (const auto& m : matrices) {
for (auto aa : {false, true}) {
paint.setAntiAlias(aa);
@@ -70,14 +76,22 @@ protected:
paint.setFilterQuality(filter);
canvas->save();
canvas->concat(m);
- if (subrect) {
- SkRect src = {img->width() / 4.f, img->height() / 4.f,
- 3.f * img->width() / 4.f, 3.f * img->height() / 4};
- SkRect dst = {0, 0,
- 3.f / 4.f * img->width(), 3.f / 4.f * img->height()};
- canvas->drawImageRect(img, src, dst, &paint);
- } else {
- canvas->drawImage(img, 0, 0, &paint);
+ SkRect src = {img->width() / 4.f, img->height() / 4.f,
+ 3.f * img->width() / 4.f, 3.f * img->height() / 4};
+ SkRect dst = {0, 0,
+ 3.f / 4.f * img->width(), 3.f / 4.f * img->height()};
+ switch (type) {
+ case DrawType::kDrawImage:
+ canvas->drawImage(img, 0, 0, &paint);
+ break;
+ case DrawType::kDrawImageRectStrict:
+ canvas->drawImageRect(img, src, dst, &paint,
+ SkCanvas::kStrict_SrcRectConstraint);
+ break;
+ case DrawType::kDrawImageRectFast:
+ canvas->drawImageRect(img, src, dst, &paint,
+ SkCanvas::kFast_SrcRectConstraint);
+ break;
}
canvas->restore();
++n;