OLD | NEW |
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 "gm.h" | 8 #include "gm.h" |
9 #include "SkAlphaThresholdFilter.h" | 9 #include "SkAlphaThresholdFilter.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 SkString onShortName() override { | 88 SkString onShortName() override { |
89 return SkString("imagealphathreshold_surface"); | 89 return SkString("imagealphathreshold_surface"); |
90 } | 90 } |
91 | 91 |
92 SkISize onISize() override { | 92 SkISize onISize() override { |
93 return SkISize::Make(WIDTH, HEIGHT); | 93 return SkISize::Make(WIDTH, HEIGHT); |
94 } | 94 } |
95 | 95 |
96 void onDraw(SkCanvas* canvas) override { | 96 void onDraw(SkCanvas* canvas) override { |
97 SkImageInfo info = SkImageInfo::MakeN32(WIDTH, HEIGHT, kOpaque_SkAlphaTy
pe); | 97 SkImageInfo info = SkImageInfo::MakeN32(WIDTH, HEIGHT, kOpaque_SkAlphaTy
pe); |
98 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); | 98 auto surface(canvas->makeSurface(info)); |
99 if (nullptr == surface) { | 99 if (nullptr == surface) { |
100 surface.reset(SkSurface::NewRaster(info)); | 100 surface = SkSurface::MakeRaster(info); |
101 } | 101 } |
102 surface->getCanvas()->clear(SK_ColorWHITE); | 102 surface->getCanvas()->clear(SK_ColorWHITE); |
103 draw_rects(surface->getCanvas()); | 103 draw_rects(surface->getCanvas()); |
104 | 104 |
105 SkPaint paint = create_filter_paint(); | 105 SkPaint paint = create_filter_paint(); |
106 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100)); | 106 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100)); |
107 canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint); | 107 canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint); |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 typedef GM INHERITED; | 111 typedef GM INHERITED; |
112 }; | 112 }; |
113 | 113 |
114 ////////////////////////////////////////////////////////////////////////////// | 114 ////////////////////////////////////////////////////////////////////////////// |
115 | 115 |
116 DEF_GM(return new ImageAlphaThresholdGM();) | 116 DEF_GM(return new ImageAlphaThresholdGM();) |
117 DEF_GM(return new ImageAlphaThresholdSurfaceGM();) | 117 DEF_GM(return new ImageAlphaThresholdSurfaceGM();) |
118 | 118 |
119 } | 119 } |
OLD | NEW |