aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-22 22:01:41 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-22 22:01:41 +0000
commitf1d63aa80dc951417ad34dd00914c8150112e42a (patch)
tree1efaf1c45fb04f46604c9a816e2bb9f6d15a3658 /include/gpu
parentce96b651d383305561ff0459a527acda8e93cc49 (diff)
Revert of Add factory class for generating various flavors of GrTextContext. (https://codereview.chromium.org/144283002/)
Reason for revert: Breaks Chrome. Need to fix template issue. Original issue's description: > Add factory class for generating various flavors of GrTextContext. > > This is the first pass of making Gr*TextContext more generic and easily > subclassed. The next stage will be making GrBitmapTextContext and > GrDistanceFieldTextContext more similar by moving the SkDraw loop into > each subclass. > > BUG=skia:2018 > > Committed: http://code.google.com/p/skia/source/detail?r=13142 R=bsalomon@google.com, reed@google.com TBR=bsalomon@google.com, reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia:2018 Author: jvanverth@google.com Review URL: https://codereview.chromium.org/145023006 git-svn-id: http://skia.googlecode.com/svn/trunk@13143 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rwxr-xr-xinclude/gpu/GrBitmapTextContext.h8
-rwxr-xr-xinclude/gpu/GrDistanceFieldTextContext.h8
-rw-r--r--include/gpu/GrTextContext.h74
-rw-r--r--include/gpu/SkGpuDevice.h4
4 files changed, 11 insertions, 83 deletions
diff --git a/include/gpu/GrBitmapTextContext.h b/include/gpu/GrBitmapTextContext.h
index e1b3d725a9..e0900ecd7d 100755
--- a/include/gpu/GrBitmapTextContext.h
+++ b/include/gpu/GrBitmapTextContext.h
@@ -17,14 +17,13 @@ class GrTextStrike;
*/
class GrBitmapTextContext : public GrTextContext {
public:
+ GrBitmapTextContext(GrContext*, const GrPaint&, SkColor);
+ virtual ~GrBitmapTextContext();
+
virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
GrFontScaler*) SK_OVERRIDE;
private:
- GrBitmapTextContext(GrContext*, const GrPaint&, const SkPaint&);
- virtual ~GrBitmapTextContext();
- friend class GrTTextContextManager<GrBitmapTextContext>;
-
GrContext::AutoMatrix fAutoMatrix;
GrTextStrike* fStrike;
@@ -37,6 +36,7 @@ private:
kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
};
+ SkColor fSkPaintColor;
SkPoint* fVertices;
int32_t fMaxVertices;
GrTexture* fCurrTexture;
diff --git a/include/gpu/GrDistanceFieldTextContext.h b/include/gpu/GrDistanceFieldTextContext.h
index 4fde6ceef8..3e00ff2477 100755
--- a/include/gpu/GrDistanceFieldTextContext.h
+++ b/include/gpu/GrDistanceFieldTextContext.h
@@ -17,6 +17,9 @@ class GrTextStrike;
*/
class GrDistanceFieldTextContext : public GrTextContext {
public:
+ GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&);
+ virtual ~GrDistanceFieldTextContext();
+
virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
GrFontScaler*) SK_OVERRIDE;
@@ -30,10 +33,6 @@ public:
const SkPaint& getSkPaint() { return fSkPaint; }
private:
- GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&);
- virtual ~GrDistanceFieldTextContext();
- friend class GrTTextContextManager<GrDistanceFieldTextContext>;
-
GrTextStrike* fStrike;
SkScalar fTextRatio;
@@ -46,6 +45,7 @@ private:
kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
};
+ SkPaint fSkPaint;
SkPoint* fVertices;
int32_t fMaxVertices;
GrTexture* fCurrTexture;
diff --git a/include/gpu/GrTextContext.h b/include/gpu/GrTextContext.h
index 3c61cbc80e..b367cf228d 100644
--- a/include/gpu/GrTextContext.h
+++ b/include/gpu/GrTextContext.h
@@ -12,8 +12,6 @@
#include "GrGlyph.h"
#include "GrPaint.h"
-#include "SkPostConfig.h"
-
class GrContext;
class GrDrawTarget;
class GrFontScaler;
@@ -23,88 +21,20 @@ class GrFontScaler;
*/
class GrTextContext {
public:
- virtual ~GrTextContext() {}
virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
GrFontScaler*) = 0;
protected:
- GrTextContext(GrContext*, const GrPaint&, const SkPaint&);
+ GrTextContext(GrContext*, const GrPaint&);
+ virtual ~GrTextContext() {}
GrPaint fPaint;
- SkPaint fSkPaint;
GrContext* fContext;
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* context, const GrPaint& grPaint,
- const SkPaint& skPaint) = 0;
-};
-template <class TextContextClass>
-class GrTTextContextManager : public GrTextContextManager {
private:
- class ManagedTextContext : public TextContextClass {
- public:
- ~ManagedTextContext() {}
-
- ManagedTextContext(GrContext* context,
- const GrPaint& grPaint,
- const SkPaint& skPaint,
- GrTTextContextManager<TextContextClass>* manager) :
- TextContextClass(context, grPaint, skPaint) {
- fManager = manager;
- }
-
- static void operator delete(void* ptr) {
- if (ptr == NULL) {
- return;
- }
- ManagedTextContext* context = reinterpret_cast<ManagedTextContext*>(ptr);
- context->fManager->recycle(context);
- }
-
- GrTTextContextManager<TextContextClass>* fManager;
- };
-
-public:
- GrTTextContextManager() {
- fAllocation = sk_malloc_throw(sizeof(ManagedTextContext));
- fUsed = false;
- }
-
- ~GrTTextContextManager() {
- SkASSERT(!fUsed);
- sk_free(fAllocation);
- }
-
- GrTextContext* create(GrContext* context, const GrPaint& grPaint,
- const SkPaint& skPaint) {
- // add check for usePath here?
- SkASSERT(!fUsed);
- ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextContext,
- (context, grPaint, skPaint, this));
- fUsed = true;
- return obj;
- }
-
-private:
- void recycle(GrTextContext* textContext) {
- SkASSERT((void*)textContext == fAllocation);
- SkASSERT(fUsed);
- fUsed = false;
- }
-
- void* fAllocation;
- bool fUsed;
};
#endif
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 2888951e47..9b7129fbf6 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -16,10 +16,10 @@
#include "SkBitmapDevice.h"
#include "SkRegion.h"
#include "GrContext.h"
-#include "GrTextContext.h"
struct SkDrawProcs;
struct GrSkDrawProcs;
+class GrTextContext;
/**
* Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by the
@@ -149,8 +149,6 @@ private:
GrClipData fClipData;
- GrTextContextManager* fTextContextManager;
-
// state for our render-target
GrRenderTarget* fRenderTarget;
bool fNeedClear;