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

Side by Side Diff: gm/tileimagefilter.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/resizeimagefilter.cpp ('k') | gm/xfermodeimagefilter.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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkColorFilterImageFilter.h" 9 #include "SkColorFilterImageFilter.h"
10 #include "SkColorMatrixFilter.h" 10 #include "SkColorMatrixFilter.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 canvas->clear(SK_ColorBLACK); 49 canvas->clear(SK_ColorBLACK);
50 SkPaint red; 50 SkPaint red;
51 red.setColor(SK_ColorRED); 51 red.setColor(SK_ColorRED);
52 red.setStyle(SkPaint::kStroke_Style); 52 red.setStyle(SkPaint::kStroke_Style);
53 SkPaint blue; 53 SkPaint blue;
54 blue.setColor(SK_ColorBLUE); 54 blue.setColor(SK_ColorBLUE);
55 blue.setStyle(SkPaint::kStroke_Style); 55 blue.setStyle(SkPaint::kStroke_Style);
56 56
57 int x = 0, y = 0; 57 int x = 0, y = 0;
58 for (size_t i = 0; i < 4; i++) { 58 for (size_t i = 0; i < 4; i++) {
59 SkImage* image = (i & 0x01) ? fCheckerboard.get() : fBitmap.get(); 59 sk_sp<SkImage> image = (i & 0x01) ? fCheckerboard : fBitmap;
60 SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(image->width()/4), 60 SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(image->width()/4),
61 SkIntToScalar(image->height()/4), 61 SkIntToScalar(image->height()/4),
62 SkIntToScalar(image->width()/(i+1) ), 62 SkIntToScalar(image->width()/(i+1) ),
63 SkIntToScalar(image->height()/(i+1 ))); 63 SkIntToScalar(image->height()/(i+1 )));
64 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(i * 8), 64 SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(i * 8),
65 SkIntToScalar(i * 4), 65 SkIntToScalar(i * 4),
66 SkIntToScalar(image->width() - i * 12), 66 SkIntToScalar(image->width() - i * 12),
67 SkIntToScalar(image->height()) - i * 12); 67 SkIntToScalar(image->height()) - i * 12);
68 SkAutoTUnref<SkImageFilter> tileInput(SkImageSource::Create(image)); 68 sk_sp<SkImageFilter> tileInput(SkImageSource::Make(image));
69 SkAutoTUnref<SkImageFilter> filter( 69 sk_sp<SkImageFilter> filter(SkTileImageFilter::Create(srcRect, dstRe ct, tileInput.get()));
70 SkTileImageFilter::Create(srcRect, dstRect, tileInput));
71 canvas->save(); 70 canvas->save();
72 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 71 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
73 SkPaint paint; 72 SkPaint paint;
74 paint.setImageFilter(filter); 73 paint.setImageFilter(std::move(filter));
75 canvas->drawImage(fBitmap.get(), 0, 0, &paint); 74 canvas->drawImage(fBitmap.get(), 0, 0, &paint);
76 canvas->drawRect(srcRect, red); 75 canvas->drawRect(srcRect, red);
77 canvas->drawRect(dstRect, blue); 76 canvas->drawRect(dstRect, blue);
78 canvas->restore(); 77 canvas->restore();
79 x += image->width() + MARGIN; 78 x += image->width() + MARGIN;
80 if (x + image->width() > WIDTH) { 79 if (x + image->width() > WIDTH) {
81 x = 0; 80 x = 0;
82 y += image->height() + MARGIN; 81 y += image->height() + MARGIN;
83 } 82 }
84 } 83 }
(...skipping 26 matching lines...) Expand all
111 private: 110 private:
112 sk_sp<SkImage> fBitmap, fCheckerboard; 111 sk_sp<SkImage> fBitmap, fCheckerboard;
113 112
114 typedef GM INHERITED; 113 typedef GM INHERITED;
115 }; 114 };
116 115
117 ////////////////////////////////////////////////////////////////////////////// 116 //////////////////////////////////////////////////////////////////////////////
118 117
119 DEF_GM(return new TileImageFilterGM;) 118 DEF_GM(return new TileImageFilterGM;)
120 } 119 }
OLDNEW
« no previous file with comments | « gm/resizeimagefilter.cpp ('k') | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698