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

Side by Side Diff: gm/complexclip_blur_tiled.cpp

Issue 1817383002: switch surface to sk_sp (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/color4f.cpp ('k') | gm/dftext.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 2016 Google Inc. 2 * Copyright 2016 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 "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkRRect.h" 10 #include "SkRRect.h"
(...skipping 22 matching lines...) Expand all
33 SkPaint blurPaint; 33 SkPaint blurPaint;
34 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(5.0f, 5.0f)); 34 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(5.0f, 5.0f));
35 blurPaint.setImageFilter(blur); 35 blurPaint.setImageFilter(blur);
36 const SkScalar tile_size = SkIntToScalar(128); 36 const SkScalar tile_size = SkIntToScalar(128);
37 SkRect bounds; 37 SkRect bounds;
38 if (!canvas->getClipBounds(&bounds)) { 38 if (!canvas->getClipBounds(&bounds)) {
39 bounds.setEmpty(); 39 bounds.setEmpty();
40 } 40 }
41 int ts = SkScalarCeilToInt(tile_size); 41 int ts = SkScalarCeilToInt(tile_size);
42 SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts); 42 SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts);
43 SkAutoTUnref<SkSurface> tileSurface(canvas->newSurface(info)); 43 auto tileSurface(canvas->makeSurface(info));
44 if (!tileSurface.get()) { 44 if (!tileSurface) {
45 tileSurface.reset(SkSurface::NewRaster(info)); 45 tileSurface = SkSurface::MakeRaster(info);
46 } 46 }
47 SkCanvas* tileCanvas = tileSurface->getCanvas(); 47 SkCanvas* tileCanvas = tileSurface->getCanvas();
48 for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) { 48 for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
49 for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) { 49 for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
50 tileCanvas->save(); 50 tileCanvas->save();
51 tileCanvas->clear(0); 51 tileCanvas->clear(0);
52 tileCanvas->translate(-x, -y); 52 tileCanvas->translate(-x, -y);
53 SkRect rect = SkRect::MakeWH(WIDTH, HEIGHT); 53 SkRect rect = SkRect::MakeWH(WIDTH, HEIGHT);
54 tileCanvas->saveLayer(&rect, &blurPaint); 54 tileCanvas->saveLayer(&rect, &blurPaint);
55 SkRRect rrect = SkRRect::MakeRectXY(rect.makeInset(20, 20), 25, 25); 55 SkRRect rrect = SkRRect::MakeRectXY(rect.makeInset(20, 20), 25, 25);
(...skipping 10 matching lines...) Expand all
66 private: 66 private:
67 typedef GM INHERITED; 67 typedef GM INHERITED;
68 }; 68 };
69 69
70 ////////////////////////////////////////////////////////////////////////////// 70 //////////////////////////////////////////////////////////////////////////////
71 71
72 static GM* MyFactory1(void*) { return new ComplexClipBlurTiledGM(); } 72 static GM* MyFactory1(void*) { return new ComplexClipBlurTiledGM(); }
73 static GMRegistry reg1(MyFactory1); 73 static GMRegistry reg1(MyFactory1);
74 74
75 } 75 }
OLDNEW
« no previous file with comments | « gm/color4f.cpp ('k') | gm/dftext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698