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

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

Issue 1010113004: Add GrRenderTarget parameter to GrTextContext::canDraw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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/GrDistanceFieldTextContext.h ('k') | src/gpu/GrStencilAndCoverTextContext.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 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 "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 (context, gpuDevice, pr ops, enable)); 76 (context, gpuDevice, pr ops, enable));
77 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, gpu Device, props); 77 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, gpu Device, props);
78 78
79 return textContext; 79 return textContext;
80 } 80 }
81 81
82 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { 82 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
83 SkSafeSetNull(fGammaTexture); 83 SkSafeSetNull(fGammaTexture);
84 } 84 }
85 85
86 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& v iewMatrix) { 86 bool GrDistanceFieldTextContext::canDraw(const GrRenderTarget* rt,
87 const GrClip& clip,
88 const GrPaint& paint,
89 const SkPaint& skPaint,
90 const SkMatrix& viewMatrix) {
87 // TODO: support perspective (need getMaxScale replacement) 91 // TODO: support perspective (need getMaxScale replacement)
88 if (viewMatrix.hasPerspective()) { 92 if (viewMatrix.hasPerspective()) {
89 return false; 93 return false;
90 } 94 }
91 95
92 SkScalar maxScale = viewMatrix.getMaxScale(); 96 SkScalar maxScale = viewMatrix.getMaxScale();
93 SkScalar scaledTextSize = maxScale*paint.getTextSize(); 97 SkScalar scaledTextSize = maxScale*skPaint.getTextSize();
94 // Hinted text looks far better at small resolutions 98 // Hinted text looks far better at small resolutions
95 // Scaling up beyond 2x yields undesireable artifacts 99 // Scaling up beyond 2x yields undesireable artifacts
96 if (scaledTextSize < kMinDFFontSize || scaledTextSize > 2*kLargeDFFontSize) { 100 if (scaledTextSize < kMinDFFontSize || scaledTextSize > 2*kLargeDFFontSize) {
97 return false; 101 return false;
98 } 102 }
99 103
100 if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP() && 104 if (!fEnableDFRendering && !skPaint.isDistanceFieldTextTEMP() &&
101 scaledTextSize < kLargeDFFontSize) { 105 scaledTextSize < kLargeDFFontSize) {
102 return false; 106 return false;
103 } 107 }
104 108
105 // rasterizers and mask filters modify alpha, which doesn't 109 // rasterizers and mask filters modify alpha, which doesn't
106 // translate well to distance 110 // translate well to distance
107 if (paint.getRasterizer() || paint.getMaskFilter() || 111 if (skPaint.getRasterizer() || skPaint.getMaskFilter() ||
108 !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) { 112 !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
109 return false; 113 return false;
110 } 114 }
111 115
112 // TODO: add some stroking support 116 // TODO: add some stroking support
113 if (paint.getStyle() != SkPaint::kFill_Style) { 117 if (skPaint.getStyle() != SkPaint::kFill_Style) {
114 return false; 118 return false;
115 } 119 }
116 120
117 return true; 121 return true;
118 } 122 }
119 123
120 inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrClip& c lip, 124 inline void GrDistanceFieldTextContext::init(GrRenderTarget* rt, const GrClip& c lip,
121 const GrPaint& paint, const SkPaint & skPaint, 125 const GrPaint& paint, const SkPaint & skPaint,
122 const SkIRect& regionClipBounds) { 126 const SkIRect& regionClipBounds) {
123 GrTextContext::init(rt, clip, paint, skPaint, regionClipBounds); 127 GrTextContext::init(rt, clip, paint, skPaint, regionClipBounds);
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 732 }
729 } 733 }
730 734
731 inline void GrDistanceFieldTextContext::finish() { 735 inline void GrDistanceFieldTextContext::finish() {
732 this->flush(); 736 this->flush();
733 fTotalVertexCount = 0; 737 fTotalVertexCount = 0;
734 738
735 GrTextContext::finish(); 739 GrTextContext::finish();
736 } 740 }
737 741
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/GrStencilAndCoverTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698