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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/pdf/SkBitmapKey.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Resources.h"
9 #include "SkBitmap.h"
10 #include "gm.h"
11
12 DEF_SIMPLE_GM(bitmap_subset_shader, canvas, 256, 256) {
13 canvas->clear(SK_ColorWHITE);
14
15 SkBitmap source;
16 if (!GetResourceAsBitmap("color_wheel.png", &source)) {
17 return;
18 }
19 SkIRect left = SkIRect::MakeWH(source.width()/2, source.height());
20 SkIRect right = SkIRect::MakeXYWH(source.width()/2, 0,
21 source.width()/2, source.height());
22 SkBitmap leftBitmap, rightBitmap;
23 source.extractSubset(&leftBitmap, left);
24 source.extractSubset(&rightBitmap, right);
25
26 SkMatrix matrix;
27 matrix.setScale(0.75f, 0.75f);
28 matrix.preRotate(30.0f);
29 SkShader::TileMode tm = SkShader::kRepeat_TileMode;
30 SkPaint paint;
31 paint.setShader(SkShader::MakeBitmapShader(leftBitmap, tm, tm, &matrix));
32 canvas->drawRect(SkRect::MakeWH(256.0f, 128.0f), paint);
33 paint.setShader(SkShader::MakeBitmapShader(rightBitmap, tm, tm, &matrix));
34 canvas->drawRect(SkRect::MakeXYWH(0, 128.0f, 256.0f, 128.0f), paint);
35 }
OLDNEW
« 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