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

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

Issue 936943002: Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: feedback inc 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/GrTextContext.h ('k') | src/gpu/SkGpuDevice.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 "GrTextContext.h" 8 #include "GrTextContext.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawTarget.h"
11 #include "GrFontScaler.h"
10 12
11 #include "SkAutoKern.h" 13 #include "SkAutoKern.h"
12 #include "SkGlyphCache.h" 14 #include "SkGlyphCache.h"
13 #include "GrFontScaler.h"
14 15
15 GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& prope rties) : 16 GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& prope rties) :
16 fFallbackTextContext(NULL), 17 fFallbackTextContext(NULL),
17 fContext(context), fDeviceProperties(properties), fD rawTarget(NULL) { 18 fContext(context), fDeviceProperties(properties), fD rawTarget(NULL) {
18 } 19 }
19 20
20 GrTextContext::~GrTextContext() { 21 GrTextContext::~GrTextContext() {
21 SkDELETE(fFallbackTextContext); 22 SkDELETE(fFallbackTextContext);
22 } 23 }
23 24
24 void GrTextContext::init(GrRenderTarget* rt, const GrPaint& grPaint, const SkPai nt& skPaint) { 25 void GrTextContext::init(GrRenderTarget* rt, const GrClip& clip, const GrPaint& grPaint,
25 fClip = fContext->getClip(); 26 const SkPaint& skPaint) {
27 fClip = clip;
26 28
27 fRenderTarget.reset(SkRef(rt)); 29 fRenderTarget.reset(SkRef(rt));
28 30
29 fClip->getConservativeBounds(fRenderTarget->width(), fRenderTarget->height() , &fClipRect); 31 fClip.getConservativeBounds(fRenderTarget->width(), fRenderTarget->height(), &fClipRect);
jvanverth1 2015/02/24 21:52:08 Just wondering if we could remove fClipRect as a m
30 32
31 fDrawTarget = fContext->getTextTarget(); 33 fDrawTarget = fContext->getTextTarget();
32 34
33 fPaint = grPaint; 35 fPaint = grPaint;
34 fSkPaint = skPaint; 36 fSkPaint = skPaint;
35 } 37 }
36 38
37 bool GrTextContext::drawText(GrRenderTarget* rt, const GrPaint& paint, const SkP aint& skPaint, 39 bool GrTextContext::drawText(GrRenderTarget* rt, const GrClip& clip, const GrPai nt& paint,
38 const SkMatrix& viewMatrix, 40 const SkPaint& skPaint, const SkMatrix& viewMatrix,
39 const char text[], size_t byteLength, 41 const char text[], size_t byteLength,
40 SkScalar x, SkScalar y) { 42 SkScalar x, SkScalar y) {
41 43
42 GrTextContext* textContext = this; 44 GrTextContext* textContext = this;
43 do { 45 do {
44 if (textContext->canDraw(skPaint, viewMatrix)) { 46 if (textContext->canDraw(skPaint, viewMatrix)) {
45 textContext->onDrawText(rt, paint, skPaint, viewMatrix, text, byteLe ngth, x, y); 47 textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix, text, byteLength, x, y);
46 return true; 48 return true;
47 } 49 }
48 textContext = textContext->fFallbackTextContext; 50 textContext = textContext->fFallbackTextContext;
49 } while (textContext); 51 } while (textContext);
50 52
51 return false; 53 return false;
52 } 54 }
53 55
54 bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrPaint& paint, const SkPaint& skPaint, 56 bool GrTextContext::drawPosText(GrRenderTarget* rt, const GrClip& clip, const Gr Paint& paint,
55 const SkMatrix& viewMatrix, 57 const SkPaint& skPaint, const SkMatrix& viewMatr ix,
56 const char text[], size_t byteLength, 58 const char text[], size_t byteLength,
57 const SkScalar pos[], int scalarsPerPosition, 59 const SkScalar pos[], int scalarsPerPosition,
58 const SkPoint& offset) { 60 const SkPoint& offset) {
59 61
60 GrTextContext* textContext = this; 62 GrTextContext* textContext = this;
61 do { 63 do {
62 if (textContext->canDraw(skPaint, viewMatrix)) { 64 if (textContext->canDraw(skPaint, viewMatrix)) {
63 textContext->onDrawPosText(rt, paint, skPaint, viewMatrix, text, byt eLength, pos, 65 textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix, tex t, byteLength, pos,
64 scalarsPerPosition, offset); 66 scalarsPerPosition, offset);
65 return true; 67 return true;
66 } 68 }
67 textContext = textContext->fFallbackTextContext; 69 textContext = textContext->fFallbackTextContext;
68 } while (textContext); 70 } while (textContext);
69 71
70 return false; 72 return false;
71 } 73 }
72 74
73 75
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { 110 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
109 scaler = (GrFontScaler*)auxData; 111 scaler = (GrFontScaler*)auxData;
110 } 112 }
111 if (NULL == scaler) { 113 if (NULL == scaler) {
112 scaler = SkNEW_ARGS(GrFontScaler, (cache)); 114 scaler = SkNEW_ARGS(GrFontScaler, (cache));
113 cache->setAuxProc(GlyphCacheAuxProc, scaler); 115 cache->setAuxProc(GlyphCacheAuxProc, scaler);
114 } 116 }
115 117
116 return scaler; 118 return scaler;
117 } 119 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.h ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698