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 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 const SkPaint* paint) { | 2029 const SkPaint* paint) { |
2030 if (bitmap.drawsNothing() || dst.isEmpty()) { | 2030 if (bitmap.drawsNothing() || dst.isEmpty()) { |
2031 return; | 2031 return; |
2032 } | 2032 } |
2033 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { | 2033 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { |
2034 this->drawBitmapRect(bitmap, dst, paint); | 2034 this->drawBitmapRect(bitmap, dst, paint); |
2035 } | 2035 } |
2036 this->onDrawBitmapNine(bitmap, center, dst, paint); | 2036 this->onDrawBitmapNine(bitmap, center, dst, paint); |
2037 } | 2037 } |
2038 | 2038 |
| 2039 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& divs,
const SkRect& dst, |
| 2040 const SkPaint* paint) { |
| 2041 if (bitmap.drawsNothing() || dst.isEmpty()) { |
| 2042 return; |
| 2043 } |
| 2044 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), divs)) { |
| 2045 this->drawBitmapRect(bitmap, dst, paint); |
| 2046 } |
| 2047 this->onDrawBitmapNine(bitmap, divs, dst, paint); |
| 2048 } |
| 2049 |
2039 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
Rect tex[], | 2050 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
Rect tex[], |
2040 const SkColor colors[], int count, SkXfermode::Mode mod
e, | 2051 const SkColor colors[], int count, SkXfermode::Mode mod
e, |
2041 const SkRect* cull, const SkPaint* paint) { | 2052 const SkRect* cull, const SkPaint* paint) { |
2042 RETURN_ON_NULL(atlas); | 2053 RETURN_ON_NULL(atlas); |
2043 if (count <= 0) { | 2054 if (count <= 0) { |
2044 return; | 2055 return; |
2045 } | 2056 } |
2046 SkASSERT(atlas); | 2057 SkASSERT(atlas); |
2047 SkASSERT(xform); | 2058 SkASSERT(xform); |
2048 SkASSERT(tex); | 2059 SkASSERT(tex); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 | 2520 |
2510 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) | 2521 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
2511 | 2522 |
2512 while (iter.next()) { | 2523 while (iter.next()) { |
2513 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); | 2524 iter.fDevice->drawBitmapNine(iter, bitmap, center, dst, looper.paint()); |
2514 } | 2525 } |
2515 | 2526 |
2516 LOOPER_END | 2527 LOOPER_END |
2517 } | 2528 } |
2518 | 2529 |
| 2530 void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& div
s, |
| 2531 const SkRect& dst, const SkPaint* paint) { |
| 2532 SkDEBUGCODE(bitmap.validate();) |
| 2533 |
| 2534 if (nullptr == paint || paint->canComputeFastBounds()) { |
| 2535 SkRect storage; |
| 2536 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) :
dst)) { |
| 2537 return; |
| 2538 } |
| 2539 } |
| 2540 |
| 2541 SkLazyPaint lazy; |
| 2542 if (nullptr == paint) { |
| 2543 paint = lazy.init(); |
| 2544 } |
| 2545 |
| 2546 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst) |
| 2547 |
| 2548 while (iter.next()) { |
| 2549 iter.fDevice->drawBitmapNine(iter, bitmap, divs, dst, looper.paint()); |
| 2550 } |
| 2551 |
| 2552 LOOPER_END |
| 2553 } |
| 2554 |
2519 class SkDeviceFilteredPaint { | 2555 class SkDeviceFilteredPaint { |
2520 public: | 2556 public: |
2521 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { | 2557 SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { |
2522 uint32_t filteredFlags = device->filterTextFlags(paint); | 2558 uint32_t filteredFlags = device->filterTextFlags(paint); |
2523 if (filteredFlags != paint.getFlags()) { | 2559 if (filteredFlags != paint.getFlags()) { |
2524 SkPaint* newPaint = fLazy.set(paint); | 2560 SkPaint* newPaint = fLazy.set(paint); |
2525 newPaint->setFlags(filteredFlags); | 2561 newPaint->setFlags(filteredFlags); |
2526 fPaint = newPaint; | 2562 fPaint = newPaint; |
2527 } else { | 2563 } else { |
2528 fPaint = &paint; | 2564 fPaint = &paint; |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 | 3164 |
3129 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3165 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3130 fCanvas->restoreToCount(fSaveCount); | 3166 fCanvas->restoreToCount(fSaveCount); |
3131 } | 3167 } |
3132 | 3168 |
3133 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3169 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3134 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3170 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3135 return this->makeSurface(info, props).release(); | 3171 return this->makeSurface(info, props).release(); |
3136 } | 3172 } |
3137 #endif | 3173 #endif |
OLD | NEW |