Clean up likely reference leak in Ganesh custom stages.
authortomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 4 Jun 2012 19:58:30 +0000 (19:58 +0000)
committertomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 4 Jun 2012 19:58:30 +0000 (19:58 +0000)
http://codereview.appspot.com/6286047/

git-svn-id: http://skia.googlecode.com/svn/trunk@4146 2bbb7eff-a529-9590-31e7-b0007b416f81

include/gpu/GrSamplerState.h
src/gpu/SkGpuDevice.cpp
src/gpu/gl/GrGpuGL_program.cpp

index fb59111..f52775d 100644 (file)
@@ -165,8 +165,9 @@ public:
         this->reset(kDefault_WrapMode, kDefault_Filter, GrMatrix::I());
     }
 
-    void setCustomStage(GrCustomStage* stage) {
+    GrCustomStage* setCustomStage(GrCustomStage* stage) {
         GrSafeAssign(fCustomStage, stage);
+        return stage;
     }
     GrCustomStage* getCustomStage() const { return fCustomStage; }
 
index de9d973..056c5d8 100644 (file)
@@ -540,15 +540,16 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
     GrSamplerState* sampler = grPaint->textureSampler(kShaderTextureIdx);
     switch (bmptype) {
     case SkShader::kRadial_BitmapType: {
-        sampler->setCustomStage(new GrRadialGradient());
+        sampler->setCustomStage(new GrRadialGradient())->unref();
         } break;
     case SkShader::kSweep_BitmapType: {
-        sampler->setCustomStage(new GrSweepGradient());
+        sampler->setCustomStage(new GrSweepGradient())->unref();
         } break;
     case SkShader::kTwoPointRadial_BitmapType: {
-        sampler->setCustomStage(new GrRadial2Gradient(twoPointParams[0],
-                                                      twoPointParams[1],
-                                                      twoPointParams[2] < 0));
+        sampler->setCustomStage(new
+            GrRadial2Gradient(twoPointParams[0],
+                              twoPointParams[1],
+                              twoPointParams[2] < 0))->unref();
         } break;
     default:
         break;
index c230d40..30c5422 100644 (file)
@@ -7,8 +7,6 @@
 
 #include "GrGpuGL.h"
 
-#include "effects/GrGradientEffects.h"
-
 #include "GrCustomStage.h"
 #include "GrGLProgramStage.h"
 #include "GrGpuVertex.h"