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

Unified Diff: gm/subsetshader.cpp

Issue 1848383002: SkPDF: properly dedup bitmaps in shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-01 (Friday) 14:35:15 EDT Created 4 years, 9 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/pdf/SkBitmapKey.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/subsetshader.cpp
diff --git a/gm/subsetshader.cpp b/gm/subsetshader.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c4ef5f7a774f7b1a5476ec9d23c1d00e83987d19
--- /dev/null
+++ b/gm/subsetshader.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Resources.h"
+#include "SkBitmap.h"
+#include "gm.h"
+
+DEF_SIMPLE_GM(bitmap_subset_shader, canvas, 256, 256) {
+ canvas->clear(SK_ColorWHITE);
+
+ SkBitmap source;
+ if (!GetResourceAsBitmap("color_wheel.png", &source)) {
+ return;
+ }
+ SkIRect left = SkIRect::MakeWH(source.width()/2, source.height());
+ SkIRect right = SkIRect::MakeXYWH(source.width()/2, 0,
+ source.width()/2, source.height());
+ SkBitmap leftBitmap, rightBitmap;
+ source.extractSubset(&leftBitmap, left);
+ source.extractSubset(&rightBitmap, right);
+
+ SkMatrix matrix;
+ matrix.setScale(0.75f, 0.75f);
+ matrix.preRotate(30.0f);
+ SkShader::TileMode tm = SkShader::kRepeat_TileMode;
+ SkPaint paint;
+ paint.setShader(SkShader::MakeBitmapShader(leftBitmap, tm, tm, &matrix));
+ canvas->drawRect(SkRect::MakeWH(256.0f, 128.0f), paint);
+ paint.setShader(SkShader::MakeBitmapShader(rightBitmap, tm, tm, &matrix));
+ canvas->drawRect(SkRect::MakeXYWH(0, 128.0f, 256.0f, 128.0f), paint);
+}
« no previous file with comments | « no previous file | src/pdf/SkBitmapKey.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698