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

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: Don't quickreject empty bounds. 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 bool hasOffset = x || y;
2224
2225 // FIXME: temporarily disable quickreject for empty bounds,
2226 // pending implicit blob bounds implementation.
2227 if (!blob->bounds().isEmpty() && paint.canComputeFastBounds()) {
2228 SkRect storage;
reed1 2014/08/29 15:34:28 I wonder if we should send the translated rect to
f(malita) 2014/08/29 16:01:26 Done.
2229 const SkRect* bounds = &paint.computeFastBounds(blob->bounds(), &storage );
2230 if (hasOffset) {
2231 if (bounds != &storage) {
2232 storage = *bounds;
2233 bounds = &storage;
2234 }
2235 storage.offset(x, y);
2236 }
2237
2238 if (this->quickReject(*bounds)) {
2239 return;
2240 }
2241 }
2242
2223 // FIXME: dispatch to the device instead 2243 // FIXME: dispatch to the device instead
2224 2244
2225 if (x || y) { 2245 if (hasOffset) {
2226 this->translate(x, y); 2246 this->translate(x, y);
reed1 2014/08/29 15:34:28 Eeeek! translate is virtual. I thought all of this
f(malita) 2014/08/29 15:36:39 It is now, just haven't rebased this yet :)
2227 } 2247 }
2228 2248
2229 SkPaint runPaint = paint; 2249 SkPaint runPaint = paint;
2230 SkTextBlob::RunIterator it(blob); 2250 SkTextBlob::RunIterator it(blob);
2231 while (!it.done()) { 2251 while (!it.done()) {
2232 size_t textLen = it.glyphCount() * sizeof(uint16_t); 2252 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2233 const SkPoint& offset = it.offset(); 2253 const SkPoint& offset = it.offset();
2234 // applyFontToPaint() always overwrites the exact same attributes, 2254 // applyFontToPaint() always overwrites the exact same attributes,
2235 // so it is safe to not re-seed the paint. 2255 // so it is safe to not re-seed the paint.
2236 it.applyFontToPaint(&runPaint); 2256 it.applyFontToPaint(&runPaint);
2237 2257
2238 switch (it.positioning()) { 2258 switch (it.positioning()) {
2239 case SkTextBlob::kDefault_Positioning: 2259 case SkTextBlob::kDefault_Positioning:
2240 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), runPain t); 2260 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), runPain t);
2241 break; 2261 break;
2242 case SkTextBlob::kHorizontal_Positioning: 2262 case SkTextBlob::kHorizontal_Positioning:
2243 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), runPa int); 2263 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), runPa int);
2244 break; 2264 break;
2245 case SkTextBlob::kFull_Positioning: 2265 case SkTextBlob::kFull_Positioning:
2246 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), ru nPaint); 2266 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), ru nPaint);
2247 break; 2267 break;
2248 default: 2268 default:
2249 SkFAIL("unhandled positioning mode"); 2269 SkFAIL("unhandled positioning mode");
2250 } 2270 }
2251 2271
2252 it.next(); 2272 it.next();
2253 } 2273 }
2254 2274
2255 if (x || y) { 2275 if (hasOffset) {
2256 this->translate(-x, -y); 2276 this->translate(-x, -y);
2257 } 2277 }
2258 } 2278 }
2259 2279
2260 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2280 // 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, 2281 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2262 const SkPaint& paint) { 2282 const SkPaint& paint) {
2263 this->onDrawText(text, byteLength, x, y, paint); 2283 this->onDrawText(text, byteLength, x, y, paint);
2264 } 2284 }
2265 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[], 2285 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2614 }
2595 2615
2596 if (NULL != matrix) { 2616 if (NULL != matrix) {
2597 canvas->concat(*matrix); 2617 canvas->concat(*matrix);
2598 } 2618 }
2599 } 2619 }
2600 2620
2601 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2621 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2602 fCanvas->restoreToCount(fSaveCount); 2622 fCanvas->restoreToCount(fSaveCount);
2603 } 2623 }
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