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 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 SkIntToScalar(image->width()), SkIntToScala
r(image->height())); | 2228 SkIntToScalar(image->width()), SkIntToScala
r(image->height())); |
2229 if (nullptr == paint || paint->canComputeFastBounds()) { | 2229 if (nullptr == paint || paint->canComputeFastBounds()) { |
2230 SkRect tmp = bounds; | 2230 SkRect tmp = bounds; |
2231 if (paint) { | 2231 if (paint) { |
2232 paint->computeFastBounds(tmp, &tmp); | 2232 paint->computeFastBounds(tmp, &tmp); |
2233 } | 2233 } |
2234 if (this->quickReject(tmp)) { | 2234 if (this->quickReject(tmp)) { |
2235 return; | 2235 return; |
2236 } | 2236 } |
2237 } | 2237 } |
2238 | 2238 |
2239 SkLazyPaint lazy; | 2239 SkLazyPaint lazy; |
2240 if (nullptr == paint) { | 2240 if (nullptr == paint) { |
2241 paint = lazy.init(); | 2241 paint = lazy.init(); |
2242 } | 2242 } |
2243 | 2243 |
2244 bool drawAsSprite = this->canDrawBitmapAsSprite(x, y, image->width(), image-
>height(), | 2244 bool drawAsSprite = this->canDrawBitmapAsSprite(x, y, image->width(), image-
>height(), |
2245 *paint); | 2245 *paint); |
2246 if (drawAsSprite && paint->getImageFilter()) { | 2246 if (drawAsSprite && paint->getImageFilter()) { |
2247 SkBitmap bitmap; | 2247 SkBitmap bitmap; |
2248 if (!as_IB(image)->asBitmapForImageFilters(&bitmap)) { | 2248 if (!as_IB(image)->asBitmapForImageFilters(&bitmap)) { |
(...skipping 16 matching lines...) Expand all Loading... |
2265 SkPoint pt; | 2265 SkPoint pt; |
2266 iter.fMatrix->mapXY(x, y, &pt); | 2266 iter.fMatrix->mapXY(x, y, &pt); |
2267 iter.fDevice->drawSpriteWithFilter(iter, bitmap, | 2267 iter.fDevice->drawSpriteWithFilter(iter, bitmap, |
2268 SkScalarRoundToInt(pt.fX), | 2268 SkScalarRoundToInt(pt.fX), |
2269 SkScalarRoundToInt(pt.fY), pn
t); | 2269 SkScalarRoundToInt(pt.fY), pn
t); |
2270 } | 2270 } |
2271 } else { | 2271 } else { |
2272 iter.fDevice->drawImage(iter, image, x, y, pnt); | 2272 iter.fDevice->drawImage(iter, image, x, y, pnt); |
2273 } | 2273 } |
2274 } | 2274 } |
2275 | 2275 |
2276 LOOPER_END | 2276 LOOPER_END |
2277 } | 2277 } |
2278 | 2278 |
2279 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, | 2279 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, |
2280 const SkPaint* paint, SrcRectConstraint constrain
t) { | 2280 const SkPaint* paint, SrcRectConstraint constrain
t) { |
2281 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); | 2281 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); |
2282 if (nullptr == paint || paint->canComputeFastBounds()) { | 2282 if (nullptr == paint || paint->canComputeFastBounds()) { |
2283 SkRect storage = dst; | 2283 SkRect storage = dst; |
2284 if (paint) { | 2284 if (paint) { |
2285 paint->computeFastBounds(dst, &storage); | 2285 paint->computeFastBounds(dst, &storage); |
2286 } | 2286 } |
2287 if (this->quickReject(storage)) { | 2287 if (this->quickReject(storage)) { |
2288 return; | 2288 return; |
2289 } | 2289 } |
2290 } | 2290 } |
2291 SkLazyPaint lazy; | 2291 SkLazyPaint lazy; |
2292 if (nullptr == paint) { | 2292 if (nullptr == paint) { |
2293 paint = lazy.init(); | 2293 paint = lazy.init(); |
2294 } | 2294 } |
2295 | 2295 |
2296 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &d
st, | 2296 LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &d
st, |
2297 image->isOpaque()) | 2297 image->isOpaque()) |
2298 | 2298 |
2299 while (iter.next()) { | 2299 while (iter.next()) { |
2300 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const
raint); | 2300 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint(), const
raint); |
2301 } | 2301 } |
2302 | 2302 |
2303 LOOPER_END | 2303 LOOPER_END |
2304 } | 2304 } |
2305 | 2305 |
2306 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { | 2306 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { |
2307 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); | 2307 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); |
2308 SkDEBUGCODE(bitmap.validate();) | 2308 SkDEBUGCODE(bitmap.validate();) |
2309 | 2309 |
2310 if (bitmap.drawsNothing()) { | 2310 if (bitmap.drawsNothing()) { |
2311 return; | 2311 return; |
2312 } | 2312 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const
SkRect& dst, | 2390 void SkCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const
SkRect& dst, |
2391 const SkPaint* paint, SrcRectConstraint constrai
nt) { | 2391 const SkPaint* paint, SrcRectConstraint constrai
nt) { |
2392 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()")
; | 2392 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapRectToRect()")
; |
2393 SkDEBUGCODE(bitmap.validate();) | 2393 SkDEBUGCODE(bitmap.validate();) |
2394 this->internalDrawBitmapRect(bitmap, src, dst, paint, constraint); | 2394 this->internalDrawBitmapRect(bitmap, src, dst, paint, constraint); |
2395 } | 2395 } |
2396 | 2396 |
2397 void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons
t SkRect& dst, | 2397 void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons
t SkRect& dst, |
2398 const SkPaint* paint) { | 2398 const SkPaint* paint) { |
2399 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageNine()"); | 2399 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageNine()"); |
2400 | 2400 |
2401 if (nullptr == paint || paint->canComputeFastBounds()) { | 2401 if (nullptr == paint || paint->canComputeFastBounds()) { |
2402 SkRect storage; | 2402 SkRect storage; |
2403 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { | 2403 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
2404 return; | 2404 return; |
2405 } | 2405 } |
2406 } | 2406 } |
2407 | 2407 |
2408 SkLazyPaint lazy; | 2408 SkLazyPaint lazy; |
2409 if (nullptr == paint) { | 2409 if (nullptr == paint) { |
2410 paint = lazy.init(); | 2410 paint = lazy.init(); |
2411 } | 2411 } |
2412 | 2412 |
2413 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) | 2413 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
2414 | 2414 |
2415 while (iter.next()) { | 2415 while (iter.next()) { |
2416 iter.fDevice->drawImageNine(iter, image, center, dst, looper.paint()); | 2416 iter.fDevice->drawImageNine(iter, image, center, dst, looper.paint()); |
2417 } | 2417 } |
2418 | 2418 |
2419 LOOPER_END | 2419 LOOPER_END |
2420 } | 2420 } |
2421 | 2421 |
2422 void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, c
onst SkRect& dst, | 2422 void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, c
onst SkRect& dst, |
2423 const SkPaint* paint) { | 2423 const SkPaint* paint) { |
2424 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapNine()"); | 2424 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmapNine()"); |
2425 SkDEBUGCODE(bitmap.validate();) | 2425 SkDEBUGCODE(bitmap.validate();) |
2426 | 2426 |
2427 if (nullptr == paint || paint->canComputeFastBounds()) { | 2427 if (nullptr == paint || paint->canComputeFastBounds()) { |
2428 SkRect storage; | 2428 SkRect storage; |
2429 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { | 2429 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
2430 return; | 2430 return; |
2431 } | 2431 } |
2432 } | 2432 } |
2433 | 2433 |
2434 SkLazyPaint lazy; | 2434 SkLazyPaint lazy; |
2435 if (nullptr == paint) { | 2435 if (nullptr == paint) { |
2436 paint = lazy.init(); | 2436 paint = lazy.init(); |
2437 } | 2437 } |
2438 | 2438 |
2439 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) | 2439 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
2440 | 2440 |
2441 while (iter.next()) { | 2441 while (iter.next()) { |
2442 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); | 2442 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); |
2443 } | 2443 } |
2444 | 2444 |
2445 LOOPER_END | 2445 LOOPER_END |
2446 } | 2446 } |
2447 | 2447 |
2448 class SkDeviceFilteredPaint { | 2448 class SkDeviceFilteredPaint { |
2449 public: | 2449 public: |
2450 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { | 2450 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { |
2451 uint32_t filteredFlags = device->filterTextFlags(paint); | 2451 uint32_t filteredFlags = device->filterTextFlags(paint); |
2452 if (filteredFlags != paint.getFlags()) { | 2452 if (filteredFlags != paint.getFlags()) { |
2453 SkPaint* newPaint = fLazy.set(paint); | 2453 SkPaint* newPaint = fLazy.set(paint); |
2454 newPaint->setFlags(filteredFlags); | 2454 newPaint->setFlags(filteredFlags); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2733 const SkColor colors[], int count, SkXfermode::Mode m
ode, | 2733 const SkColor colors[], int count, SkXfermode::Mode m
ode, |
2734 const SkRect* cull, const SkPaint* paint) { | 2734 const SkRect* cull, const SkPaint* paint) { |
2735 if (cull && this->quickReject(*cull)) { | 2735 if (cull && this->quickReject(*cull)) { |
2736 return; | 2736 return; |
2737 } | 2737 } |
2738 | 2738 |
2739 SkPaint pnt; | 2739 SkPaint pnt; |
2740 if (paint) { | 2740 if (paint) { |
2741 pnt = *paint; | 2741 pnt = *paint; |
2742 } | 2742 } |
2743 | 2743 |
2744 LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, nullptr) | 2744 LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, nullptr) |
2745 while (iter.next()) { | 2745 while (iter.next()) { |
2746 iter.fDevice->drawAtlas(iter, atlas, xform, tex, colors, count, mode, pn
t); | 2746 iter.fDevice->drawAtlas(iter, atlas, xform, tex, colors, count, mode, pn
t); |
2747 } | 2747 } |
2748 LOOPER_END | 2748 LOOPER_END |
2749 } | 2749 } |
2750 | 2750 |
2751 void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* va
lue) { | 2751 void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* va
lue) { |
2752 SkASSERT(key); | 2752 SkASSERT(key); |
2753 | 2753 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 | 3041 |
3042 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3042 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3043 fCanvas->restoreToCount(fSaveCount); | 3043 fCanvas->restoreToCount(fSaveCount); |
3044 } | 3044 } |
3045 | 3045 |
3046 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3046 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3047 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3047 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3048 return this->makeSurface(info, props).release(); | 3048 return this->makeSurface(info, props).release(); |
3049 } | 3049 } |
3050 #endif | 3050 #endif |
OLD | NEW |