| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs)); | 114 canvas->translate(0, (H * 5 / 4) * SK_ARRAY_COUNT(procs)); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, | 118 static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size, |
| 119 bool skipGPU) { | 119 bool skipGPU) { |
| 120 SkImage::Info info = { | 120 SkImage::Info info = { |
| 121 size.width(), | 121 size.width(), |
| 122 size.height(), | 122 size.height(), |
| 123 SkImage::kPMColor_ColorType, | 123 SkImage::kPMColor_ColorType, |
| 124 SkImage::kPremul_AlphaType | 124 kPremul_SkAlphaType |
| 125 }; | 125 }; |
| 126 #if SK_SUPPORT_GPU | 126 #if SK_SUPPORT_GPU |
| 127 SkBaseDevice* dev = canvas->getDevice(); | 127 SkBaseDevice* dev = canvas->getDevice(); |
| 128 if (!skipGPU && dev->accessRenderTarget()) { | 128 if (!skipGPU && dev->accessRenderTarget()) { |
| 129 SkGpuDevice* gd = (SkGpuDevice*)dev; | 129 SkGpuDevice* gd = (SkGpuDevice*)dev; |
| 130 GrContext* ctx = gd->context(); | 130 GrContext* ctx = gd->context(); |
| 131 return SkSurface::NewRenderTarget(ctx, info, 0); | 131 return SkSurface::NewRenderTarget(ctx, info, 0); |
| 132 } | 132 } |
| 133 #endif | 133 #endif |
| 134 return SkSurface::NewRaster(info); | 134 return SkSurface::NewRaster(info); |
| 135 } | 135 } |
| 136 | 136 |
| 137 virtual void onDraw(SkCanvas* canvas) { | 137 virtual void onDraw(SkCanvas* canvas) { |
| 138 SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(), | 138 SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(), |
| 139 this->isCanvasDeferred())); | 139 this->isCanvasDeferred())); |
| 140 surf->getCanvas()->drawColor(SK_ColorWHITE); | 140 surf->getCanvas()->drawColor(SK_ColorWHITE); |
| 141 this->drawContent(surf->getCanvas()); | 141 this->drawContent(surf->getCanvas()); |
| 142 surf->draw(canvas, 0, 0, NULL); | 142 surf->draw(canvas, 0, 0, NULL); |
| 143 } | 143 } |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 typedef skiagm::GM INHERITED; | 146 typedef skiagm::GM INHERITED; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 /////////////////////////////////////////////////////////////////////////////// | 149 /////////////////////////////////////////////////////////////////////////////// |
| 150 | 150 |
| 151 DEF_GM(return new SrcModeGM;) | 151 DEF_GM(return new SrcModeGM;) |
| OLD | NEW |