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

Side by Side Diff: gm/image.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 * 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 "SkData.h" 9 #include "SkData.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 src2.iset(-surf->width() / 2, -surf->height() / 2, 85 src2.iset(-surf->width() / 2, -surf->height() / 2,
86 surf->width(), surf->height()); 86 surf->width(), surf->height());
87 src3.iset(0, 0, surf->width() / 2, surf->height() / 2); 87 src3.iset(0, 0, surf->width() / 2, surf->height() / 2);
88 88
89 SkRect dst1, dst2, dst3, dst4; 89 SkRect dst1, dst2, dst3, dst4;
90 dst1.set(0, 240, 65, 305); 90 dst1.set(0, 240, 65, 305);
91 dst2.set(0, 320, 65, 385); 91 dst2.set(0, 320, 65, 385);
92 dst3.set(0, 400, 65, 465); 92 dst3.set(0, 400, 65, 465);
93 dst4.set(0, 480, 65, 545); 93 dst4.set(0, 480, 65, 545);
94 94
95 canvas->drawImageRect(imgR, &src1, dst1, usePaint ? &paint : NULL); 95 canvas->drawImageRect(imgR, src1, dst1, usePaint ? &paint : NULL);
96 canvas->drawImageRect(imgG, &src2, dst2, usePaint ? &paint : NULL); 96 canvas->drawImageRect(imgG, src2, dst2, usePaint ? &paint : NULL);
97 canvas->drawImageRect(imgR, &src3, dst3, usePaint ? &paint : NULL); 97 canvas->drawImageRect(imgR, src3, dst3, usePaint ? &paint : NULL);
98 canvas->drawImageRect(imgG, NULL, dst4, usePaint ? &paint : NULL); 98 canvas->drawImageRect(imgG, dst4, usePaint ? &paint : NULL);
99 99
100 imgG->unref(); 100 imgG->unref();
101 imgR->unref(); 101 imgR->unref();
102 } 102 }
103 103
104 class ImageGM : public skiagm::GM { 104 class ImageGM : public skiagm::GM {
105 void* fBuffer; 105 void* fBuffer;
106 size_t fBufferSize; 106 size_t fBufferSize;
107 SkSize fSize; 107 SkSize fSize;
108 enum { 108 enum {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 this->drawIntoImage(surface->getCanvas()); 230 this->drawIntoImage(surface->getCanvas());
231 return surface->newImageSnapshot(); 231 return surface->newImageSnapshot();
232 } 232 }
233 233
234 void drawResized(SkCanvas* canvas, SkImage* image, int newW, int newH, const SkIRect* subset, 234 void drawResized(SkCanvas* canvas, SkImage* image, int newW, int newH, const SkIRect* subset,
235 SkFilterQuality fq) { 235 SkFilterQuality fq) {
236 // canvas method 236 // canvas method
237 SkPaint paint; 237 SkPaint paint;
238 paint.setFilterQuality(fq); 238 paint.setFilterQuality(fq);
239 SkRect dstR = SkRect::MakeWH(SkIntToScalar(newW), SkIntToScalar(newH)); 239 SkRect dstR = SkRect::MakeWH(SkIntToScalar(newW), SkIntToScalar(newH));
robertphillips 2015/08/06 17:23:00 SkRect srcR = SkRect::MakeWH(image->width(), image
240 SkRect srcR; 240 SkRect srcR;
241 if (subset) { 241 if (subset) {
242 srcR.set(*subset); 242 srcR.set(*subset);
243 } 243 }
244 canvas->drawImageRect(image, subset ? &srcR : NULL, dstR, &paint); 244 canvas->legacy_drawImageRect(image, subset ? &srcR : NULL, dstR, &paint) ;
245 canvas->translate(newW + 20.0f, 0); 245 canvas->translate(newW + 20.0f, 0);
246 246
247 // image method 247 // image method
248 SkAutoTUnref<SkImage> image2(image->newImage(newW, newH, subset, fq)); 248 SkAutoTUnref<SkImage> image2(image->newImage(newW, newH, subset, fq));
249 canvas->drawImage(image2, 0, 0, NULL); 249 canvas->drawImage(image2, 0, 0, NULL);
250 canvas->translate(image2->width() + 20.0f, 0); 250 canvas->translate(image2->width() + 20.0f, 0);
251 } 251 }
252 252
253 void drawImage(SkCanvas* canvas, SkImage* image, SkFilterQuality fq) { 253 void drawImage(SkCanvas* canvas, SkImage* image, SkFilterQuality fq) {
254 254
(...skipping 23 matching lines...) Expand all
278 } 278 }
279 canvas->translate(0, image->height() + 20.0f); 279 canvas->translate(0, image->height() + 20.0f);
280 } 280 }
281 } 281 }
282 282
283 private: 283 private:
284 typedef skiagm::GM INHERITED; 284 typedef skiagm::GM INHERITED;
285 }; 285 };
286 DEF_GM( return new ImageResizeGM; ) 286 DEF_GM( return new ImageResizeGM; )
287 287
OLDNEW
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/mipmap.cpp » ('j') | src/c/sk_surface.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698