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

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

Issue 1011403004: BitmapTextBatch and BitmapTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@dfpr_take_2
Patch Set: tweak Created 5 years, 9 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
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 #include "GrGeometryProcessor.h" 13 #include "GrGeometryProcessor.h"
14 #include "SkTHash.h"
15
16 class GrBatchTextStrike;
17 class GrPipelineBuilder;
18
19 /*
20 * This class implements GrTextContext using standard bitmap fonts, and can also process textblobs.
21 * TODO replace GrBitmapTextContext
22 */
23 class GrBitmapTextContextB : public GrTextContext {
24 public:
25 static GrBitmapTextContextB* Create(GrContext*, SkGpuDevice*, const SkDevice Properties&);
26
27 virtual ~GrBitmapTextContextB();
28
29 private:
30 GrBitmapTextContextB(GrContext*, SkGpuDevice*, const SkDeviceProperties&);
31
32 bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
33
robertphillips 2015/03/23 19:03:12 aren't we ditching virtual on SK_OVERRIDE calls ?
34 virtual void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, cons t SkPaint&,
35 const SkMatrix& viewMatrix, const char text[], size_ t byteLength,
36 SkScalar x, SkScalar y, const SkIRect& regionClipBou nds) SK_OVERRIDE;
37 virtual void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, c onst SkPaint&,
38 const SkMatrix& viewMatrix,
39 const char text[], size_t byteLength,
40 const SkScalar pos[], int scalarsPerPosition,
41 const SkPoint& offset, const SkIRect& regionClipB ounds) SK_OVERRIDE;
42 virtual void onDrawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&,
43 const SkMatrix& viewMatrix, const SkTextBlob*,
44 SkScalar x, SkScalar y, SkDrawFilter*,
45 const SkIRect& clipBounds) SK_OVERRIDE;
46
47 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
48 const SkIRect& regionClipBounds);
49
50 struct BitmapTextBlob : public SkRefCnt {
51 struct Run : public SkRefCnt {
robertphillips 2015/03/23 19:03:12 init fColor here too ?
52 Run() { fVertexBounds.setLargestInverted(); }
53 struct TextInfo {
54 TextInfo() : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGenerat ion) {}
55 SkTDArray<unsigned char> fVertices;
56 SkTDArray<GrGlyph::PackedID> fGlyphIDs;
57 uint32_t fAtlasGeneration;
58 };
59 SkAutoTUnref<const SkData> fDescriptor;
60 SkAutoTUnref<SkTypeface> fTypeface;
61 TextInfo fInfos[kMaskFormatCount];
62 SkRect fVertexBounds;
63 GrColor fColor;
64 };
65 SkTArray<Run, true> fRuns;
66 struct BigGlyph {
67 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {}
68 SkPath fPath;
69 int fVx;
70 int fVy;
71 };
72 SkTArray<BigGlyph> fBigGlyphs;
73 SkTextBlob* fBlob;
74 SkMatrix fViewMatrix;
75 SkScalar fX;
76 SkScalar fY;
77 SkPaint::Style fStyle;
78
79 static uint32_t Hash(const uint32_t& key) {
80 return SkChecksum::Mix(key);
81 }
82 };
83
84 void appendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, int left, int top,
85 GrFontScaler*);
86 void flush(BitmapTextBlob*, int i, GrPipelineBuilder*, GrMaskFormat);
87 void flush(BitmapTextBlob*); // automatically called by dest ructor
88 void finish(BitmapTextBlob*);
89
90 void internalDrawText(BitmapTextBlob*, int runIndex, GrRenderTarget*, const GrClip&,
91 const GrPaint&, const SkPaint&,
92 const SkMatrix& viewMatrix, const char text[], size_t byteLength,
93 SkScalar x, SkScalar y, const SkIRect& regionClipBound s);
94 void internalDrawPosText(BitmapTextBlob*, int runIndex, GrRenderTarget*, con st GrClip&,
95 const GrPaint&, const SkPaint&, const SkMatrix& vie wMatrix,
96 const char text[], size_t byteLength,
97 const SkScalar pos[], int scalarsPerPosition,
98 const SkPoint& offset, const SkIRect& regionClipBou nds);
99
100 static inline bool MustRegenerateBlob(const BitmapTextBlob&, const SkPaint&,
101 const SkMatrix& viewMatrix, SkScalar x , SkScalar y);
102 void regenerateTextBlob(BitmapTextBlob* bmp, GrRenderTarget* rt, const GrCli p& clip,
103 const SkPaint& skPaint, const SkMatrix& viewMatrix,
104 const SkTextBlob* blob, SkScalar x, SkScalar y,
105 SkDrawFilter* drawFilter, const SkIRect& clipBounds) ;
106
107 GrBatchTextStrike* fStrike;
108
109 // TODO use real cache
110 static void ClearCacheEntry(uint32_t key, BitmapTextBlob**);
111 SkTHashMap<uint32_t, BitmapTextBlob*, BitmapTextBlob::Hash> fCache;
112
113 friend class BitmapTextBatch;
robertphillips 2015/03/23 19:03:12 INHERITED ?
114 };
14 115
15 class GrTextStrike; 116 class GrTextStrike;
16 117
17 /* 118 /*
18 * This class implements GrTextContext using standard bitmap fonts 119 * This class implements GrTextContext using standard bitmap fonts
19 */ 120 */
20 class GrBitmapTextContext : public GrTextContext { 121 class GrBitmapTextContext : public GrTextContext {
21 public: 122 public:
22 static GrBitmapTextContext* Create(GrContext*, SkGpuDevice*, const SkDevice Properties&); 123 static GrBitmapTextContext* Create(GrContext*, SkGpuDevice*, const SkDevice Properties&);
23 124
(...skipping 28 matching lines...) Expand all
52 153
53 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, 154 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
54 const SkIRect& regionClipBounds); 155 const SkIRect& regionClipBounds);
55 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler* ); 156 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler* );
56 bool uploadGlyph(GrGlyph*, GrFontScaler*); 157 bool uploadGlyph(GrGlyph*, GrFontScaler*);
57 void flush(); // automatically called by destructor 158 void flush(); // automatically called by destructor
58 void finish(); 159 void finish();
59 }; 160 };
60 161
61 #endif 162 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698