remove RenderTargetFlags -- NewRenderTargetDirect will never clear
authorreed <reed@chromium.org>
Fri, 19 Sep 2014 12:56:29 +0000 (05:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 19 Sep 2014 12:56:29 +0000 (05:56 -0700)
BUG=skia:
R=robertphillips@google.com, bsalomon@google.com

Author: reed@chromium.org

Review URL: https://codereview.chromium.org/583043002

include/core/SkSurface.h
src/gpu/GrLayerHoister.cpp
src/image/SkSurface_Gpu.cpp

index cb5133ae003e4d89de0f2f376b749977aee715f4..1871c676f21e56a9a6e0a66018836fcc7c534ade 100644 (file)
@@ -77,29 +77,20 @@ public:
         kDistanceField_TextRenderMode,
     };
 
-    enum RenderTargetFlags {
-        kNone_RenderTargetFlag      = 0x0,
-        /*
-         * By default a RenderTarget-based surface will be cleared on creation.
-         * Pass in this flag to prevent the clear from happening.
-         */
-        kDontClear_RenderTargetFlag = 0x01,
-    };
-
     /**
      *  Return a new surface using the specified render target.
+     *  The pixels in the rendertarget are not cleared or otherwised changed when the surface
+     *  is created.
      */
     static SkSurface* NewRenderTargetDirect(GrRenderTarget*,
-                                            TextRenderMode trm = kStandard_TextRenderMode,
-                                            RenderTargetFlags flags = kNone_RenderTargetFlag);
+                                            TextRenderMode trm = kStandard_TextRenderMode);
 
     /**
      *  Return a new surface whose contents will be drawn to an offscreen
      *  render target, allocated by the surface.
      */
     static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
-                                      TextRenderMode trm = kStandard_TextRenderMode,
-                                      RenderTargetFlags flags = kNone_RenderTargetFlag);
+                                      TextRenderMode trm = kStandard_TextRenderMode);
 
     /**
      *  Return a new surface whose contents will be drawn to an offscreen
@@ -114,8 +105,7 @@ public:
      *  budget.
      */
     static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0,
-                                             TextRenderMode trm = kStandard_TextRenderMode,
-                                             RenderTargetFlags flags = kNone_RenderTargetFlag);
+                                             TextRenderMode trm = kStandard_TextRenderMode);
 
     int width() const { return fWidth; }
     int height() const { return fHeight; }
index aa9576b675314b7639aee6142d4e2488c4203c33..ba431d33e98c0340210a5a9ea2749087de558762 100644 (file)
@@ -143,8 +143,7 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture,
         // All the atlased layers are rendered into the same GrTexture
         SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
                                                 atlased[0]->texture()->asRenderTarget(),
-                                                SkSurface::kStandard_TextRenderMode,
-                                                SkSurface::kDontClear_RenderTargetFlag));
+                                                SkSurface::kStandard_TextRenderMode));
 
         SkCanvas* atlasCanvas = surface->getCanvas();
 
@@ -198,8 +197,7 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture,
         // Each non-atlased layer has its own GrTexture
         SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
                                                 layer->texture()->asRenderTarget(),
-                                                SkSurface::kStandard_TextRenderMode,
-                                                SkSurface::kDontClear_RenderTargetFlag));
+                                                SkSurface::kStandard_TextRenderMode));
 
         SkCanvas* layerCanvas = surface->getCanvas();
 
index f94dc5bd7002dc88a18b65b811702f2f5a992b20..d7260ac29eb457566316e564d3ad32c44d4fed5c 100644 (file)
@@ -14,8 +14,7 @@ class SkSurface_Gpu : public SkSurface_Base {
 public:
     SK_DECLARE_INST_COUNT(SkSurface_Gpu)
 
-    SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, 
-                  SkSurface::RenderTargetFlags flags);
+    SkSurface_Gpu(GrRenderTarget*, bool cached, TextRenderMode trm, bool doClear);
     virtual ~SkSurface_Gpu();
 
     virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
@@ -35,15 +34,14 @@ private:
 ///////////////////////////////////////////////////////////////////////////////
 
 SkSurface_Gpu::SkSurface_Gpu(GrRenderTarget* renderTarget, bool cached, TextRenderMode trm,
-                             SkSurface::RenderTargetFlags flags)
+                             bool doClear)
         : INHERITED(renderTarget->width(), renderTarget->height()) {
     int deviceFlags = 0;
     deviceFlags |= cached ? SkGpuDevice::kCached_Flag : 0;
     deviceFlags |= (kDistanceField_TextRenderMode == trm) ? SkGpuDevice::kDFFonts_Flag : 0;
     fDevice = SkGpuDevice::Create(renderTarget, deviceFlags);
 
-    if (kRGB_565_GrPixelConfig != renderTarget->config() && 
-        !(flags & kDontClear_RenderTargetFlag)) {
+    if (kRGB_565_GrPixelConfig != renderTarget->config() && doClear) {
         fDevice->clear(0x0);
     }
 }
@@ -104,16 +102,15 @@ void SkSurface_Gpu::onDiscard() {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm,
-                                            RenderTargetFlags flags) {
+SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, TextRenderMode trm) {
     if (NULL == target) {
         return NULL;
     }
-    return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, flags));
+    return SkNEW_ARGS(SkSurface_Gpu, (target, false, trm, false));
 }
 
 SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount,
-                                      TextRenderMode trm, RenderTargetFlags flags) {
+                                      TextRenderMode trm) {
     if (NULL == ctx) {
         return NULL;
     }
@@ -130,12 +127,11 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, i
         return NULL;
     }
 
-    return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, flags));
+    return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), false, trm, true));
 }
 
 SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& info,
-                                             int sampleCount, TextRenderMode trm,
-                                             RenderTargetFlags flags) {
+                                             int sampleCount, TextRenderMode trm) {
     if (NULL == ctx) {
         return NULL;
     }
@@ -153,5 +149,5 @@ SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo&
         return NULL;
     }
 
-    return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, flags));
+    return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, trm, true));
 }