OLD | NEW |
---|---|
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) { |
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 while (!it.done()) { |
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 // For drawTextBlob calls, we defer applying draw filters | |
138 // until we have a complete run paint. | |
139 if (!!draw.fDrawFilter) { | |
reed1
2015/03/03 21:26:22
style: its fine to say
if (draw.fDrawFilter), no
| |
140 draw.fDrawFilter->filter(&runPaint, SkDrawFilter::kText_Type); | |
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 |
161 if (!!draw.fDrawFilter) { | |
162 // A draw filter may change the paint arbitrarily, so we must re-see d in this case. | |
163 runPaint = paint; | |
164 } | |
165 | |
153 it.next(); | 166 it.next(); |
154 } | 167 } |
155 } | 168 } |
156 | 169 |
157 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { | 170 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { |
158 #ifdef SK_DEBUG | 171 #ifdef SK_DEBUG |
159 SkASSERT(info.width() > 0 && info.height() > 0); | 172 SkASSERT(info.width() > 0 && info.height() > 0); |
160 SkASSERT(dstP); | 173 SkASSERT(dstP); |
161 SkASSERT(rowBytes >= info.minRowBytes()); | 174 SkASSERT(rowBytes >= info.minRowBytes()); |
162 SkASSERT(x >= 0 && y >= 0); | 175 SkASSERT(x >= 0 && y >= 0); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() | 361 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() |
349 || this->onShouldDisableLCD(paint)) { | 362 || this->onShouldDisableLCD(paint)) { |
350 | 363 |
351 flags &= ~SkPaint::kLCDRenderText_Flag; | 364 flags &= ~SkPaint::kLCDRenderText_Flag; |
352 flags |= SkPaint::kGenA8FromLCD_Flag; | 365 flags |= SkPaint::kGenA8FromLCD_Flag; |
353 } | 366 } |
354 | 367 |
355 return flags; | 368 return flags; |
356 } | 369 } |
357 | 370 |
OLD | NEW |