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

Side by Side Diff: gm/mipmap.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage 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 unified diff | Download patch
« no previous file with comments | « gm/localmatriximagefilter.cpp ('k') | gm/multipicturedraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkSurface.h" 12 #include "SkSurface.h"
13 13
14 static SkImage* make_image() { 14 static sk_sp<SkImage> make_image() {
15 const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52); 15 const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
16 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 16 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
17 SkCanvas* canvas = surface->getCanvas(); 17 SkCanvas* canvas = surface->getCanvas();
18 canvas->drawColor(sk_tool_utils::color_to_565(0xFFF8F8F8)); 18 canvas->drawColor(sk_tool_utils::color_to_565(0xFFF8F8F8));
19 19
20 SkPaint paint; 20 SkPaint paint;
21 paint.setAntiAlias(true); 21 paint.setAntiAlias(true);
22 22
23 paint.setStyle(SkPaint::kStroke_Style); 23 paint.setStyle(SkPaint::kStroke_Style);
24 for (int i = 0; i < 20; ++i) { 24 for (int i = 0; i < 20; ++i) {
25 canvas->drawCircle(-4, 25, 20, paint); 25 canvas->drawCircle(-4, 25, 20, paint);
26 canvas->translate(25, 0); 26 canvas->translate(25, 0);
27 } 27 }
28 return surface->newImageSnapshot(); 28 return surface->makeImageSnapshot();
29 } 29 }
30 30
31 DEF_SIMPLE_GM(mipmap, canvas, 400, 200) { 31 DEF_SIMPLE_GM(mipmap, canvas, 400, 200) {
32 SkAutoTUnref<SkImage> img(make_image());//SkImage::NewFromEncoded(data)); 32 sk_sp<SkImage> img(make_image());//SkImage::NewFromEncoded(data));
33 33
34 SkPaint paint; 34 SkPaint paint;
35 const SkRect dst = SkRect::MakeWH(177, 15); 35 const SkRect dst = SkRect::MakeWH(177, 15);
36 36
37 paint.setTextSize(30); 37 paint.setTextSize(30);
38 SkString str; 38 SkString str;
39 str.printf("scale %g %g", dst.width() / img->width(), dst.height() / img->he ight()); 39 str.printf("scale %g %g", dst.width() / img->width(), dst.height() / img->he ight());
40 // canvas->drawText(str.c_str(), str.size(), 300, 100, paint); 40 // canvas->drawText(str.c_str(), str.size(), 300, 100, paint);
41 41
42 canvas->translate(20, 20); 42 canvas->translate(20, 20);
43 for (int i = 0; i < 4; ++i) { 43 for (int i = 0; i < 4; ++i) {
44 paint.setFilterQuality(SkFilterQuality(i)); 44 paint.setFilterQuality(SkFilterQuality(i));
45 canvas->drawImageRect(img, dst, &paint); 45 canvas->drawImageRect(img.get(), dst, &paint);
46 canvas->translate(0, 20); 46 canvas->translate(0, 20);
47 } 47 }
48 canvas->drawImage(img, 20, 20, nullptr); 48 canvas->drawImage(img.get(), 20, 20, nullptr);
49 } 49 }
50 50
OLDNEW
« no previous file with comments | « gm/localmatriximagefilter.cpp ('k') | gm/multipicturedraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698