| 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 | 8 |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 tmpPaint.setAlpha(alpha); | 888 tmpPaint.setAlpha(alpha); |
| 889 return this->saveLayer(bounds, &tmpPaint, flags); | 889 return this->saveLayer(bounds, &tmpPaint, flags); |
| 890 } | 890 } |
| 891 } | 891 } |
| 892 | 892 |
| 893 void SkCanvas::restore() { | 893 void SkCanvas::restore() { |
| 894 // check for underflow | 894 // check for underflow |
| 895 if (fMCStack.count() > 1) { | 895 if (fMCStack.count() > 1) { |
| 896 this->willRestore(); | 896 this->willRestore(); |
| 897 this->internalRestore(); | 897 this->internalRestore(); |
| 898 this->didRestore(); |
| 898 } | 899 } |
| 899 } | 900 } |
| 900 | 901 |
| 901 void SkCanvas::internalRestore() { | 902 void SkCanvas::internalRestore() { |
| 902 SkASSERT(fMCStack.count() != 0); | 903 SkASSERT(fMCStack.count() != 0); |
| 903 | 904 |
| 904 fDeviceCMDirty = true; | 905 fDeviceCMDirty = true; |
| 905 fCachedLocalClipBoundsDirty = true; | 906 fCachedLocalClipBoundsDirty = true; |
| 906 | 907 |
| 907 fClipStack.restore(); | 908 fClipStack.restore(); |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 LOOPER_END | 2256 LOOPER_END |
| 2256 } | 2257 } |
| 2257 | 2258 |
| 2258 void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4], | 2259 void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 2259 const SkPoint texCoords[4], SkXfermode* xmode, const Sk
Paint& paint) { | 2260 const SkPoint texCoords[4], SkXfermode* xmode, const Sk
Paint& paint) { |
| 2260 if (NULL == cubics) { | 2261 if (NULL == cubics) { |
| 2261 return; | 2262 return; |
| 2262 } | 2263 } |
| 2263 | 2264 |
| 2264 // Since a patch is always within the convex hull of the control points, we
discard it when its | 2265 // Since a patch is always within the convex hull of the control points, we
discard it when its |
| 2265 // bounding rectangle is completely outside the current clip. | 2266 // bounding rectangle is completely outside the current clip. |
| 2266 SkRect bounds; | 2267 SkRect bounds; |
| 2267 bounds.set(cubics, SkPatchUtils::kNumCtrlPts); | 2268 bounds.set(cubics, SkPatchUtils::kNumCtrlPts); |
| 2268 if (this->quickReject(bounds)) { | 2269 if (this->quickReject(bounds)) { |
| 2269 return; | 2270 return; |
| 2270 } | 2271 } |
| 2271 | 2272 |
| 2272 this->onDrawPatch(cubics, colors, texCoords, xmode, paint); | 2273 this->onDrawPatch(cubics, colors, texCoords, xmode, paint); |
| 2273 } | 2274 } |
| 2274 | 2275 |
| 2275 void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], | 2276 void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 2276 const SkPoint texCoords[4], SkXfermode* xmode, const
SkPaint& paint) { | 2277 const SkPoint texCoords[4], SkXfermode* xmode, const
SkPaint& paint) { |
| 2277 | 2278 |
| 2278 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) | 2279 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) |
| 2279 | 2280 |
| 2280 while (iter.next()) { | 2281 while (iter.next()) { |
| 2281 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); | 2282 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); |
| 2282 } | 2283 } |
| 2283 | 2284 |
| 2284 LOOPER_END | 2285 LOOPER_END |
| 2285 } | 2286 } |
| 2286 | 2287 |
| 2287 ////////////////////////////////////////////////////////////////////////////// | 2288 ////////////////////////////////////////////////////////////////////////////// |
| 2288 // These methods are NOT virtual, and therefore must call back into virtual | 2289 // These methods are NOT virtual, and therefore must call back into virtual |
| 2289 // methods, rather than actually drawing themselves. | 2290 // methods, rather than actually drawing themselves. |
| 2290 ////////////////////////////////////////////////////////////////////////////// | 2291 ////////////////////////////////////////////////////////////////////////////// |
| 2291 | 2292 |
| 2292 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, | 2293 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, |
| 2293 SkXfermode::Mode mode) { | 2294 SkXfermode::Mode mode) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 { | 2544 { |
| 2544 if (NULL != paint) { | 2545 if (NULL != paint) { |
| 2545 SkRect bounds = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); | 2546 SkRect bounds = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heigh
t)); |
| 2546 if (matrix) { | 2547 if (matrix) { |
| 2547 matrix->mapRect(&bounds); | 2548 matrix->mapRect(&bounds); |
| 2548 } | 2549 } |
| 2549 canvas->saveLayer(&bounds, paint); | 2550 canvas->saveLayer(&bounds, paint); |
| 2550 } else if (NULL != matrix) { | 2551 } else if (NULL != matrix) { |
| 2551 canvas->save(); | 2552 canvas->save(); |
| 2552 } | 2553 } |
| 2553 | 2554 |
| 2554 if (NULL != matrix) { | 2555 if (NULL != matrix) { |
| 2555 canvas->concat(*matrix); | 2556 canvas->concat(*matrix); |
| 2556 } | 2557 } |
| 2557 } | 2558 } |
| 2558 | 2559 |
| 2559 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2560 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2560 fCanvas->restoreToCount(fSaveCount); | 2561 fCanvas->restoreToCount(fSaveCount); |
| 2561 } | 2562 } |
| OLD | NEW |