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

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

Issue 494763004: Quick-reject draw text blob calls. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
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 8
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 matrix, looper.paint()); 2213 matrix, looper.paint());
2214 } 2214 }
2215 2215
2216 LOOPER_END 2216 LOOPER_END
2217 } 2217 }
2218 2218
2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2220 const SkPaint& paint) { 2220 const SkPaint& paint) {
2221 SkASSERT(blob); 2221 SkASSERT(blob);
2222 2222
2223 // FIXME: dispatch to the device instead
2224
2225 if (x || y) { 2223 if (x || y) {
2226 this->translate(x, y); 2224 this->translate(x, y);
2227 } 2225 }
2228 2226
2229 SkPaint runPaint = paint; 2227 if (!this->quickReject(blob->bounds())) {
2230 SkTextBlob::RunIterator it(blob); 2228 // FIXME: dispatch to the device instead
reed1 2014/08/27 17:16:22 I don't think the device needs to do this. Howeve
robertphillips 2014/08/27 17:25:30 The GPU device wants this.
f(malita) 2014/08/27 17:55:44 Done.
2231 while (!it.done()) {
2232 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2233 const SkPoint& offset = it.offset();
2234 // applyFontToPaint() always overwrites the exact same attributes,
2235 // so it is safe to not re-seed the paint.
2236 it.applyFontToPaint(&runPaint);
2237 2229
2238 switch (it.positioning()) { 2230 SkPaint runPaint = paint;
2239 case SkTextBlob::kDefault_Positioning: 2231 SkTextBlob::RunIterator it(blob);
2240 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), runPain t); 2232 while (!it.done()) {
2241 break; 2233 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2242 case SkTextBlob::kHorizontal_Positioning: 2234 const SkPoint& offset = it.offset();
2243 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), runPa int); 2235 // applyFontToPaint() always overwrites the exact same attributes,
2244 break; 2236 // so it is safe to not re-seed the paint.
2245 case SkTextBlob::kFull_Positioning: 2237 it.applyFontToPaint(&runPaint);
2246 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), ru nPaint); 2238
2247 break; 2239 switch (it.positioning()) {
2248 default: 2240 case SkTextBlob::kDefault_Positioning:
2249 SkFAIL("unhandled positioning mode"); 2241 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), run Paint);
2242 break;
2243 case SkTextBlob::kHorizontal_Positioning:
2244 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), r unPaint);
2245 break;
2246 case SkTextBlob::kFull_Positioning:
2247 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos() , runPaint);
2248 break;
2249 default:
2250 SkFAIL("unhandled positioning mode");
2251 }
2252
2253 it.next();
2250 } 2254 }
2251
2252 it.next();
2253 } 2255 }
2254 2256
2255 if (x || y) { 2257 if (x || y) {
2256 this->translate(-x, -y); 2258 this->translate(-x, -y);
2257 } 2259 }
2258 } 2260 }
2259 2261
2260 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2262 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2261 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y, 2263 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2262 const SkPaint& paint) { 2264 const SkPaint& paint) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2596 }
2595 2597
2596 if (NULL != matrix) { 2598 if (NULL != matrix) {
2597 canvas->concat(*matrix); 2599 canvas->concat(*matrix);
2598 } 2600 }
2599 } 2601 }
2600 2602
2601 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2603 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2602 fCanvas->restoreToCount(fSaveCount); 2604 fCanvas->restoreToCount(fSaveCount);
2603 } 2605 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698