Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: src/gpu/GrBitmapTextContext.h

Issue 663423003: Allocate only the vertices we need for text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrBitmapTextContext_DEFINED 8 #ifndef GrBitmapTextContext_DEFINED
9 #define GrBitmapTextContext_DEFINED 9 #define GrBitmapTextContext_DEFINED
10 10
11 #include "GrTextContext.h" 11 #include "GrTextContext.h"
12 12
13 class GrGeometryProcessor; 13 class GrGeometryProcessor;
14 class GrTextStrike; 14 class GrTextStrike;
15 15
16 /* 16 /*
17 * This class implements GrTextContext using standard bitmap fonts 17 * This class implements GrTextContext using standard bitmap fonts
18 */ 18 */
19 class GrBitmapTextContext : public GrTextContext { 19 class GrBitmapTextContext : public GrTextContext {
20 public: 20 public:
21 static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&); 21 static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&);
22 22
23 virtual ~GrBitmapTextContext(); 23 virtual ~GrBitmapTextContext();
24 24
25 private: 25 private:
26 enum {
27 kMinRequestedGlyphs = 1,
28 kDefaultRequestedGlyphs = 64,
29 kMinRequestedVerts = kMinRequestedGlyphs * 4,
30 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
31 };
32
33 GrTextStrike* fStrike; 26 GrTextStrike* fStrike;
34 void* fVertices; 27 void* fVertices;
35 int fCurrVertex; 28 int fCurrVertex;
36 int fMaxVertices; 29 int fAllocVertexCount;
30 int fTotalVertexCount;
37 SkRect fVertexBounds; 31 SkRect fVertexBounds;
38 GrTexture* fCurrTexture; 32 GrTexture* fCurrTexture;
39 GrMaskFormat fCurrMaskFormat; 33 GrMaskFormat fCurrMaskFormat;
40 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; 34 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
41 // Used to check whether fCachedEffect is still valid. 35 // Used to check whether fCachedEffect is still valid.
42 uint32_t fEffectTextureUniqueID; 36 uint32_t fEffectTextureUniqueID;
43 37
44 GrBitmapTextContext(GrContext*, const SkDeviceProperties&); 38 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
45 39
46 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; 40 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
47 41
48 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], s ize_t byteLength, 42 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], s ize_t byteLength,
49 SkScalar x, SkScalar y) SK_OVERRIDE; 43 SkScalar x, SkScalar y) SK_OVERRIDE;
50 virtual void onDrawPosText(const GrPaint&, const SkPaint&, 44 virtual void onDrawPosText(const GrPaint&, const SkPaint&,
51 const char text[], size_t byteLength, 45 const char text[], size_t byteLength,
52 const SkScalar pos[], int scalarsPerPosition, 46 const SkScalar pos[], int scalarsPerPosition,
53 const SkPoint& offset) SK_OVERRIDE; 47 const SkPoint& offset) SK_OVERRIDE;
54 48
55 void init(const GrPaint&, const SkPaint&); 49 void init(const GrPaint&, const SkPaint&);
56 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler* ); 50 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler* );
57 void flush(); // automatically called by destructor 51 void flush(); // automatically called by destructor
58 void finish(); 52 void finish();
59 53
60 }; 54 };
61 55
62 #endif 56 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698