OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 if (sk_sp<SkImage> subset = image->makeSubset(srcR)) { | 126 if (sk_sp<SkImage> subset = image->makeSubset(srcR)) { |
127 canvas->drawImageRect(subset, dstR, paint); | 127 canvas->drawImageRect(subset, dstR, paint); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRec
t&, const SkRect&, | 131 typedef void DrawRectRectProc(SkCanvas*, SkImage*, const SkBitmap&, const SkIRec
t&, const SkRect&, |
132 const SkPaint*); | 132 const SkPaint*); |
133 | 133 |
134 static const int gSize = 1024; | 134 constexpr int gSize = 1024; |
135 static const int gBmpSize = 2048; | 135 constexpr int gBmpSize = 2048; |
136 | 136 |
137 class DrawBitmapRectGM : public skiagm::GM { | 137 class DrawBitmapRectGM : public skiagm::GM { |
138 public: | 138 public: |
139 DrawBitmapRectGM(DrawRectRectProc proc, const char suffix[]) : fProc(proc) { | 139 DrawBitmapRectGM(DrawRectRectProc proc, const char suffix[]) : fProc(proc) { |
140 fName.set("drawbitmaprect"); | 140 fName.set("drawbitmaprect"); |
141 if (suffix) { | 141 if (suffix) { |
142 fName.append(suffix); | 142 fName.append(suffix); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
(...skipping 10 matching lines...) Expand all Loading... |
156 void setupImage(SkCanvas* canvas) { | 156 void setupImage(SkCanvas* canvas) { |
157 fImage = makebm(canvas, &fLargeBitmap, gBmpSize, gBmpSize); | 157 fImage = makebm(canvas, &fLargeBitmap, gBmpSize, gBmpSize); |
158 } | 158 } |
159 | 159 |
160 void onDraw(SkCanvas* canvas) override { | 160 void onDraw(SkCanvas* canvas) override { |
161 if (!fImage) { | 161 if (!fImage) { |
162 this->setupImage(canvas); | 162 this->setupImage(canvas); |
163 } | 163 } |
164 | 164 |
165 SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; | 165 SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; |
166 static const int kMaxSrcRectSize = 1 << (SkNextLog2(gBmpSize) + 2); | 166 const int kMaxSrcRectSize = 1 << (SkNextLog2(gBmpSize) + 2); |
167 | 167 |
168 static const int kPadX = 30; | 168 const int kPadX = 30; |
169 static const int kPadY = 40; | 169 const int kPadY = 40; |
170 SkPaint paint; | 170 SkPaint paint; |
171 paint.setAlpha(0x20); | 171 paint.setAlpha(0x20); |
172 canvas->drawImageRect(fImage, SkRect::MakeIWH(gSize, gSize), &paint); | 172 canvas->drawImageRect(fImage, SkRect::MakeIWH(gSize, gSize), &paint); |
173 canvas->translate(SK_Scalar1 * kPadX / 2, | 173 canvas->translate(SK_Scalar1 * kPadX / 2, |
174 SK_Scalar1 * kPadY / 2); | 174 SK_Scalar1 * kPadY / 2); |
175 SkPaint blackPaint; | 175 SkPaint blackPaint; |
176 SkScalar titleHeight = SK_Scalar1 * 24; | 176 SkScalar titleHeight = SK_Scalar1 * 24; |
177 blackPaint.setColor(SK_ColorBLACK); | 177 blackPaint.setColor(SK_ColorBLACK); |
178 blackPaint.setTextSize(titleHeight); | 178 blackPaint.setTextSize(titleHeight); |
179 blackPaint.setAntiAlias(true); | 179 blackPaint.setAntiAlias(true); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 240 } |
241 | 241 |
242 private: | 242 private: |
243 typedef skiagm::GM INHERITED; | 243 typedef skiagm::GM INHERITED; |
244 }; | 244 }; |
245 | 245 |
246 DEF_GM( return new DrawBitmapRectGM(bitmapproc , nullptr); ) | 246 DEF_GM( return new DrawBitmapRectGM(bitmapproc , nullptr); ) |
247 DEF_GM( return new DrawBitmapRectGM(bitmapsubsetproc, "-subset"); ) | 247 DEF_GM( return new DrawBitmapRectGM(bitmapsubsetproc, "-subset"); ) |
248 DEF_GM( return new DrawBitmapRectGM(imageproc , "-imagerect"); ) | 248 DEF_GM( return new DrawBitmapRectGM(imageproc , "-imagerect"); ) |
249 DEF_GM( return new DrawBitmapRectGM(imagesubsetproc , "-imagerect-subset"); ) | 249 DEF_GM( return new DrawBitmapRectGM(imagesubsetproc , "-imagerect-subset"); ) |
OLD | NEW |