Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / GrClipMaskCache.h
index b332c7b..0329c84 100644 (file)
@@ -40,7 +40,8 @@ public:
 
         // We could reuse the mask if bounds is a subset of last bounds. We'd have to communicate
         // an offset to the caller.
-        if (back->fLastMask.texture() &&
+        if (back->fLastMask &&
+            !back->fLastMask->wasDestroyed() &&
             back->fLastBound == bounds &&
             back->fLastClipGenID == clipGenID) {
             return true;
@@ -97,7 +98,7 @@ public:
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        return back->fLastMask.texture();
+        return back->fLastMask;
     }
 
     const GrTexture* getLastMask() const {
@@ -109,11 +110,11 @@ public:
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        return back->fLastMask.texture();
+        return back->fLastMask;
     }
 
     void acquireMask(int32_t clipGenID,
-                     const GrTextureDesc& desc,
+                     const GrSurfaceDesc& desc,
                      const SkIRect& bound) {
 
         if (fStack.empty()) {
@@ -135,11 +136,11 @@ public:
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        if (NULL == back->fLastMask.texture()) {
+        if (NULL == back->fLastMask) {
             return -1;
         }
 
-        return back->fLastMask.texture()->width();
+        return back->fLastMask->width();
     }
 
     int getLastMaskHeight() const {
@@ -151,11 +152,11 @@ public:
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        if (NULL == back->fLastMask.texture()) {
+        if (NULL == back->fLastMask) {
             return -1;
         }
 
-        return back->fLastMask.texture()->height();
+        return back->fLastMask->height();
     }
 
     void getLastBound(SkIRect* bound) const {
@@ -179,8 +180,8 @@ public:
         return fContext;
     }
 
-    void releaseResources() {
-
+    //  TODO: Remove this when we hold cache keys instead of refs to textures.
+    void purgeResources() {
         SkDeque::F2BIter iter(fStack);
         for (GrClipStackFrame* frame = (GrClipStackFrame*) iter.next();
                 frame != NULL;
@@ -198,12 +199,15 @@ private:
 
         void acquireMask(GrContext* context,
                          int32_t clipGenID,
-                         const GrTextureDesc& desc,
+                         const GrSurfaceDesc& desc,
                          const SkIRect& bound) {
 
             fLastClipGenID = clipGenID;
 
-            fLastMask.set(context, desc);
+            // HACK: set the last param to true to indicate that this request is at
+            // flush time and therefore we require a scratch texture with no pending IO operations.
+            fLastMask.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch,
+                                                       /*flushing=*/true));
 
             fLastBound = bound;
         }
@@ -211,16 +215,17 @@ private:
         void reset () {
             fLastClipGenID = SkClipStack::kInvalidGenID;
 
-            GrTextureDesc desc;
+            GrSurfaceDesc desc;
 
-            fLastMask.set(NULL, desc);
+            fLastMask.reset(NULL);
             fLastBound.setEmpty();
         }
 
         int32_t                 fLastClipGenID;
         // The mask's width & height values are used by GrClipMaskManager to correctly scale the
-        // texture coords for the geometry drawn with this mask.
-        GrAutoScratchTexture    fLastMask;
+        // texture coords for the geometry drawn with this mask. TODO: This should be a cache key
+        // and not a hard ref to a texture.
+        SkAutoTUnref<GrTexture> fLastMask;
         // fLastBound stores the bounding box of the clip mask in clip-stack space. This rect is
         // used by GrClipMaskManager to position a rect and compute texture coords for the mask.
         SkIRect                 fLastBound;