aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrTextContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gpu/GrTextContext.h')
-rw-r--r--include/gpu/GrTextContext.h128
1 files changed, 39 insertions, 89 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
+