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

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

Issue 641613003: Rearrange code in TextContexts to be more consistent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Some more indention clean up 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 | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.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 2014 Google Inc. 2 * Copyright 2014 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 GrStencilAndCoverTextContext_DEFINED 8 #ifndef GrStencilAndCoverTextContext_DEFINED
9 #define GrStencilAndCoverTextContext_DEFINED 9 #define GrStencilAndCoverTextContext_DEFINED
10 10
11 #include "GrTextContext.h" 11 #include "GrTextContext.h"
12 #include "GrDrawState.h" 12 #include "GrDrawState.h"
13 #include "GrDrawTarget.h" 13 #include "GrDrawTarget.h"
14 #include "SkStrokeRec.h" 14 #include "SkStrokeRec.h"
15 15
16 class GrTextStrike; 16 class GrTextStrike;
17 class GrPath; 17 class GrPath;
18 class GrPathRange; 18 class GrPathRange;
19 19
20 /* 20 /*
21 * This class implements text rendering using stencil and cover path rendering 21 * This class implements text rendering using stencil and cover path rendering
22 * (by the means of GrDrawTarget::drawPath). 22 * (by the means of GrDrawTarget::drawPath).
23 * This class exposes the functionality through GrTextContext interface. 23 * This class exposes the functionality through GrTextContext interface.
24 */ 24 */
25 class GrStencilAndCoverTextContext : public GrTextContext { 25 class GrStencilAndCoverTextContext : public GrTextContext {
26 public: 26 public:
27 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&); 27 GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&);
28 virtual ~GrStencilAndCoverTextContext(); 28 virtual ~GrStencilAndCoverTextContext();
29 29
30 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
31
30 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], 32 virtual void drawText(const GrPaint&, const SkPaint&, const char text[],
31 size_t byteLength, 33 size_t byteLength,
32 SkScalar x, SkScalar y) SK_OVERRIDE; 34 SkScalar x, SkScalar y) SK_OVERRIDE;
33 virtual void drawPosText(const GrPaint&, const SkPaint&, 35 virtual void drawPosText(const GrPaint&, const SkPaint&,
34 const char text[], size_t byteLength, 36 const char text[], size_t byteLength,
35 const SkScalar pos[], int scalarsPerPosition, 37 const SkScalar pos[], int scalarsPerPosition,
36 const SkPoint& offset) SK_OVERRIDE; 38 const SkPoint& offset) SK_OVERRIDE;
37 39
38 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
39
40 private: 40 private:
41 static const int kGlyphBufferSize = 1024; 41 static const int kGlyphBufferSize = 1024;
42 42
43 enum RenderMode { 43 enum RenderMode {
44 /** 44 /**
45 * This is the render mode used by drawText(), which is mainly used by 45 * This is the render mode used by drawText(), which is mainly used by
46 * the Skia unit tests. It tries match the other text backends exactly, 46 * the Skia unit tests. It tries match the other text backends exactly,
47 * with the exception of not implementing LCD text, and doing anti- 47 * with the exception of not implementing LCD text, and doing anti-
48 * aliasing with the built-in MSAA. 48 * aliasing with the built-in MSAA.
49 */ 49 */
50 kMaxAccuracy_RenderMode, 50 kMaxAccuracy_RenderMode,
51 51
52 /** 52 /**
53 * This is the render mode used by drawPosText(). It ignores hinting and 53 * This is the render mode used by drawPosText(). It ignores hinting and
54 * LCD text, even if the client provided positions for hinted glyphs, 54 * LCD text, even if the client provided positions for hinted glyphs,
55 * and renders from a canonically-sized, generic set of paths for the 55 * and renders from a canonically-sized, generic set of paths for the
56 * given typeface. In the future we should work out a system for the 56 * given typeface. In the future we should work out a system for the
57 * client to know it should not provide hinted glyph positions. This 57 * client to know it should not provide hinted glyph positions. This
58 * render mode also tries to use GPU stroking for fake bold, even when 58 * render mode also tries to use GPU stroking for fake bold, even when
59 * SK_USE_FREETYPE_EMBOLDEN is set. 59 * SK_USE_FREETYPE_EMBOLDEN is set.
60 */ 60 */
61 kMaxPerformance_RenderMode, 61 kMaxPerformance_RenderMode,
62 }; 62 };
63 63
64 GrDrawState::AutoRestoreEffects fStateRestore;
65 SkScalar fTextRatio;
66 float fTextInverseRatio;
67 SkGlyphCache* fGlyphCache;
68 GrPathRange* fGlyphs;
69 uint32_t fIndexBuffer[kGlyphBufferSize];
70 float fTransformBuffer[2 * kGlyphBufferSize];
71 GrDrawTarget::PathTransformType fTransformType;
72 int fPendingGlyphCount;
73 SkMatrix fContextInitialMatrix;
74 bool fNeedsDeviceSpaceGlyphs;
75
64 void init(const GrPaint&, const SkPaint&, size_t textByteLength, 76 void init(const GrPaint&, const SkPaint&, size_t textByteLength,
65 RenderMode, const SkPoint& textTranslate); 77 RenderMode, const SkPoint& textTranslate);
66 void initGlyphs(SkGlyphCache* cache); 78 void initGlyphs(SkGlyphCache* cache);
67 void appendGlyph(uint16_t glyphID, float x); 79 void appendGlyph(uint16_t glyphID, float x);
68 void appendGlyph(uint16_t glyphID, float x, float y); 80 void appendGlyph(uint16_t glyphID, float x, float y);
69 void flush(); 81 void flush();
70 void finish(); 82 void finish();
71 83
72 GrDrawState::AutoRestoreEffects fStateRestore;
73 SkScalar fTextRatio;
74 float fTextInverseRatio;
75 SkGlyphCache* fGlyphCache;
76 GrPathRange* fGlyphs;
77 uint32_t fIndexBuffer[kGlyphBufferSize];
78 float fTransformBuffer[2 * kGlyphBufferSize];
79 GrDrawTarget::PathTransformType fTransformType;
80 int fPendingGlyphCount;
81 SkMatrix fContextInitialMatrix;
82 bool fNeedsDeviceSpaceGlyphs;
83 }; 84 };
84 85
85 #endif 86 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698