| 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 "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
| 9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
| 10 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkGpuDevice.h" | 12 #include "SkGpuDevice.h" |
| 13 #include "SkSurface_Gpu.h" |
| 13 | 14 |
| 14 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 15 | 16 |
| 16 class SkSurface_Gpu : public SkSurface_Base { | |
| 17 public: | |
| 18 SK_DECLARE_INST_COUNT(SkSurface_Gpu) | |
| 19 | |
| 20 SkSurface_Gpu(GrRenderTarget*, const SkSurfaceProps*, bool doClear); | |
| 21 virtual ~SkSurface_Gpu(); | |
| 22 | |
| 23 virtual SkCanvas* onNewCanvas() SK_OVERRIDE; | |
| 24 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; | |
| 25 virtual SkImage* onNewImageSnapshot() SK_OVERRIDE; | |
| 26 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, | |
| 27 const SkPaint*) SK_OVERRIDE; | |
| 28 virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; | |
| 29 virtual void onDiscard() SK_OVERRIDE; | |
| 30 | |
| 31 private: | |
| 32 SkGpuDevice* fDevice; | |
| 33 | |
| 34 typedef SkSurface_Base INHERITED; | |
| 35 }; | |
| 36 | |
| 37 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
| 38 | 18 |
| 39 SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, const SkSurfaceProps*
props, | 19 SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, const SkSurfaceProps*
props, |
| 40 bool doClear) | 20 bool doClear) |
| 41 : INHERITED(renderTarget->width(), renderTarget->height(), props) { | 21 : INHERITED(renderTarget->width(), renderTarget->height(), props) { |
| 42 int deviceFlags = 0; | 22 int deviceFlags = 0; |
| 43 deviceFlags |= this->props().isUseDistanceFieldFonts() ? SkGpuDevice::kDFTex
t_Flag : 0; | 23 deviceFlags |= this->props().isUseDistanceFieldFonts() ? SkGpuDevice::kDFTex
t_Flag : 0; |
| 44 fDevice = SkGpuDevice::Create(renderTarget, this->props(), deviceFlags); | 24 fDevice = SkGpuDevice::Create(renderTarget, this->props(), deviceFlags); |
| 45 | 25 |
| 46 if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) { | 26 if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); | 136 SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_S
cratchTexMatch)); |
| 157 | 137 |
| 158 if (NULL == tex) { | 138 if (NULL == tex) { |
| 159 return NULL; | 139 return NULL; |
| 160 } | 140 } |
| 161 | 141 |
| 162 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); | 142 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), props, true)); |
| 163 } | 143 } |
| 164 | 144 |
| 165 #endif | 145 #endif |
| OLD | NEW |