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

Side by Side Diff: gm/imagesource2.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/imagesource.cpp ('k') | gm/imagetoyuvplanes.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 "SkImage.h" 9 #include "SkImage.h"
10 #include "SkImageSource.h" 10 #include "SkImageSource.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 for (int x = 0; x < kImageSize; x += 3) { 49 for (int x = 0; x < kImageSize; x += 3) {
50 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0), 50 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(0),
51 SkIntToScalar(3), SkIntToScalar(kImageSi ze)); 51 SkIntToScalar(3), SkIntToScalar(kImageSi ze));
52 SkPaint p; 52 SkPaint p;
53 p.setColor(gColors[curColor]); 53 p.setColor(gColors[curColor]);
54 canvas->drawRect(r, p); 54 canvas->drawRect(r, p);
55 55
56 curColor = (curColor+1) % SK_ARRAY_COUNT(gColors); 56 curColor = (curColor+1) % SK_ARRAY_COUNT(gColors);
57 } 57 }
58 58
59 fImage.reset(surface->newImageSnapshot()); 59 fImage = surface->makeImageSnapshot();
60 } 60 }
61 61
62 void onDraw(SkCanvas* canvas) override { 62 void onDraw(SkCanvas* canvas) override {
63 SkRect srcRect = SkRect::MakeLTRB(0, 0, 63 SkRect srcRect = SkRect::MakeLTRB(0, 0,
64 SkIntToScalar(kImageSize), SkIntToScal ar(kImageSize)); 64 SkIntToScalar(kImageSize), SkIntToScal ar(kImageSize));
65 SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f); 65 SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f);
66 66
67 SkAutoTUnref<SkImageFilter> filter( 67 SkAutoTUnref<SkImageFilter> filter(
68 SkImageSource::Create(fImage, srcRect, dstRect, fFilter)); 68 SkImageSource::Create(fImage.get(), srcRect, dstRect, fFilter));
69 69
70 SkPaint p; 70 SkPaint p;
71 p.setImageFilter(filter); 71 p.setImageFilter(filter);
72 72
73 canvas->saveLayer(nullptr, &p); 73 canvas->saveLayer(nullptr, &p);
74 canvas->restore(); 74 canvas->restore();
75 } 75 }
76 76
77 private: 77 private:
78 static const int kImageSize = 503; 78 static const int kImageSize = 503;
79 79
80 SkString fSuffix; 80 SkString fSuffix;
81 SkFilterQuality fFilter; 81 SkFilterQuality fFilter;
82 SkAutoTUnref<SkImage> fImage; 82 sk_sp<SkImage> fImage;
83 83
84 typedef GM INHERITED; 84 typedef GM INHERITED;
85 }; 85 };
86 86
87 ////////////////////////////////////////////////////////////////////////////// 87 //////////////////////////////////////////////////////////////////////////////
88 88
89 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) 89 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);)
90 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) 90 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);)
91 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) 91 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);)
92 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) 92 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);)
93 } 93 }
OLDNEW
« no previous file with comments | « gm/imagesource.cpp ('k') | gm/imagetoyuvplanes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698