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

Side by Side Diff: gm/bigtileimagefilter.cpp

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up 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
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 "SkImageSource.h" 8 #include "SkImageSource.h"
9 #include "SkSurface.h" 9 #include "SkSurface.h"
10 #include "SkTileImageFilter.h" 10 #include "SkTileImageFilter.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 fRedImage = create_circle_texture(kBitmapSize, SK_ColorRED); 47 fRedImage = create_circle_texture(kBitmapSize, SK_ColorRED);
48 fGreenImage = create_circle_texture(kBitmapSize, SK_ColorGREEN); 48 fGreenImage = create_circle_texture(kBitmapSize, SK_ColorGREEN);
49 } 49 }
50 50
51 void onDraw(SkCanvas* canvas) override { 51 void onDraw(SkCanvas* canvas) override {
52 canvas->clear(SK_ColorBLACK); 52 canvas->clear(SK_ColorBLACK);
53 53
54 { 54 {
55 SkPaint p; 55 SkPaint p;
56 56
57 SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(k Height)); 57 const SkRect bound = SkRect::MakeIWH(kWidth, kHeight);
58 sk_sp<SkImageFilter> imageSource(SkImageSource::Create(fRedImage.get ())); 58 sk_sp<SkImageFilter> imageSource(SkImageSource::Make(fRedImage));
59 SkAutoTUnref<SkImageFilter> tif(SkTileImageFilter::Create( 59
60 SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToSc alar(kBitmapSize)), 60 p.setImageFilter(SkTileImageFilter::Create(SkRect::MakeIWH(kBitmapSi ze, kBitmapSize),
f(malita) 2016/03/31 13:26:09 out-of-order ditto
robertphillips 2016/03/31 14:35:53 Done.
61 SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar( kHeight)), 61 SkRect::MakeIWH(kWidth, k Height),
62 imageSource.get())); 62 imageSource.get()));
63 p.setImageFilter(tif);
64 63
65 canvas->saveLayer(&bound, &p); 64 canvas->saveLayer(&bound, &p);
66 canvas->restore(); 65 canvas->restore();
67 } 66 }
68 67
69 { 68 {
70 SkPaint p2; 69 SkPaint p2;
71 70
72 SkRect bound2 = SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToSc alar(kBitmapSize)); 71 const SkRect bound2 = SkRect::MakeIWH(kBitmapSize, kBitmapSize);
73 72
74 SkAutoTUnref<SkImageFilter> tif2(SkTileImageFilter::Create( 73 p2.setImageFilter(SkTileImageFilter::Create(SkRect::MakeIWH(kBitmapS ize, kBitmapSize),
f(malita) 2016/03/31 13:26:09 out-of-order ditto
robertphillips 2016/03/31 14:35:54 Done.
75 SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToSc alar(kBitmapSize)), 74 SkRect::MakeIWH(kBitmapS ize, kBitmapSize),
76 SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToSc alar(kBitmapSize)), 75 nullptr));
77 nullptr));
78 p2.setImageFilter(tif2);
79 76
80 canvas->translate(320, 320); 77 canvas->translate(320, 320);
81 canvas->saveLayer(&bound2, &p2); 78 canvas->saveLayer(&bound2, &p2);
82 canvas->setMatrix(SkMatrix::I()); 79 canvas->setMatrix(SkMatrix::I());
83 80
84 SkRect bound3 = SkRect::MakeXYWH(320, 320, 81 SkRect bound3 = SkRect::MakeXYWH(320, 320,
85 SkIntToScalar(kBitmapSize), 82 SkIntToScalar(kBitmapSize),
86 SkIntToScalar(kBitmapSize)); 83 SkIntToScalar(kBitmapSize));
87 canvas->drawImageRect(fGreenImage.get(), bound2, bound3, nullptr, 84 canvas->drawImageRect(fGreenImage.get(), bound2, bound3, nullptr,
88 SkCanvas::kStrict_SrcRectConstraint); 85 SkCanvas::kStrict_SrcRectConstraint);
89 canvas->restore(); 86 canvas->restore();
90 } 87 }
91 } 88 }
92 89
93 private: 90 private:
94 static const int kWidth = 512; 91 static const int kWidth = 512;
95 static const int kHeight = 512; 92 static const int kHeight = 512;
96 static const int kBitmapSize = 64; 93 static const int kBitmapSize = 64;
97 94
98 sk_sp<SkImage> fRedImage; 95 sk_sp<SkImage> fRedImage;
99 sk_sp<SkImage> fGreenImage; 96 sk_sp<SkImage> fGreenImage;
100 97
101 typedef GM INHERITED; 98 typedef GM INHERITED;
102 }; 99 };
103 100
104 ////////////////////////////////////////////////////////////////////////////// 101 //////////////////////////////////////////////////////////////////////////////
105 102
106 DEF_GM(return new BigTileImageFilterGM;) 103 DEF_GM(return new BigTileImageFilterGM;)
107 } 104 }
OLDNEW
« no previous file with comments | « bench/MergeBench.cpp ('k') | gm/displacement.cpp » ('j') | gm/imagesource.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698