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

Side by Side Diff: src/core/SkDevice.cpp

Issue 973973003: Text blob run paints should be filtered. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix iterator filter skipping 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/core/SkCanvas.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkDevice.h" 8 #include "SkDevice.h"
9 #include "SkDeviceProperties.h" 9 #include "SkDeviceProperties.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
11 #include "SkDrawFilter.h"
11 #include "SkMetaData.h" 12 #include "SkMetaData.h"
12 #include "SkPatchUtils.h" 13 #include "SkPatchUtils.h"
13 #include "SkPathMeasure.h" 14 #include "SkPathMeasure.h"
14 #include "SkRasterClip.h" 15 #include "SkRasterClip.h"
15 #include "SkShader.h" 16 #include "SkShader.h"
16 #include "SkTextBlob.h" 17 #include "SkTextBlob.h"
17 #include "SkTextToPathIter.h" 18 #include "SkTextToPathIter.h"
18 19
19 SkBaseDevice::SkBaseDevice() 20 SkBaseDevice::SkBaseDevice()
20 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega cyLCD_InitType))) 21 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega cyLCD_InitType)))
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // It automatically adjusts lodX and lodY in case it exceeds the number of i ndices. 115 // It automatically adjusts lodX and lodY in case it exceeds the number of i ndices.
115 // If it fails to generate the vertices, then we do not draw. 116 // If it fails to generate the vertices, then we do not draw.
116 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) { 117 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) {
117 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints, 118 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints,
118 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount, 119 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
119 paint); 120 paint);
120 } 121 }
121 } 122 }
122 123
123 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y, 124 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y,
124 const SkPaint &paint) { 125 const SkPaint &paint, SkDrawFilter* drawFilter) {
125 126
126 SkPaint runPaint = paint; 127 SkPaint runPaint = paint;
127 128
128 SkTextBlob::RunIterator it(blob); 129 SkTextBlob::RunIterator it(blob);
129 while (!it.done()) { 130 for (;!it.done(); it.next()) {
130 size_t textLen = it.glyphCount() * sizeof(uint16_t); 131 size_t textLen = it.glyphCount() * sizeof(uint16_t);
131 const SkPoint& offset = it.offset(); 132 const SkPoint& offset = it.offset();
132 // applyFontToPaint() always overwrites the exact same attributes, 133 // applyFontToPaint() always overwrites the exact same attributes,
133 // so it is safe to not re-seed the paint. 134 // so it is safe to not re-seed the paint for this reason.
134 it.applyFontToPaint(&runPaint); 135 it.applyFontToPaint(&runPaint);
136
137 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Typ e)) {
138 // A false return from filter() means we should abort the current dr aw.
139 runPaint = paint;
140 continue;
141 }
142
135 runPaint.setFlags(this->filterTextFlags(runPaint)); 143 runPaint.setFlags(this->filterTextFlags(runPaint));
136 144
137 switch (it.positioning()) { 145 switch (it.positioning()) {
138 case SkTextBlob::kDefault_Positioning: 146 case SkTextBlob::kDefault_Positioning:
139 this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offse t.y(), runPaint); 147 this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offse t.y(), runPaint);
140 break; 148 break;
141 case SkTextBlob::kHorizontal_Positioning: 149 case SkTextBlob::kHorizontal_Positioning:
142 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1, 150 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1,
143 SkPoint::Make(x, y + offset.y()), runPaint); 151 SkPoint::Make(x, y + offset.y()), runPaint);
144 break; 152 break;
145 case SkTextBlob::kFull_Positioning: 153 case SkTextBlob::kFull_Positioning:
146 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2, 154 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2,
147 SkPoint::Make(x, y), runPaint); 155 SkPoint::Make(x, y), runPaint);
148 break; 156 break;
149 default: 157 default:
150 SkFAIL("unhandled positioning mode"); 158 SkFAIL("unhandled positioning mode");
151 } 159 }
152 160
153 it.next(); 161 if (drawFilter) {
162 // A draw filter may change the paint arbitrarily, so we must re-see d in this case.
163 runPaint = paint;
164 }
154 } 165 }
155 } 166 }
156 167
157 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { 168 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) {
158 #ifdef SK_DEBUG 169 #ifdef SK_DEBUG
159 SkASSERT(info.width() > 0 && info.height() > 0); 170 SkASSERT(info.width() > 0 && info.height() > 0);
160 SkASSERT(dstP); 171 SkASSERT(dstP);
161 SkASSERT(rowBytes >= info.minRowBytes()); 172 SkASSERT(rowBytes >= info.minRowBytes());
162 SkASSERT(x >= 0 && y >= 0); 173 SkASSERT(x >= 0 && y >= 0);
163 174
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() 359 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry()
349 || this->onShouldDisableLCD(paint)) { 360 || this->onShouldDisableLCD(paint)) {
350 361
351 flags &= ~SkPaint::kLCDRenderText_Flag; 362 flags &= ~SkPaint::kLCDRenderText_Flag;
352 flags |= SkPaint::kGenA8FromLCD_Flag; 363 flags |= SkPaint::kGenA8FromLCD_Flag;
353 } 364 }
354 365
355 return flags; 366 return flags;
356 } 367 }
357 368
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698