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

Side by Side Diff: gm/imagesource.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/imagescalealigned.cpp ('k') | gm/imagesource2.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 2013 Google Inc. 2 * Copyright 2013 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 9
10 #include "SkImage.h" 10 #include "SkImage.h"
11 #include "SkImageSource.h" 11 #include "SkImageSource.h"
12 12
13 // This GM exercises the SkImageSource ImageFilter class. 13 // This GM exercises the SkImageSource ImageFilter class.
14 14
15 class ImageSourceGM : public skiagm::GM { 15 class ImageSourceGM : public skiagm::GM {
16 public: 16 public:
17 ImageSourceGM() { } 17 ImageSourceGM() { }
18 18
19 protected: 19 protected:
20 SkString onShortName() override { 20 SkString onShortName() override {
21 return SkString("imagesource"); 21 return SkString("imagesource");
22 } 22 }
23 23
24 SkISize onISize() override { return SkISize::Make(500, 150); } 24 SkISize onISize() override { return SkISize::Make(500, 150); }
25 25
26 void onOnceBeforeDraw() override { 26 void onOnceBeforeDraw() override {
27 SkBitmap bm = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e"); 27 SkBitmap bm = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
28 fImage.reset(SkImage::NewFromBitmap(bm)); 28 fImage = SkImage::MakeFromBitmap(bm);
29 } 29 }
30 30
31 static void FillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma geFilter* filter) { 31 static void FillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma geFilter* filter) {
32 SkPaint paint; 32 SkPaint paint;
33 paint.setImageFilter(filter); 33 paint.setImageFilter(filter);
34 canvas->save(); 34 canvas->save();
35 canvas->clipRect(clipRect); 35 canvas->clipRect(clipRect);
36 canvas->drawPaint(paint); 36 canvas->drawPaint(paint);
37 canvas->restore(); 37 canvas->restore();
38 } 38 }
39 39
40 void onDraw(SkCanvas* canvas) override { 40 void onDraw(SkCanvas* canvas) override {
41 canvas->clear(SK_ColorBLACK); 41 canvas->clear(SK_ColorBLACK);
42 { 42 {
43 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); 43 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
44 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); 44 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60);
45 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); 45 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
46 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height()); 46 SkRect bounds = SkRect::MakeIWH(fImage->width(), fImage->height());
47 SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fImage )); 47 SkAutoTUnref<SkImageFilter> imageSource(SkImageSource::Create(fImage .get()));
48 SkAutoTUnref<SkImageFilter> imageSourceSrcRect( 48 SkAutoTUnref<SkImageFilter> imageSourceSrcRect(
49 SkImageSource::Create(fImage, srcRect, srcRect, kHigh_SkFilterQu ality)); 49 SkImageSource::Create(fImage.get(), srcRect, srcRect, kHigh_SkFi lterQuality));
50 SkAutoTUnref<SkImageFilter> imageSourceSrcRectDstRect( 50 SkAutoTUnref<SkImageFilter> imageSourceSrcRectDstRect(
51 SkImageSource::Create(fImage, srcRect, dstRect, kHigh_SkFilterQu ality)); 51 SkImageSource::Create(fImage.get(), srcRect, dstRect, kHigh_SkFi lterQuality));
52 SkAutoTUnref<SkImageFilter> imageSourceDstRectOnly( 52 SkAutoTUnref<SkImageFilter> imageSourceDstRectOnly(
53 SkImageSource::Create(fImage, bounds, dstRect, kHigh_SkFilterQua lity)); 53 SkImageSource::Create(fImage.get(), bounds, dstRect, kHigh_SkFil terQuality));
54 54
55 // Draw an unscaled bitmap. 55 // Draw an unscaled bitmap.
56 FillRectFiltered(canvas, clipRect, imageSource); 56 FillRectFiltered(canvas, clipRect, imageSource);
57 canvas->translate(SkIntToScalar(100), 0); 57 canvas->translate(SkIntToScalar(100), 0);
58 58
59 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect) . 59 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect) .
60 FillRectFiltered(canvas, clipRect, imageSourceSrcRect); 60 FillRectFiltered(canvas, clipRect, imageSourceSrcRect);
61 canvas->translate(SkIntToScalar(100), 0); 61 canvas->translate(SkIntToScalar(100), 0);
62 62
63 // Draw a subset of the bitmap scaled to a destination rect (srcRect -> dstRect). 63 // Draw a subset of the bitmap scaled to a destination rect (srcRect -> dstRect).
64 FillRectFiltered(canvas, clipRect, imageSourceSrcRectDstRect); 64 FillRectFiltered(canvas, clipRect, imageSourceSrcRectDstRect);
65 canvas->translate(SkIntToScalar(100), 0); 65 canvas->translate(SkIntToScalar(100), 0);
66 66
67 // Draw the entire bitmap scaled to a destination rect (bounds -> ds tRect). 67 // Draw the entire bitmap scaled to a destination rect (bounds -> ds tRect).
68 FillRectFiltered(canvas, clipRect, imageSourceDstRectOnly); 68 FillRectFiltered(canvas, clipRect, imageSourceDstRectOnly);
69 canvas->translate(SkIntToScalar(100), 0); 69 canvas->translate(SkIntToScalar(100), 0);
70 } 70 }
71 } 71 }
72 72
73 private: 73 private:
74 SkAutoTUnref<SkImage> fImage; 74 sk_sp<SkImage> fImage;
75 typedef GM INHERITED; 75 typedef GM INHERITED;
76 }; 76 };
77 77
78 /////////////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////////////
79 79
80 DEF_GM( return new ImageSourceGM; ) 80 DEF_GM( return new ImageSourceGM; )
OLDNEW
« no previous file with comments | « gm/imagescalealigned.cpp ('k') | gm/imagesource2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698