| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); |
| 99 if (nullptr == surface) { | 99 if (nullptr == surface) { |
| 100 surface.reset(SkSurface::NewRaster(info)); | 100 surface.reset(SkSurface::NewRaster(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 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | |
| 106 SkPaint paint = create_filter_paint(); | 105 SkPaint paint = create_filter_paint(); |
| 107 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100)); | 106 canvas->clipRect(SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100)); |
| 108 canvas->drawImage(image, 0, 0, &paint); | 107 canvas->drawImage(surface->makeImageSnapshot().get(), 0, 0, &paint); |
| 109 } | 108 } |
| 110 | 109 |
| 111 private: | 110 private: |
| 112 typedef GM INHERITED; | 111 typedef GM INHERITED; |
| 113 }; | 112 }; |
| 114 | 113 |
| 115 ////////////////////////////////////////////////////////////////////////////// | 114 ////////////////////////////////////////////////////////////////////////////// |
| 116 | 115 |
| 117 DEF_GM(return new ImageAlphaThresholdGM();) | 116 DEF_GM(return new ImageAlphaThresholdGM();) |
| 118 DEF_GM(return new ImageAlphaThresholdSurfaceGM();) | 117 DEF_GM(return new ImageAlphaThresholdSurfaceGM();) |
| 119 | 118 |
| 120 } | 119 } |
| OLD | NEW |