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

Side by Side Diff: gm/bitmaprect.cpp

Issue 1272713005: flag to use const& instead of const* for src-rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 SkRect dstR = { 0, 200, 128, 380 }; 64 SkRect dstR = { 0, 200, 128, 380 };
65 65
66 canvas->translate(16, 40); 66 canvas->translate(16, 40);
67 for (size_t i = 0; i < SK_ARRAY_COUNT(src); i++) { 67 for (size_t i = 0; i < SK_ARRAY_COUNT(src); i++) {
68 SkRect srcR; 68 SkRect srcR;
69 srcR.set(src[i]); 69 srcR.set(src[i]);
70 70
71 canvas->drawBitmap(bitmap, 0, 0, &paint); 71 canvas->drawBitmap(bitmap, 0, 0, &paint);
72 if (!fUseIRect) { 72 if (!fUseIRect) {
73 canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint, 73 canvas->drawBitmapRect(bitmap, srcR, dstR, &paint,
74 SkCanvas::kStrict_SrcRectConstraint); 74 SkCanvas::kStrict_SrcRectConstraint);
75 } else { 75 } else {
76 canvas->drawBitmapRect(bitmap, src[i], dstR, &paint); 76 canvas->drawBitmapRect(bitmap, src[i], dstR, &paint);
77 } 77 }
78 78
79 canvas->drawRect(dstR, paint); 79 canvas->drawRect(dstR, paint);
80 canvas->drawRect(srcR, paint); 80 canvas->drawRect(srcR, paint);
81 81
82 canvas->translate(160, 0); 82 canvas->translate(160, 0);
83 } 83 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 void onDraw(SkCanvas* canvas) override { 138 void onDraw(SkCanvas* canvas) override {
139 139
140 SkBitmap bitmap; 140 SkBitmap bitmap;
141 make_3x3_bitmap(&bitmap); 141 make_3x3_bitmap(&bitmap);
142 142
143 SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f }; 143 SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f };
144 SkRect dstR = { 100, 100, 300, 200 }; 144 SkRect dstR = { 100, 100, 300, 200 };
145 145
146 canvas->drawBitmapRect(bitmap, &srcR, dstR, NULL, SkCanvas::kStrict_SrcR ectConstraint); 146 canvas->drawBitmapRect(bitmap, srcR, dstR, nullptr, SkCanvas::kStrict_Sr cRectConstraint);
147 } 147 }
148 148
149 private: 149 private:
150 typedef skiagm::GM INHERITED; 150 typedef skiagm::GM INHERITED;
151 }; 151 };
152 152
153 ////////////////////////////////////////////////////////////////////////////// 153 //////////////////////////////////////////////////////////////////////////////
154 static void make_big_bitmap(SkBitmap* bitmap) { 154 static void make_big_bitmap(SkBitmap* bitmap) {
155 155
156 static const int gXSize = 4096; 156 static const int gXSize = 4096;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 paint.setAlpha(128); 206 paint.setAlpha(128);
207 paint.setXfermode(mode)->unref(); 207 paint.setXfermode(mode)->unref();
208 208
209 SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f }; 209 SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f };
210 SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f }; 210 SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f };
211 211
212 SkRect srcR2 = { 4085.0f, 10.0f, 4087.0f, 12.0f }; 212 SkRect srcR2 = { 4085.0f, 10.0f, 4087.0f, 12.0f };
213 SkRect dstR2 = { 10, 410, 30, 430 }; 213 SkRect dstR2 = { 10, 410, 30, 430 };
214 214
215 if (!fUseIRect) { 215 if (!fUseIRect) {
216 canvas->drawBitmapRect(fBigBitmap, &srcR1, dstR1, &paint, 216 canvas->drawBitmapRect(fBigBitmap, srcR1, dstR1, &paint,
217 SkCanvas::kStrict_SrcRectConstraint); 217 SkCanvas::kStrict_SrcRectConstraint);
218 canvas->drawBitmapRect(fBigBitmap, &srcR2, dstR2, &paint, 218 canvas->drawBitmapRect(fBigBitmap, srcR2, dstR2, &paint,
219 SkCanvas::kStrict_SrcRectConstraint); 219 SkCanvas::kStrict_SrcRectConstraint);
220 } else { 220 } else {
221 canvas->drawBitmapRect(fBigBitmap, srcR1.roundOut(), dstR1, &paint); 221 canvas->drawBitmapRect(fBigBitmap, srcR1.roundOut(), dstR1, &paint);
222 canvas->drawBitmapRect(fBigBitmap, srcR2.roundOut(), dstR2, &paint); 222 canvas->drawBitmapRect(fBigBitmap, srcR2.roundOut(), dstR2, &paint);
223 } 223 }
224 } 224 }
225 225
226 private: 226 private:
227 typedef skiagm::GM INHERITED; 227 typedef skiagm::GM INHERITED;
228 }; 228 };
(...skipping 27 matching lines...) Expand all
256 // The correct image should be all blue. 256 // The correct image should be all blue.
257 void onDraw(SkCanvas* canvas) override { 257 void onDraw(SkCanvas* canvas) override {
258 SkPaint paint; 258 SkPaint paint;
259 paint.setColor(SK_ColorRED); 259 paint.setColor(SK_ColorRED);
260 260
261 const SkRect r = SkRect::MakeXYWH(1, 1, 110, 114); 261 const SkRect r = SkRect::MakeXYWH(1, 1, 110, 114);
262 canvas->scale(0.9f, 0.9f); 262 canvas->scale(0.9f, 0.9f);
263 263
264 // the drawRect shows the same problem as clipRect(r) followed by drawco lor(red) 264 // the drawRect shows the same problem as clipRect(r) followed by drawco lor(red)
265 canvas->drawRect(r, paint); 265 canvas->drawRect(r, paint);
266 canvas->drawBitmapRect(fBM, NULL, r, NULL); 266 canvas->drawBitmapRect(fBM, r, nullptr);
267 } 267 }
268 268
269 private: 269 private:
270 typedef skiagm::GM INHERITED; 270 typedef skiagm::GM INHERITED;
271 }; 271 };
272 DEF_GM( return new BitmapRectRounding; ) 272 DEF_GM( return new BitmapRectRounding; )
273 273
274 ////////////////////////////////////////////////////////////////////////////// 274 //////////////////////////////////////////////////////////////////////////////
275 275
276 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); } 276 static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); }
277 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); } 277 static skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); }
278 278
279 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); } 279 static skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); }
280 280
281 #ifndef SK_BUILD_FOR_ANDROID 281 #ifndef SK_BUILD_FOR_ANDROID
282 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); } 282 static skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); }
283 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); } 283 static skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); }
284 #endif 284 #endif
285 285
286 static skiagm::GMRegistry reg0(MyFactory0); 286 static skiagm::GMRegistry reg0(MyFactory0);
287 static skiagm::GMRegistry reg1(MyFactory1); 287 static skiagm::GMRegistry reg1(MyFactory1);
288 288
289 static skiagm::GMRegistry reg2(MyFactory2); 289 static skiagm::GMRegistry reg2(MyFactory2);
290 290
291 #ifndef SK_BUILD_FOR_ANDROID 291 #ifndef SK_BUILD_FOR_ANDROID
292 static skiagm::GMRegistry reg3(MyFactory3); 292 static skiagm::GMRegistry reg3(MyFactory3);
293 static skiagm::GMRegistry reg4(MyFactory4); 293 static skiagm::GMRegistry reg4(MyFactory4);
294 #endif 294 #endif
295 295
OLDNEW
« no previous file with comments | « gm/bigtileimagefilter.cpp ('k') | gm/bitmaprecttest.cpp » ('j') | gm/image.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698