OLD | NEW |
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 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2192 | 2192 |
2193 LOOPER_BEGIN(paint, SkDrawFilter::kPoint_Type, bounds) | 2193 LOOPER_BEGIN(paint, SkDrawFilter::kPoint_Type, bounds) |
2194 | 2194 |
2195 while (iter.next()) { | 2195 while (iter.next()) { |
2196 iter.fDevice->drawPoints(iter, mode, count, pts, looper.paint()); | 2196 iter.fDevice->drawPoints(iter, mode, count, pts, looper.paint()); |
2197 } | 2197 } |
2198 | 2198 |
2199 LOOPER_END | 2199 LOOPER_END |
2200 } | 2200 } |
2201 | 2201 |
| 2202 static bool needs_autodrawlooper(SkCanvas* canvas, const SkPaint& paint) { |
| 2203 return ((intptr_t)paint.getImageFilter() | |
| 2204 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
| 2205 (intptr_t)canvas->getDrawFilter() | |
| 2206 #endif |
| 2207 (intptr_t)paint.getLooper() ) != 0; |
| 2208 } |
| 2209 |
2202 void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) { | 2210 void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) { |
2203 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawRect()"); | 2211 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawRect()"); |
2204 SkRect storage; | 2212 SkRect storage; |
2205 const SkRect* bounds = nullptr; | 2213 const SkRect* bounds = nullptr; |
2206 if (paint.canComputeFastBounds()) { | 2214 if (paint.canComputeFastBounds()) { |
2207 // Skia will draw an inverted rect, because it explicitly "sorts" it dow
nstream. | 2215 // Skia will draw an inverted rect, because it explicitly "sorts" it dow
nstream. |
2208 // To prevent accidental rejecting at this stage, we have to sort it bef
ore we check. | 2216 // To prevent accidental rejecting at this stage, we have to sort it bef
ore we check. |
2209 SkRect tmp(r); | 2217 SkRect tmp(r); |
2210 tmp.sort(); | 2218 tmp.sort(); |
2211 | 2219 |
2212 if (this->quickReject(paint.computeFastBounds(tmp, &storage))) { | 2220 if (this->quickReject(paint.computeFastBounds(tmp, &storage))) { |
2213 return; | 2221 return; |
2214 } | 2222 } |
2215 bounds = &r; | 2223 bounds = &r; |
2216 } | 2224 } |
2217 | 2225 |
2218 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, SkDrawFilter::kRect_Type, bound
s, false) | 2226 if (needs_autodrawlooper(this, paint)) { |
| 2227 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, SkDrawFilter::kRect_Type, b
ounds, false) |
2219 | 2228 |
2220 while (iter.next()) { | 2229 while (iter.next()) { |
2221 iter.fDevice->drawRect(iter, r, looper.paint()); | 2230 iter.fDevice->drawRect(iter, r, looper.paint()); |
| 2231 } |
| 2232 |
| 2233 LOOPER_END |
| 2234 } else { |
| 2235 this->predrawNotify(bounds, &paint, false); |
| 2236 SkDrawIter iter(this); |
| 2237 while (iter.next()) { |
| 2238 iter.fDevice->drawRect(iter, r, paint); |
| 2239 } |
2222 } | 2240 } |
2223 | |
2224 LOOPER_END | |
2225 } | 2241 } |
2226 | 2242 |
2227 void SkCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) { | 2243 void SkCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) { |
2228 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawOval()"); | 2244 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawOval()"); |
2229 SkRect storage; | 2245 SkRect storage; |
2230 const SkRect* bounds = nullptr; | 2246 const SkRect* bounds = nullptr; |
2231 if (paint.canComputeFastBounds()) { | 2247 if (paint.canComputeFastBounds()) { |
2232 if (this->quickReject(paint.computeFastBounds(oval, &storage))) { | 2248 if (this->quickReject(paint.computeFastBounds(oval, &storage))) { |
2233 return; | 2249 return; |
2234 } | 2250 } |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 | 3374 |
3359 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3375 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3360 fCanvas->restoreToCount(fSaveCount); | 3376 fCanvas->restoreToCount(fSaveCount); |
3361 } | 3377 } |
3362 | 3378 |
3363 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3379 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3364 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3380 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3365 return this->makeSurface(info, props).release(); | 3381 return this->makeSurface(info, props).release(); |
3366 } | 3382 } |
3367 #endif | 3383 #endif |
OLD | NEW |