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

Side by Side Diff: gm/imageresizetiled.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 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/imagemagnifier.cpp ('k') | gm/matrixconvolution.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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkResizeImageFilter.h" 9 #include "SkResizeImageFilter.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 19 matching lines...) Expand all
30 return make_isize(WIDTH, HEIGHT); 30 return make_isize(WIDTH, HEIGHT);
31 } 31 }
32 32
33 virtual uint32_t onGetFlags() const SK_OVERRIDE { 33 virtual uint32_t onGetFlags() const SK_OVERRIDE {
34 return kSkipTiled_Flag; 34 return kSkipTiled_Flag;
35 } 35 }
36 36
37 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 37 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
38 SkPaint paint; 38 SkPaint paint;
39 SkAutoTUnref<SkImageFilter> imageFilter( 39 SkAutoTUnref<SkImageFilter> imageFilter(
40 new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone _FilterLevel)); 40 SkResizeImageFilter::Create(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::k None_FilterLevel));
41 paint.setImageFilter(imageFilter.get()); 41 paint.setImageFilter(imageFilter.get());
42 const SkScalar tile_size = SkIntToScalar(100); 42 const SkScalar tile_size = SkIntToScalar(100);
43 SkRect bounds; 43 SkRect bounds;
44 canvas->getClipBounds(&bounds); 44 canvas->getClipBounds(&bounds);
45 for (SkScalar y = 0; y < HEIGHT; y += tile_size) { 45 for (SkScalar y = 0; y < HEIGHT; y += tile_size) {
46 for (SkScalar x = 0; x < WIDTH; x += tile_size) { 46 for (SkScalar x = 0; x < WIDTH; x += tile_size) {
47 canvas->save(); 47 canvas->save();
48 canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size)); 48 canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
49 canvas->scale(SkScalarInvert(RESIZE_FACTOR), 49 canvas->scale(SkScalarInvert(RESIZE_FACTOR),
50 SkScalarInvert(RESIZE_FACTOR)); 50 SkScalarInvert(RESIZE_FACTOR));
(...skipping 21 matching lines...) Expand all
72 72
73 private: 73 private:
74 typedef GM INHERITED; 74 typedef GM INHERITED;
75 }; 75 };
76 76
77 ////////////////////////////////////////////////////////////////////////////// 77 //////////////////////////////////////////////////////////////////////////////
78 78
79 DEF_GM(return new ImageResizeTiledGM(); ) 79 DEF_GM(return new ImageResizeTiledGM(); )
80 80
81 } 81 }
OLDNEW
« no previous file with comments | « gm/imagemagnifier.cpp ('k') | gm/matrixconvolution.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698