Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / gpu / GrSWMaskHelper.h
index 0ffaa64..f8cce8b 100644 (file)
@@ -15,6 +15,7 @@
 #include "SkMatrix.h"
 #include "SkRasterClip.h"
 #include "SkRegion.h"
+#include "SkTextureCompressor.h"
 #include "SkTypes.h"
 
 class GrAutoScratchTexture;
@@ -41,14 +42,16 @@ class GrDrawTarget;
 class GrSWMaskHelper : SkNoncopyable {
 public:
     GrSWMaskHelper(GrContext* context)
-    : fContext(context) {
+    : fContext(context)
+    , fCompressionMode(kNone_CompressionMode) {
     }
 
     // set up the internal state in preparation for draws. Since many masks
     // may be accumulated in the helper during creation, "resultBounds"
     // allows the caller to specify the region of interest - to limit the
-    // amount of work.
-    bool init(const SkIRect& resultBounds, const SkMatrix* matrix);
+    // amount of work. allowCompression should be set to false if you plan on using
+    // your own texture to draw into, and not a scratch texture via getTexture().
+    bool init(const SkIRect& resultBounds, const SkMatrix* matrix, bool allowCompression = true);
 
     // Draw a single rect into the accumulation bitmap using the specified op
     void draw(const SkRect& rect, SkRegion::Op op,
@@ -93,7 +96,6 @@ public:
                                          GrDrawTarget* target,
                                          const SkIRect& rect);
 
-protected:
 private:
     GrContext*      fContext;
     SkMatrix        fMatrix;
@@ -101,11 +103,33 @@ private:
     SkDraw          fDraw;
     SkRasterClip    fRasterClip;
 
+    // This enum says whether or not we should compress the mask:
+    // kNone_CompressionMode: compression is not supported on this device.
+    // kCompress_CompressionMode: compress the bitmap before it gets sent to the gpu
+    // kBlitter_CompressionMode: write to the bitmap using a special compressed blitter.
+    enum CompressionMode {
+        kNone_CompressionMode,
+        kCompress_CompressionMode,
+        kBlitter_CompressionMode,
+    } fCompressionMode;
+
+    // This is the buffer into which we store our compressed data. This buffer is
+    // only allocated (non-null) if fCompressionMode is kBlitter_CompressionMode
+    SkAutoMalloc fCompressedBuffer;
+
+    // This is the desired format within which to compress the
+    // texture. This value is only valid if fCompressionMode is not kNone_CompressionMode.
+    SkTextureCompressor::Format fCompressedFormat;
+
     // Actually sends the texture data to the GPU. This is called from
     // toTexture with the data filled in depending on the texture config.
     void sendTextureData(GrTexture *texture, const GrTextureDesc& desc,
                          const void *data, int rowbytes);
 
+    // Compresses the bitmap stored in fBM and sends the compressed data
+    // to the GPU to be stored in 'texture' using sendTextureData.
+    void compressTextureData(GrTexture *texture, const GrTextureDesc& desc);
+
     typedef SkNoncopyable INHERITED;
 };