blob: 348f3abb45c3bf837741da9d4fa2c4f7121b8c4a [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrTextContext_DEFINED
12#define GrTextContext_DEFINED
13
bsalomon@google.com858804d2012-10-15 14:25:50 +000014#include "GrContext.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015#include "GrGlyph.h"
tomhudson@google.com375ff852012-06-29 18:37:57 +000016#include "GrPaint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000017
18class GrContext;
tomhudson@google.com375ff852012-06-29 18:37:57 +000019class GrTextStrike;
reed@google.comac10a2d2010-12-22 21:39:39 +000020class GrFontScaler;
tomhudson@google.com375ff852012-06-29 18:37:57 +000021class GrDrawTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000022
tomhudson@google.com375ff852012-06-29 18:37:57 +000023class GrTextContext {
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000024public:
bsalomon@google.com0e354aa2012-10-08 20:44:25 +000025 GrTextContext(GrContext*, const GrPaint&);
tomhudson@google.com375ff852012-06-29 18:37:57 +000026 ~GrTextContext();
reed@google.comfa35e3d2012-06-26 20:16:17 +000027
tomhudson@google.com375ff852012-06-29 18:37:57 +000028 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
29 GrFontScaler*);
reed@google.comac10a2d2010-12-22 21:39:39 +000030
tomhudson@google.com375ff852012-06-29 18:37:57 +000031 void flush(); // optional; automatically called by destructor
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000032
33private:
tomhudson@google.com375ff852012-06-29 18:37:57 +000034 GrPaint fPaint;
tomhudson@google.com375ff852012-06-29 18:37:57 +000035 GrContext* fContext;
36 GrDrawTarget* fDrawTarget;
37
tomhudson@google.com375ff852012-06-29 18:37:57 +000038 GrFontScaler* fScaler;
39 GrTextStrike* fStrike;
40
41 inline void flushGlyphs();
42 void setupDrawTarget();
43
44 enum {
45 kMinRequestedGlyphs = 1,
46 kDefaultRequestedGlyphs = 64,
47 kMinRequestedVerts = kMinRequestedGlyphs * 4,
48 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
49 };
50
bsalomon@google.com85983282013-02-07 22:00:29 +000051 SkPoint* fVertices;
bsalomon@google.com858804d2012-10-15 14:25:50 +000052 int32_t fMaxVertices;
53 GrTexture* fCurrTexture;
54 int fCurrVertex;
tomhudson@google.com375ff852012-06-29 18:37:57 +000055
bsalomon@google.com858804d2012-10-15 14:25:50 +000056 GrIRect fClipRect;
57 GrContext::AutoMatrix fAutoMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +000058};
59
60#endif