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

Side by Side Diff: gm/imagesource2.cpp

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 8 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/offsetimagefilter.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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = surface->makeImageSnapshot(); 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 const SkRect srcRect = SkRect::MakeLTRB(0, 0,
64 SkIntToScalar(kImageSize), SkIntToScal ar(kImageSize)); 64 SkIntToScalar(kImageSize),
65 SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f); 65 SkIntToScalar(kImageSize));
66 66 const SkRect dstRect = SkRect::MakeLTRB(0.75f, 0.75f, 225.75f, 225.75f);
67 SkAutoTUnref<SkImageFilter> filter(
68 SkImageSource::Create(fImage.get(), srcRect, dstRect, fFilter));
69 67
70 SkPaint p; 68 SkPaint p;
71 p.setImageFilter(filter); 69 p.setImageFilter(SkImageSource::Make(fImage, srcRect, dstRect, fFilter)) ;
72 70
73 canvas->saveLayer(nullptr, &p); 71 canvas->saveLayer(nullptr, &p);
74 canvas->restore(); 72 canvas->restore();
75 } 73 }
76 74
77 private: 75 private:
78 static const int kImageSize = 503; 76 static const int kImageSize = 503;
79 77
80 SkString fSuffix; 78 SkString fSuffix;
81 SkFilterQuality fFilter; 79 SkFilterQuality fFilter;
82 sk_sp<SkImage> fImage; 80 sk_sp<SkImage> fImage;
83 81
84 typedef GM INHERITED; 82 typedef GM INHERITED;
85 }; 83 };
86 84
87 ////////////////////////////////////////////////////////////////////////////// 85 //////////////////////////////////////////////////////////////////////////////
88 86
89 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);) 87 DEF_GM(return new ImageSourceGM("none", kNone_SkFilterQuality);)
90 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);) 88 DEF_GM(return new ImageSourceGM("low", kLow_SkFilterQuality);)
91 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);) 89 DEF_GM(return new ImageSourceGM("med", kMedium_SkFilterQuality);)
92 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);) 90 DEF_GM(return new ImageSourceGM("high", kHigh_SkFilterQuality);)
93 } 91 }
OLDNEW
« no previous file with comments | « gm/imagesource.cpp ('k') | gm/offsetimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698