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

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

Issue 1015173002: Let text contexts fall back directly to paths (Closed) Base URL: https://skia.googlesource.com/skia.git@text-blob-to-context
Patch Set: move createTextContext to private 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
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrContext.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 #include "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 28 matching lines...) Expand all
39 // position + local coord 39 // position + local coord
40 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); 40 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
41 41
42 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof (SkIPoint16); 42 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof (SkIPoint16);
43 43
44 static const int kVerticesPerGlyph = 4; 44 static const int kVerticesPerGlyph = 4;
45 static const int kIndicesPerGlyph = 6; 45 static const int kIndicesPerGlyph = 6;
46 }; 46 };
47 47
48 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, 48 GrBitmapTextContext::GrBitmapTextContext(GrContext* context,
49 SkGpuDevice* gpuDevice,
49 const SkDeviceProperties& properties) 50 const SkDeviceProperties& properties)
50 : GrTextContext(context, properties) { 51 : GrTextContext(context, gpuDevice, properties) {
51 fStrike = NULL; 52 fStrike = NULL;
52 53
53 fCurrTexture = NULL; 54 fCurrTexture = NULL;
54 fEffectTextureUniqueID = SK_InvalidUniqueID; 55 fEffectTextureUniqueID = SK_InvalidUniqueID;
55 56
56 fVertices = NULL; 57 fVertices = NULL;
57 fCurrVertex = 0; 58 fCurrVertex = 0;
58 fAllocVertexCount = 0; 59 fAllocVertexCount = 0;
59 fTotalVertexCount = 0; 60 fTotalVertexCount = 0;
60 61
61 fVertexBounds.setLargestInverted(); 62 fVertexBounds.setLargestInverted();
62 } 63 }
63 64
64 GrBitmapTextContext* GrBitmapTextContext::Create(GrContext* context, 65 GrBitmapTextContext* GrBitmapTextContext::Create(GrContext* context,
66 SkGpuDevice* gpuDevice,
65 const SkDeviceProperties& props ) { 67 const SkDeviceProperties& props ) {
66 return SkNEW_ARGS(GrBitmapTextContext, (context, props)); 68 return SkNEW_ARGS(GrBitmapTextContext, (context, gpuDevice, props));
67 } 69 }
68 70
69 bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatr ix) { 71 bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatr ix) {
70 return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix); 72 return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix);
71 } 73 }
72 74
73 inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrClip& clip, 75 inline void GrBitmapTextContext::init(GrRenderTarget* rt, const GrClip& clip,
74 const GrPaint& paint, const SkPaint& skPai nt) { 76 const GrPaint& paint, const SkPaint& skPai nt,
75 GrTextContext::init(rt, clip, paint, skPaint); 77 const SkIRect& regionClipBounds) {
78 GrTextContext::init(rt, clip, paint, skPaint, regionClipBounds);
76 79
77 fStrike = NULL; 80 fStrike = NULL;
78 81
79 fCurrTexture = NULL; 82 fCurrTexture = NULL;
80 fCurrVertex = 0; 83 fCurrVertex = 0;
81 84
82 fVertices = NULL; 85 fVertices = NULL;
83 fAllocVertexCount = 0; 86 fAllocVertexCount = 0;
84 fTotalVertexCount = 0; 87 fTotalVertexCount = 0;
85 } 88 }
86 89
87 void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip, 90 void GrBitmapTextContext::onDrawText(GrRenderTarget* rt, const GrClip& clip,
88 const GrPaint& paint, const SkPaint& skPain t, 91 const GrPaint& paint, const SkPaint& skPain t,
89 const SkMatrix& viewMatrix, 92 const SkMatrix& viewMatrix,
90 const char text[], size_t byteLength, 93 const char text[], size_t byteLength,
91 SkScalar x, SkScalar y) { 94 SkScalar x, SkScalar y, const SkIRect& regi onClipBounds) {
92 SkASSERT(byteLength == 0 || text != NULL); 95 SkASSERT(byteLength == 0 || text != NULL);
93 96
94 // nothing to draw 97 // nothing to draw
95 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { 98 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
96 return; 99 return;
97 } 100 }
98 101
99 this->init(rt, clip, paint, skPaint); 102 this->init(rt, clip, paint, skPaint, regionClipBounds);
100 103
101 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 104 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
102 105
103 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); 106 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix);
104 SkGlyphCache* cache = autoCache.getCache(); 107 SkGlyphCache* cache = autoCache.getCache();
105 GrFontScaler* fontScaler = GetGrFontScaler(cache); 108 GrFontScaler* fontScaler = GetGrFontScaler(cache);
106 109
107 // transform our starting point 110 // transform our starting point
108 { 111 {
109 SkPoint loc; 112 SkPoint loc;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 186 }
184 187
185 this->finish(); 188 this->finish();
186 } 189 }
187 190
188 void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip, 191 void GrBitmapTextContext::onDrawPosText(GrRenderTarget* rt, const GrClip& clip,
189 const GrPaint& paint, const SkPaint& skP aint, 192 const GrPaint& paint, const SkPaint& skP aint,
190 const SkMatrix& viewMatrix, 193 const SkMatrix& viewMatrix,
191 const char text[], size_t byteLength, 194 const char text[], size_t byteLength,
192 const SkScalar pos[], int scalarsPerPosi tion, 195 const SkScalar pos[], int scalarsPerPosi tion,
193 const SkPoint& offset) { 196 const SkPoint& offset, const SkIRect& re gionClipBounds) {
194 SkASSERT(byteLength == 0 || text != NULL); 197 SkASSERT(byteLength == 0 || text != NULL);
195 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 198 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
196 199
197 // nothing to draw 200 // nothing to draw
198 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { 201 if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) {
199 return; 202 return;
200 } 203 }
201 204
202 this->init(rt, clip, paint, skPaint); 205 this->init(rt, clip, paint, skPaint, regionClipBounds);
203 206
204 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); 207 SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
205 208
206 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); 209 SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix);
207 SkGlyphCache* cache = autoCache.getCache(); 210 SkGlyphCache* cache = autoCache.getCache();
208 GrFontScaler* fontScaler = GetGrFontScaler(cache); 211 GrFontScaler* fontScaler = GetGrFontScaler(cache);
209 212
210 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix, but for 213 // if we have RGB, then we won't have any SkShaders so no need to use a loca lmatrix, but for
211 // performance reasons we just invert here instead 214 // performance reasons we just invert here instead
212 if (!viewMatrix.invert(&fLocalMatrix)) { 215 if (!viewMatrix.invert(&fLocalMatrix)) {
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 628 }
626 } 629 }
627 630
628 inline void GrBitmapTextContext::finish() { 631 inline void GrBitmapTextContext::finish() {
629 this->flush(); 632 this->flush();
630 fTotalVertexCount = 0; 633 fTotalVertexCount = 0;
631 634
632 GrTextContext::finish(); 635 GrTextContext::finish();
633 } 636 }
634 637
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698