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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // const-cast. | 658 // const-cast. |
659 *const_cast<bool*>(&fConservativeRasterClip) = SkToBool(flags & kConservativ
eRasterClip_InitFlag); | 659 *const_cast<bool*>(&fConservativeRasterClip) = SkToBool(flags & kConservativ
eRasterClip_InitFlag); |
660 | 660 |
661 fCachedLocalClipBounds.setEmpty(); | 661 fCachedLocalClipBounds.setEmpty(); |
662 fCachedLocalClipBoundsDirty = true; | 662 fCachedLocalClipBoundsDirty = true; |
663 fAllowSoftClip = true; | 663 fAllowSoftClip = true; |
664 fAllowSimplifyClip = false; | 664 fAllowSimplifyClip = false; |
665 fDeviceCMDirty = true; | 665 fDeviceCMDirty = true; |
666 fSaveCount = 1; | 666 fSaveCount = 1; |
667 fMetaData = nullptr; | 667 fMetaData = nullptr; |
| 668 #ifdef SK_USE_SHADOWS |
| 669 fLights = nullptr; |
| 670 #endif |
668 | 671 |
669 fClipStack.reset(new SkClipStack); | 672 fClipStack.reset(new SkClipStack); |
670 | 673 |
671 fMCRec = (MCRec*)fMCStack.push_back(); | 674 fMCRec = (MCRec*)fMCStack.push_back(); |
672 new (fMCRec) MCRec(fConservativeRasterClip); | 675 new (fMCRec) MCRec(fConservativeRasterClip); |
673 | 676 |
674 SkASSERT(sizeof(DeviceCM) <= sizeof(fDeviceCMStorage)); | 677 SkASSERT(sizeof(DeviceCM) <= sizeof(fDeviceCMStorage)); |
675 fMCRec->fLayer = (DeviceCM*)fDeviceCMStorage; | 678 fMCRec->fLayer = (DeviceCM*)fDeviceCMStorage; |
676 new (fDeviceCMStorage) DeviceCM(nullptr, nullptr, nullptr, fConservativeRast
erClip, false, | 679 new (fDeviceCMStorage) DeviceCM(nullptr, nullptr, nullptr, fConservativeRast
erClip, false, |
677 fMCRec->fMatrix); | 680 fMCRec->fMatrix); |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 void SkCanvas::setMatrix(const SkMatrix& matrix) { | 1540 void SkCanvas::setMatrix(const SkMatrix& matrix) { |
1538 this->checkForDeferredSave(); | 1541 this->checkForDeferredSave(); |
1539 this->internalSetMatrix(matrix); | 1542 this->internalSetMatrix(matrix); |
1540 this->didSetMatrix(matrix); | 1543 this->didSetMatrix(matrix); |
1541 } | 1544 } |
1542 | 1545 |
1543 void SkCanvas::resetMatrix() { | 1546 void SkCanvas::resetMatrix() { |
1544 this->setMatrix(SkMatrix::I()); | 1547 this->setMatrix(SkMatrix::I()); |
1545 } | 1548 } |
1546 | 1549 |
| 1550 #ifdef SK_USE_SHADOWS |
1547 void SkCanvas::translateZ(SkScalar z) { | 1551 void SkCanvas::translateZ(SkScalar z) { |
1548 this->checkForDeferredSave(); | 1552 this->checkForDeferredSave(); |
1549 this->fMCRec->fCurDrawDepth += z; | 1553 this->fMCRec->fCurDrawDepth += z; |
1550 this->didTranslateZ(z); | 1554 this->didTranslateZ(z); |
1551 } | 1555 } |
1552 | 1556 |
1553 SkScalar SkCanvas::getZ() const { | 1557 SkScalar SkCanvas::getZ() const { |
1554 return this->fMCRec->fCurDrawDepth; | 1558 return this->fMCRec->fCurDrawDepth; |
1555 } | 1559 } |
1556 | 1560 |
| 1561 void SkCanvas::setLights(sk_sp<SkLights> lights) { |
| 1562 this->fLights = lights; |
| 1563 } |
| 1564 |
| 1565 sk_sp<SkLights> SkCanvas::getLights() const { |
| 1566 return this->fLights; |
| 1567 } |
| 1568 #endif |
| 1569 |
1557 ////////////////////////////////////////////////////////////////////////////// | 1570 ////////////////////////////////////////////////////////////////////////////// |
1558 | 1571 |
1559 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1572 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1560 if (!fAllowSoftClip) { | 1573 if (!fAllowSoftClip) { |
1561 doAA = false; | 1574 doAA = false; |
1562 } | 1575 } |
1563 | 1576 |
1564 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1577 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
1565 // Check if we can quick-accept the clip call (and do nothing) | 1578 // Check if we can quick-accept the clip call (and do nothing) |
1566 // | 1579 // |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 } | 3037 } |
3025 if (this->quickReject(bounds)) { | 3038 if (this->quickReject(bounds)) { |
3026 return; | 3039 return; |
3027 } | 3040 } |
3028 } | 3041 } |
3029 | 3042 |
3030 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); | 3043 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); |
3031 picture->playback(this); | 3044 picture->playback(this); |
3032 } | 3045 } |
3033 | 3046 |
| 3047 #ifdef SK_USE_SHADOWS |
| 3048 void SkCanvas::drawShadowedPicture(const SkPicture* picture, |
| 3049 const SkMatrix* matrix, |
| 3050 const SkPaint* paint) { |
| 3051 RETURN_ON_NULL(picture); |
| 3052 |
| 3053 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawShadowedPicture()"); |
| 3054 |
| 3055 this->onDrawShadowedPicture(picture, matrix, paint); |
| 3056 } |
| 3057 |
| 3058 void SkCanvas::onDrawShadowedPicture(const SkPicture* picture, |
| 3059 const SkMatrix* matrix, |
| 3060 const SkPaint* paint) { |
| 3061 this->onDrawPicture(picture, matrix, paint); |
| 3062 } |
| 3063 #endif |
| 3064 |
3034 /////////////////////////////////////////////////////////////////////////////// | 3065 /////////////////////////////////////////////////////////////////////////////// |
3035 /////////////////////////////////////////////////////////////////////////////// | 3066 /////////////////////////////////////////////////////////////////////////////// |
3036 | 3067 |
3037 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { | 3068 SkCanvas::LayerIter::LayerIter(SkCanvas* canvas, bool skipEmptyClips) { |
3038 static_assert(sizeof(fStorage) >= sizeof(SkDrawIter), "fStorage_too_small"); | 3069 static_assert(sizeof(fStorage) >= sizeof(SkDrawIter), "fStorage_too_small"); |
3039 | 3070 |
3040 SkASSERT(canvas); | 3071 SkASSERT(canvas); |
3041 | 3072 |
3042 fImpl = new (fStorage) SkDrawIter(canvas, skipEmptyClips); | 3073 fImpl = new (fStorage) SkDrawIter(canvas, skipEmptyClips); |
3043 fDone = !fImpl->next(); | 3074 fDone = !fImpl->next(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3134 | 3165 |
3135 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3166 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3136 fCanvas->restoreToCount(fSaveCount); | 3167 fCanvas->restoreToCount(fSaveCount); |
3137 } | 3168 } |
3138 | 3169 |
3139 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3170 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3140 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3171 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3141 return this->makeSurface(info, props).release(); | 3172 return this->makeSurface(info, props).release(); |
3142 } | 3173 } |
3143 #endif | 3174 #endif |
OLD | NEW |