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

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: 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 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(
70 SkTileImageFilter::Create(srcRect, dstRect, tileInput));
71 canvas->save(); 69 canvas->save();
72 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 70 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
73 SkPaint paint; 71 SkPaint paint;
74 paint.setImageFilter(filter); 72 paint.setImageFilter(SkTileImageFilter::Create(srcRect, dstRect, til eInput.get()));
f(malita) 2016/03/31 13:26:09 Ditto.
robertphillips 2016/03/31 14:35:54 Done.
75 canvas->drawImage(fBitmap.get(), 0, 0, &paint); 73 canvas->drawImage(fBitmap.get(), 0, 0, &paint);
76 canvas->drawRect(srcRect, red); 74 canvas->drawRect(srcRect, red);
77 canvas->drawRect(dstRect, blue); 75 canvas->drawRect(dstRect, blue);
78 canvas->restore(); 76 canvas->restore();
79 x += image->width() + MARGIN; 77 x += image->width() + MARGIN;
80 if (x + image->width() > WIDTH) { 78 if (x + image->width() > WIDTH) {
81 x = 0; 79 x = 0;
82 y += image->height() + MARGIN; 80 y += image->height() + MARGIN;
83 } 81 }
84 } 82 }
(...skipping 26 matching lines...) Expand all
111 private: 109 private:
112 sk_sp<SkImage> fBitmap, fCheckerboard; 110 sk_sp<SkImage> fBitmap, fCheckerboard;
113 111
114 typedef GM INHERITED; 112 typedef GM INHERITED;
115 }; 113 };
116 114
117 ////////////////////////////////////////////////////////////////////////////// 115 //////////////////////////////////////////////////////////////////////////////
118 116
119 DEF_GM(return new TileImageFilterGM;) 117 DEF_GM(return new TileImageFilterGM;)
120 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698