Move GrTextContext to private interface
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 30 Jan 2014 16:41:23 +0000 (16:41 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 30 Jan 2014 16:41:23 +0000 (16:41 +0000)
NOTRY=true
R=bsalomon@google.com, reed@google.com

Author: jvanverth@google.com

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

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

gyp/gpu.gyp
gyp/gpu.gypi
include/gpu/GrBitmapTextContext.h [deleted file]
include/gpu/GrDistanceFieldTextContext.h [deleted file]
include/gpu/GrTextContext.h [deleted file]
include/gpu/SkGpuDevice.h
src/gpu/GrBitmapTextContext.h [new file with mode: 0755]
src/gpu/GrDistanceFieldTextContext.h [new file with mode: 0755]
src/gpu/GrTextContext.h [new file with mode: 0644]

index 8034a7b3b48512235a04e5db9f9bbd21fa0d551b..77cbf2e256a5f8299581fb3ea2e6dacce78541cd 100644 (file)
         }],
         [ 'skia_distancefield_fonts', {
           'sources': [
-            '<(skia_include_path)/gpu/GrDistanceFieldTextContext.h',
+            '<(skia_src_path)/gpu/GrDistanceFieldTextContext.h',
             '<(skia_src_path)/gpu/GrDistanceFieldTextContext.cpp',
             '<(skia_src_path)/gpu/effects/GrDistanceFieldTextureEffect.cpp',
             '<(skia_src_path)/gpu/effects/GrDistanceFieldTextureEffect.h',
index cbf721c4d339c0aecfcd94962bae4d994eb666a0..e0f4b0e10808e3d34939d06e6aa18198518f6b97 100644 (file)
@@ -9,7 +9,6 @@
   'variables': {
     'skgpu_sources': [
       '<(skia_include_path)/gpu/GrBackendEffectFactory.h',
-      '<(skia_include_path)/gpu/GrBitmapTextContext.h',
       '<(skia_include_path)/gpu/GrClipData.h',
       '<(skia_include_path)/gpu/GrColor.h',
       '<(skia_include_path)/gpu/GrConfig.h',
@@ -30,7 +29,6 @@
       '<(skia_include_path)/gpu/GrResource.h',
       '<(skia_include_path)/gpu/GrSurface.h',
       '<(skia_include_path)/gpu/GrTBackendEffectFactory.h',
-      '<(skia_include_path)/gpu/GrTextContext.h',
       '<(skia_include_path)/gpu/GrTexture.h',
       '<(skia_include_path)/gpu/GrTextureAccess.h',
       '<(skia_include_path)/gpu/GrTypes.h',
@@ -55,6 +53,7 @@
       '<(skia_src_path)/gpu/GrAtlas.h',
       '<(skia_src_path)/gpu/GrBinHashKey.h',
       '<(skia_src_path)/gpu/GrBitmapTextContext.cpp',
+      '<(skia_src_path)/gpu/GrBitmapTextContext.h',
       '<(skia_src_path)/gpu/GrBlend.cpp',
       '<(skia_src_path)/gpu/GrBlend.h',
       '<(skia_src_path)/gpu/GrBufferAllocPool.cpp',
       '<(skia_src_path)/gpu/GrSurface.cpp',
       '<(skia_src_path)/gpu/GrTemplates.h',
       '<(skia_src_path)/gpu/GrTextContext.cpp',
+      '<(skia_src_path)/gpu/GrTextContext.h',
       '<(skia_src_path)/gpu/GrTextStrike.cpp',
       '<(skia_src_path)/gpu/GrTextStrike.h',
       '<(skia_src_path)/gpu/GrTextStrike_impl.h',
diff --git a/include/gpu/GrBitmapTextContext.h b/include/gpu/GrBitmapTextContext.h
deleted file mode 100755 (executable)
index 6550e3c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrBitmapTextContext_DEFINED
-#define GrBitmapTextContext_DEFINED
-
-#include "GrTextContext.h"
-
-class GrTextStrike;
-
-/*
- * This class implements GrTextContext using standard bitmap fonts
- */
-class GrBitmapTextContext : public GrTextContext {
-public:
-    GrBitmapTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProperties&);
-    virtual ~GrBitmapTextContext();
-
-    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
-    virtual void drawPosText(const char text[], size_t byteLength,
-                             const SkScalar pos[], SkScalar constY,
-                             int scalarsPerPosition) SK_OVERRIDE;
-
-    static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
-    
-private:
-    GrTextStrike*          fStrike;
-
-    void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
-    void flushGlyphs();                 // automatically called by destructor
-
-    enum {
-        kMinRequestedGlyphs      = 1,
-        kDefaultRequestedGlyphs  = 64,
-        kMinRequestedVerts       = kMinRequestedGlyphs * 4,
-        kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
-    };
-
-    SkPoint*                fVertices;
-    int32_t                 fMaxVertices;
-    GrTexture*              fCurrTexture;
-    int                     fCurrVertex;
-};
-
-#endif
diff --git a/include/gpu/GrDistanceFieldTextContext.h b/include/gpu/GrDistanceFieldTextContext.h
deleted file mode 100755 (executable)
index 8b94038..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrDistanceFieldTextContext_DEFINED
-#define GrDistanceFieldTextContext_DEFINED
-
-#include "GrTextContext.h"
-
-class GrTextStrike;
-
-/*
- * This class implements GrTextContext using distance field fonts
- */
-class GrDistanceFieldTextContext : public GrTextContext {
-public:
-    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
-    virtual void drawPosText(const char text[], size_t byteLength,
-                             const SkScalar pos[], SkScalar constY,
-                             int scalarsPerPosition) SK_OVERRIDE;
-    
-    static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
-
-private:
-    GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&,
-                               const SkDeviceProperties&);
-    virtual ~GrDistanceFieldTextContext();
-    friend class GrTTextContextManager<GrDistanceFieldTextContext>;
-
-    GrTextStrike*           fStrike;
-    SkScalar                fTextRatio;
-
-    void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
-    void flushGlyphs();                 // automatically called by destructor
-
-    enum {
-        kMinRequestedGlyphs      = 1,
-        kDefaultRequestedGlyphs  = 64,
-        kMinRequestedVerts       = kMinRequestedGlyphs * 4,
-        kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
-    };
-
-    SkPoint*                fVertices;
-    int32_t                 fMaxVertices;
-    GrTexture*              fCurrTexture;
-    int                     fCurrVertex;
-};
-
-#endif
diff --git a/include/gpu/GrTextContext.h b/include/gpu/GrTextContext.h
deleted file mode 100644 (file)
index c572d0d..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrTextContext_DEFINED
-#define GrTextContext_DEFINED
-
-#include "GrPoint.h"
-#include "GrGlyph.h"
-#include "GrPaint.h"
-#include "SkDeviceProperties.h"
-
-#include "SkPostConfig.h"
-
-class GrContext;
-class GrDrawTarget;
-class GrFontScaler;
-
-/*
- * This class wraps the state for a single text render
- */
-class GrTextContext {
-public:
-    virtual ~GrTextContext() {}
-    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) = 0;
-    virtual void drawPosText(const char text[], size_t byteLength,
-                             const SkScalar pos[], SkScalar constY,
-                             int scalarsPerPosition) = 0;
-    
-protected:
-    GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProperties&);
-
-    static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
-    static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
-                            const char text[], size_t byteLength, SkVector* stopVector);
-
-    GrContext*         fContext;
-    GrPaint            fPaint;
-    SkPaint            fSkPaint;
-    SkDeviceProperties fDeviceProperties;
-    GrDrawTarget*      fDrawTarget;
-
-    SkIRect            fClipRect;
-};
-
-/*
- * These classes wrap the creation of a single text context for a given GPU device. The
- * assumption is that we'll only be using one text context at a time for that device.
- */
-class GrTextContextManager {
-public:
-    virtual ~GrTextContextManager() {}
-    virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint,
-                                  const SkPaint& skPaint, const SkDeviceProperties& props) = 0;
-    virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) = 0;
-};
-
-template <class TextContextClass>
-class GrTTextContextManager : public GrTextContextManager {
-private:
-    class ManagedTextContext : public TextContextClass {
-    public:
-        virtual ~ManagedTextContext() {}
-
-        ManagedTextContext(GrContext* grContext,
-                           const GrPaint& grPaint,
-                           const SkPaint& skPaint,
-                           const SkDeviceProperties& properties,
-                           GrTTextContextManager<TextContextClass>* manager) :
-                          TextContextClass(grContext, grPaint, skPaint, properties) {
-            fManager = manager;
-        }
-
-        static void operator delete(void* ptr) {
-            if (ptr == NULL) {
-                return;
-            }
-            ManagedTextContext* context = reinterpret_cast<ManagedTextContext*>(ptr);
-            context->fManager->recycle(context);
-        }
-
-        static void operator delete(void*, void*) {
-        }
-
-        GrTTextContextManager<TextContextClass>* fManager;
-    };
-
-public:
-    GrTTextContextManager() {
-        fAllocation = sk_malloc_throw(sizeof(ManagedTextContext));
-        fUsed = false;
-    }
-
-    virtual ~GrTTextContextManager() {
-        SkASSERT(!fUsed);
-        sk_free(fAllocation);
-    }
-
-    virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint,
-                                  const SkPaint& skPaint, const SkDeviceProperties& properties)
-                                 SK_OVERRIDE {
-        // add check for usePath here?
-        SkASSERT(!fUsed);
-        ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextContext,
-                                                       (grContext, grPaint, skPaint, properties,
-                                                        this));
-        fUsed = true;
-        return obj;
-    }
-
-    virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) SK_OVERRIDE {
-        return TextContextClass::CanDraw(paint, ctm);
-    }
-
-private:
-    void recycle(GrTextContext* textContext) {
-        SkASSERT((void*)textContext == fAllocation);
-        SkASSERT(fUsed);
-        fUsed = false;
-    }
-
-    void* fAllocation;
-    bool  fUsed;
-};
-
-#endif
index addf6786545263a925529174d41de68ef021c657..bfcdba3fddc63da1d278dc72a7b3583d22f3f955 100644 (file)
 #include "SkBitmapDevice.h"
 #include "SkRegion.h"
 #include "GrContext.h"
