aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-29 18:37:57 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-29 18:37:57 +0000
commit375ff85e96cf0f8438ea0b11be67e85474e42c29 (patch)
tree12948b2cdd8c311142a130b1d0e5c5573bfbafa4 /include/gpu
parente7290ef304176268f22741b15cbbb0b07f09a323 (diff)
Un-trifurcate GrTextContext: get rid of Default and Batched subclasses,
folding their functionality back into the base class. Requires gyp changes. http://codereview.appspot.com/6357048/ git-svn-id: http://skia.googlecode.com/svn/trunk@4411 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrTextContext.h128
-rw-r--r--include/gpu/SkGpuDevice.h2
2 files changed, 39 insertions, 91 deletions
diff --git a/include/gpu/GrTextContext.h b/include/gpu/GrTextContext.h
index f48b8233e9..29ef007439 100644
--- a/include/gpu/GrTextContext.h
+++ b/include/gpu/GrTextContext.h
@@ -12,106 +12,56 @@
#define GrTextContext_DEFINED
#include "GrGlyph.h"
+#include "GrPaint.h"
#include "GrMatrix.h"
-#include "GrRefCnt.h"
+struct GrGpuTextVertex;
class GrContext;
+class GrTextStrike;
class GrFontScaler;
-class GrPaint;
+class GrDrawTarget;
-class SkGpuDevice;
-class SkPaint;
+class GrTextContext {
+public:
+ GrTextContext(GrContext*,
+ const GrPaint& paint,
+ const GrMatrix* extMatrix = NULL);
+ ~GrTextContext();
-/**
- * Derived classes can use stages GrPaint::kTotalStages through
- * GrDrawState::kNumStages-1. The stages before GrPaint::kTotalStages
- * are reserved for setting up the draw (i.e., textures and filter masks).
- */
-class GrTextContext: public GrRefCnt {
-protected:
+ void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
+ GrFontScaler*);
+
+ void flush(); // optional; automatically called by destructor
+
+private:
+ GrPaint fPaint;
+ GrVertexLayout fVertexLayout;
GrContext* fContext;
+ GrDrawTarget* fDrawTarget;
-public:
- SK_DECLARE_INST_COUNT(GrTextContext)
-
- /**
- * To use a text context it must be wrapped in an AutoFinish. AutoFinish's
- * destructor ensures all drawing is flushed to the GrContext.
- */
- class AutoFinish {
- public:
- AutoFinish(GrTextContext* textContext, GrContext* context,
- const GrPaint&, const GrMatrix* extMatrix);
- ~AutoFinish();
- GrTextContext* getTextContext() const;
-
- private:
- GrTextContext* fTextContext;
+ GrMatrix fExtMatrix;
+ GrFontScaler* fScaler;
+ GrTextStrike* fStrike;
+
+ inline void flushGlyphs();
+ void setupDrawTarget();
+
+ enum {
+ kMinRequestedGlyphs = 1,
+ kDefaultRequestedGlyphs = 64,
+ kMinRequestedVerts = kMinRequestedGlyphs * 4,
+ kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
};
- virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
- GrFontScaler*) = 0;
-
- virtual ~GrTextContext() {}
-
-protected:
- GrTextContext() {
- fContext = NULL;
- }
-
- bool isValid() const {
- return (NULL != fContext);
- }
-
- /**
- * Initialize the object.
- *
- * Before call to this method, the instance is considered to be in
- * invalid state. I.e. call to any method other than isValid will result in
- * undefined behaviour.
- *
- * @see finish
- */
- virtual void init(GrContext* context, const GrPaint&,
- const GrMatrix* extMatrix) {
- fContext = context;
- }
-
- /**
- * Reset the object to invalid state.
- *
- * After call to this method, the instance is considered to be in
- * invalid state.
- *
- * It might be brought back to a valid state by calling init.
- *
- * @see init
- */
- virtual void finish() {
- fContext = NULL;
- }
+ GrGpuTextVertex* fVertices;
-private:
- typedef GrRefCnt INHERITED;
-};
+ int32_t fMaxVertices;
+ GrTexture* fCurrTexture;
+ int fCurrVertex;
-inline GrTextContext::AutoFinish::AutoFinish(GrTextContext* textContext,
- GrContext* context,
- const GrPaint& grPaint,
- const GrMatrix* extMatrix) {
- GrAssert(NULL != textContext);
- fTextContext = textContext;
- fTextContext->ref();
- fTextContext->init(context, grPaint, extMatrix);
-}
-
-inline GrTextContext::AutoFinish::~AutoFinish() {
- fTextContext->finish();
- fTextContext->unref();
-}
-
-inline GrTextContext* GrTextContext::AutoFinish::getTextContext() const {
- return fTextContext;
-}
+ GrIRect fClipRect;
+ GrMatrix fOrigViewMatrix; // restore previous viewmatrix
+};
#endif
+
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index ee4d791931..124e7846fa 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -138,8 +138,6 @@ private:
bool fNeedClear;
bool fNeedPrepareRenderTarget;
- GrTextContext* fTextContext;
-
// called from rt and tex cons
void initFromRenderTarget(GrContext*, GrRenderTarget*);