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

Side by Side Diff: gm/tileimagefilter.cpp

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/textbloblooper.cpp ('k') | gm/vertices.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, 86 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
87 0, SK_Scalar1, 0, 0, 0, 87 0, SK_Scalar1, 0, 0, 0,
88 0, 0, SK_Scalar1, 0, 0, 88 0, 0, SK_Scalar1, 0, 0,
89 0, 0, 0, SK_Scalar1, 0 }; 89 0, 0, 0, SK_Scalar1, 0 };
90 90
91 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width()), 91 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width()),
92 SkIntToScalar(fBitmap->height())); 92 SkIntToScalar(fBitmap->height()));
93 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width() * 2), 93 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(fBitmap->width() * 2),
94 SkIntToScalar(fBitmap->height() * 2)); 94 SkIntToScalar(fBitmap->height() * 2));
95 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(srcRect, dstR ect, nullptr)); 95 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(srcRect, dstR ect, nullptr));
96 SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(matrix)); 96 auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
97 97
98 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf, ti le.get())); 98 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get (), tile.get()));
99 SkPaint paint; 99 SkPaint paint;
100 paint.setImageFilter(cfif); 100 paint.setImageFilter(cfif);
101 canvas->save(); 101 canvas->save();
102 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 102 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
103 canvas->clipRect(dstRect); 103 canvas->clipRect(dstRect);
104 canvas->saveLayer(&dstRect, &paint); 104 canvas->saveLayer(&dstRect, &paint);
105 canvas->drawImage(fBitmap.get(), 0, 0); 105 canvas->drawImage(fBitmap.get(), 0, 0);
106 canvas->restore(); 106 canvas->restore();
107 canvas->drawRect(srcRect, red); 107 canvas->drawRect(srcRect, red);
108 canvas->drawRect(dstRect, blue); 108 canvas->drawRect(dstRect, blue);
109 canvas->restore(); 109 canvas->restore();
110 } 110 }
111 private: 111 private:
112 sk_sp<SkImage> fBitmap, fCheckerboard; 112 sk_sp<SkImage> fBitmap, fCheckerboard;
113 113
114 typedef GM INHERITED; 114 typedef GM INHERITED;
115 }; 115 };
116 116
117 ////////////////////////////////////////////////////////////////////////////// 117 //////////////////////////////////////////////////////////////////////////////
118 118
119 DEF_GM(return new TileImageFilterGM;) 119 DEF_GM(return new TileImageFilterGM;)
120 } 120 }
OLDNEW
« no previous file with comments | « gm/textbloblooper.cpp ('k') | gm/vertices.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698