-#include "GrTextContext.h"
 
 struct SkDrawProcs;
 struct GrSkDrawProcs;
 
+class GrTextContextManager;
+
 /**
  *  Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by the
  *  canvas.
@@ -208,11 +209,6 @@ private:
                          int tileSize,
                          bool bicubic);
 
-    /**
-     * Returns non-initialized instance.
-     */
-    GrTextContext* getTextContext();
-
     typedef SkBitmapDevice INHERITED;
 };
 
diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h
new file mode 100755 (executable)
index 0000000..6550e3c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrBitmapTextContext_DEFINED
+#define GrBitmapTextContext_DEFINED
+
+#include "GrTextContext.h"
+
+class GrTextStrike;
+
+/*
+ * This class implements GrTextContext using standard bitmap fonts
+ */
+class GrBitmapTextContext : public GrTextContext {
+public:
+    GrBitmapTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProperties&);
+    virtual ~GrBitmapTextContext();
+
+    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
+    virtual void drawPosText(const char text[], size_t byteLength,
+                             const SkScalar pos[], SkScalar constY,
+                             int scalarsPerPosition) SK_OVERRIDE;
+
+    static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
+    
+private:
+    GrTextStrike*          fStrike;
+
+    void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
+    void flushGlyphs();                 // automatically called by destructor
+
+    enum {
+        kMinRequestedGlyphs      = 1,
+        kDefaultRequestedGlyphs  = 64,
+        kMinRequestedVerts       = kMinRequestedGlyphs * 4,
+        kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
+    };
+
+    SkPoint*                fVertices;
+    int32_t                 fMaxVertices;
+    GrTexture*              fCurrTexture;
+    int                     fCurrVertex;
+};
+
+#endif
diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h
new file mode 100755 (executable)
index 0000000..8b94038
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrDistanceFieldTextContext_DEFINED
+#define GrDistanceFieldTextContext_DEFINED
+
+#include "GrTextContext.h"
+
+class GrTextStrike;
+
+/*
+ * This class implements GrTextContext using distance field fonts
+ */
+class GrDistanceFieldTextContext : public GrTextContext {
+public:
+    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
+    virtual void drawPosText(const char text[], size_t byteLength,
+                             const SkScalar pos[], SkScalar constY,
+                             int scalarsPerPosition) SK_OVERRIDE;
+    
+    static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
+
+private:
+    GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&,
+                               const SkDeviceProperties&);
+    virtual ~GrDistanceFieldTextContext();
+    friend class GrTTextContextManager<GrDistanceFieldTextContext>;
+
+    GrTextStrike*           fStrike;
+    SkScalar                fTextRatio;
+
+    void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
+    void flushGlyphs();                 // automatically called by destructor
+
+    enum {
+        kMinRequestedGlyphs      = 1,
+        kDefaultRequestedGlyphs  = 64,
+        kMinRequestedVerts       = kMinRequestedGlyphs * 4,
+        kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
+    };
+
+    SkPoint*                fVertices;
+    int32_t                 fMaxVertices;
+    GrTexture*              fCurrTexture;
+    int                     fCurrVertex;
+};
+
+#endif
diff --git a/src/gpu/GrTextContext.h b/src/gpu/GrTextContext.h
new file mode 100644 (file)
index 0000000..c572d0d
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrTextContext_DEFINED
+#define GrTextContext_DEFINED
+
+#include "GrPoint.h"
+#include "GrGlyph.h"
+#include "GrPaint.h"
+#include "SkDeviceProperties.h"
+
+#include "SkPostConfig.h"
+
+class GrContext;
+class GrDrawTarget;
+class GrFontScaler;
+
+/*
+ * This class wraps the state for a single text render
+ */
+class GrTextContext {
+public:
+    virtual ~GrTextContext() {}
+    virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) = 0;
+    virtual void drawPosText(const char text[], size_t byteLength,
+                             const SkScalar pos[], SkScalar constY,
+                             int scalarsPerPosition) = 0;
+    
+protected:
+    GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProperties&);
+
+    static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
+    static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
+                            const char text[], size_t byteLength, SkVector* stopVector);
+
+    GrContext*         fContext;
+    GrPaint            fPaint;
+    SkPaint            fSkPaint;
+    SkDeviceProperties fDeviceProperties;
+    GrDrawTarget*      fDrawTarget;
+
+    SkIRect            fClipRect;
+};
+
+/*
+ * These classes wrap the creation of a single text context for a given GPU device. The
+ * assumption is that we'll only be using one text context at a time for that device.
+ */
+class GrTextContextManager {
+public:
+    virtual ~GrTextContextManager() {}
+    virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint,
+                                  const SkPaint& skPaint, const SkDeviceProperties& props) = 0;
+    virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) = 0;
+};
+
+template <class TextContextClass>
+class GrTTextContextManager : public GrTextContextManager {
+private:
+    class ManagedTextContext : public TextContextClass {
+    public:
+        virtual ~ManagedTextContext() {}
+
+        ManagedTextContext(GrContext* grContext,
+                           const GrPaint& grPaint,
+                           const SkPaint& skPaint,
+                           const SkDeviceProperties& properties,
+                           GrTTextContextManager<TextContextClass>* manager) :
+                          TextContextClass(grContext, grPaint, skPaint, properties) {
+            fManager = manager;
+        }
+
+        static void operator delete(void* ptr) {
+            if (ptr == NULL) {
+                return;
+            }
+            ManagedTextContext* context = reinterpret_cast<ManagedTextContext*>(ptr);
+            context->fManager->recycle(context);
+        }
+
+        static void operator delete(void*, void*) {
+        }
+
+        GrTTextContextManager<TextContextClass>* fManager;
+    };
+
+public:
+    GrTTextContextManager() {
+        fAllocation = sk_malloc_throw(sizeof(ManagedTextContext));
+        fUsed = false;
+    }
+
+    virtual ~GrTTextContextManager() {
+        SkASSERT(!fUsed);
+        sk_free(fAllocation);
+    }
+
+    virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint,
+                                  const SkPaint& skPaint, const SkDeviceProperties& properties)
+                                 SK_OVERRIDE {
+        // add check for usePath here?
+        SkASSERT(!fUsed);
+        ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextContext,
+                                                       (grContext, grPaint, skPaint, properties,
+                                                        this));
+        fUsed = true;
+        return obj;
+    }
+
+    virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) SK_OVERRIDE {
+        return TextContextClass::CanDraw(paint, ctm);
+    }
+
+private:
+    void recycle(GrTextContext* textContext) {
+        SkASSERT((void*)textContext == fAllocation);
+        SkASSERT(fUsed);
+        fUsed = false;
+    }
+
+    void* fAllocation;
+    bool  fUsed;
+};
+
+#endif