Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "SkTLazy.h" | 34 #include "SkTLazy.h" |
| 35 #include "SkTraceEvent.h" | 35 #include "SkTraceEvent.h" |
| 36 | 36 |
| 37 #include <new> | 37 #include <new> |
| 38 | 38 |
| 39 #if SK_SUPPORT_GPU | 39 #if SK_SUPPORT_GPU |
| 40 #include "GrContext.h" | 40 #include "GrContext.h" |
| 41 #include "GrRenderTarget.h" | 41 #include "GrRenderTarget.h" |
| 42 #include "SkGr.h" | 42 #include "SkGr.h" |
| 43 #endif | 43 #endif |
| 44 | 44 |
|
robertphillips
2016/01/08 16:44:19
Aren't our macros usually all caps ?
reed1
2016/01/08 17:01:41
Done.
| |
| 45 #define return_on_null(ptr) do { if (nullptr == (ptr)) return; } while (0) | |
| 46 | |
| 45 /* | 47 /* |
| 46 * Return true if the drawing this rect would hit every pixels in the canvas. | 48 * Return true if the drawing this rect would hit every pixels in the canvas. |
| 47 * | 49 * |
| 48 * Returns false if | 50 * Returns false if |
| 49 * - rect does not contain the canvas' bounds | 51 * - rect does not contain the canvas' bounds |
| 50 * - paint is not fill | 52 * - paint is not fill |
| 51 * - paint would blur or otherwise change the coverage of the rect | 53 * - paint would blur or otherwise change the coverage of the rect |
| 52 */ | 54 */ |
| 53 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa int, | 55 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa int, |
| 54 ShaderOverrideOpacity overrideOpacity ) const { | 56 ShaderOverrideOpacity overrideOpacity ) const { |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 return rec->fLayer->fDevice; | 828 return rec->fLayer->fDevice; |
| 827 } | 829 } |
| 828 | 830 |
| 829 SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { | 831 SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { |
| 830 if (updateMatrixClip) { | 832 if (updateMatrixClip) { |
| 831 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); | 833 const_cast<SkCanvas*>(this)->updateDeviceCMCache(); |
| 832 } | 834 } |
| 833 return fMCRec->fTopLayer->fDevice; | 835 return fMCRec->fTopLayer->fDevice; |
| 834 } | 836 } |
| 835 | 837 |
| 836 bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) { | 838 bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) { |
|
robertphillips
2016/01/08 16:44:19
here too ?
| |
| 837 if (kUnknown_SkColorType == bitmap->colorType() || bitmap->getTexture()) { | 839 if (kUnknown_SkColorType == bitmap->colorType() || bitmap->getTexture()) { |
| 838 return false; | 840 return false; |
| 839 } | 841 } |
| 840 | 842 |
| 841 bool weAllocated = false; | 843 bool weAllocated = false; |
| 842 if (nullptr == bitmap->pixelRef()) { | 844 if (nullptr == bitmap->pixelRef()) { |
| 843 if (!bitmap->tryAllocPixels()) { | 845 if (!bitmap->tryAllocPixels()) { |
| 844 return false; | 846 return false; |
| 845 } | 847 } |
| 846 weAllocated = true; | 848 weAllocated = true; |
| 847 } | 849 } |
| 848 | 850 |
| 849 SkAutoPixmapUnlock unlocker; | 851 SkAutoPixmapUnlock unlocker; |
| 850 if (bitmap->requestLock(&unlocker)) { | 852 if (bitmap->requestLock(&unlocker)) { |
| 851 const SkPixmap& pm = unlocker.pixmap(); | 853 const SkPixmap& pm = unlocker.pixmap(); |
| 852 if (this->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), x, y) ) { | 854 if (this->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), x, y) ) { |
| 853 return true; | 855 return true; |
| 854 } | 856 } |
| 855 } | 857 } |
| 856 | 858 |
| 857 if (weAllocated) { | 859 if (weAllocated) { |
| 858 bitmap->setPixelRef(nullptr); | 860 bitmap->setPixelRef(nullptr); |
| 859 } | 861 } |
| 860 return false; | 862 return false; |
| 861 } | 863 } |
| 862 | 864 |
| 863 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { | 865 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { |
|
robertphillips
2016/01/08 16:44:19
here ?
| |
| 864 SkIRect r = srcRect; | 866 SkIRect r = srcRect; |
| 865 const SkISize size = this->getBaseLayerSize(); | 867 const SkISize size = this->getBaseLayerSize(); |
| 866 if (!r.intersect(0, 0, size.width(), size.height())) { | 868 if (!r.intersect(0, 0, size.width(), size.height())) { |
| 867 bitmap->reset(); | 869 bitmap->reset(); |
| 868 return false; | 870 return false; |
| 869 } | 871 } |
| 870 | 872 |
| 871 if (!bitmap->tryAllocN32Pixels(r.width(), r.height())) { | 873 if (!bitmap->tryAllocN32Pixels(r.width(), r.height())) { |
| 872 // bitmap will already be reset. | 874 // bitmap will already be reset. |
| 873 return false; | 875 return false; |
| 874 } | 876 } |
| 875 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes( ), r.x(), r.y())) { | 877 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes( ), r.x(), r.y())) { |
| 876 bitmap->reset(); | 878 bitmap->reset(); |
| 877 return false; | 879 return false; |
| 878 } | 880 } |
| 879 return true; | 881 return true; |
| 880 } | 882 } |
| 881 | 883 |
| 882 bool SkCanvas::readPixels(const SkImageInfo& dstInfo, void* dstP, size_t rowByte s, int x, int y) { | 884 bool SkCanvas::readPixels(const SkImageInfo& dstInfo, void* dstP, size_t rowByte s, int x, int y) { |
|
robertphillips
2016/01/08 16:44:19
here ?
| |
| 883 SkBaseDevice* device = this->getDevice(); | 885 SkBaseDevice* device = this->getDevice(); |
| 884 if (!device) { | 886 if (!device) { |
| 885 return false; | 887 return false; |
| 886 } | 888 } |
| 887 const SkISize size = this->getBaseLayerSize(); | 889 const SkISize size = this->getBaseLayerSize(); |
| 888 | 890 |
| 889 SkReadPixelsRec rec(dstInfo, dstP, rowBytes, x, y); | 891 SkReadPixelsRec rec(dstInfo, dstP, rowBytes, x, y); |
| 890 if (!rec.trim(size.width(), size.height())) { | 892 if (!rec.trim(size.width(), size.height())) { |
| 891 return false; | 893 return false; |
| 892 } | 894 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 909 } | 911 } |
| 910 | 912 |
| 911 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size _t rowBytes, | 913 bool SkCanvas::writePixels(const SkImageInfo& origInfo, const void* pixels, size _t rowBytes, |
| 912 int x, int y) { | 914 int x, int y) { |
| 913 switch (origInfo.colorType()) { | 915 switch (origInfo.colorType()) { |
| 914 case kUnknown_SkColorType: | 916 case kUnknown_SkColorType: |
| 915 case kIndex_8_SkColorType: | 917 case kIndex_8_SkColorType: |
| 916 return false; | 918 return false; |
| 917 default: | 919 default: |
| 918 break; | 920 break; |
| 919 } | 921 } |
|
robertphillips
2016/01/08 16:44:19
here ?
| |
| 920 if (nullptr == pixels || rowBytes < origInfo.minRowBytes()) { | 922 if (nullptr == pixels || rowBytes < origInfo.minRowBytes()) { |
| 921 return false; | 923 return false; |
| 922 } | 924 } |
| 923 | 925 |
| 924 const SkISize size = this->getBaseLayerSize(); | 926 const SkISize size = this->getBaseLayerSize(); |
| 925 SkIRect target = SkIRect::MakeXYWH(x, y, origInfo.width(), origInfo.height() ); | 927 SkIRect target = SkIRect::MakeXYWH(x, y, origInfo.width(), origInfo.height() ); |
| 926 if (!target.intersect(0, 0, size.width(), size.height())) { | 928 if (!target.intersect(0, 0, size.width(), size.height())) { |
| 927 return false; | 929 return false; |
| 928 } | 930 } |
| 929 | 931 |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 SkPath path; | 1749 SkPath path; |
| 1748 element->asPath(&path); | 1750 element->asPath(&path); |
| 1749 rasterclip_path(&tmpClip, this, path, element->getOp(), element- >isAA()); | 1751 rasterclip_path(&tmpClip, this, path, element->getOp(), element- >isAA()); |
| 1750 break; | 1752 break; |
| 1751 } | 1753 } |
| 1752 } | 1754 } |
| 1753 } | 1755 } |
| 1754 } | 1756 } |
| 1755 #endif | 1757 #endif |
| 1756 | 1758 |
| 1757 void SkCanvas::replayClips(ClipVisitor* visitor) const { | 1759 void SkCanvas::replayClips(ClipVisitor* visitor) const { |
|
robertphillips
2016/01/08 16:44:19
here ?
| |
| 1758 SkClipStack::B2TIter iter(*fClipStack); | 1760 SkClipStack::B2TIter iter(*fClipStack); |
| 1759 const SkClipStack::Element* element; | 1761 const SkClipStack::Element* element; |
| 1760 | 1762 |
| 1761 while ((element = iter.next()) != nullptr) { | 1763 while ((element = iter.next()) != nullptr) { |
| 1762 element->replay(visitor); | 1764 element->replay(visitor); |
| 1763 } | 1765 } |
| 1764 } | 1766 } |
| 1765 | 1767 |
| 1766 /////////////////////////////////////////////////////////////////////////////// | 1768 /////////////////////////////////////////////////////////////////////////////// |
| 1767 | 1769 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1922 const uint16_t indices[], int indexCount, const SkPa int& paint) { | 1924 const uint16_t indices[], int indexCount, const SkPa int& paint) { |
| 1923 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode, | 1925 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode, |
| 1924 indices, indexCount, paint); | 1926 indices, indexCount, paint); |
| 1925 } | 1927 } |
| 1926 | 1928 |
| 1927 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { | 1929 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| 1928 this->onDrawPath(path, paint); | 1930 this->onDrawPath(path, paint); |
| 1929 } | 1931 } |
| 1930 | 1932 |
| 1931 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { | 1933 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { |
| 1934 return_on_null(image); | |
| 1932 this->onDrawImage(image, x, y, paint); | 1935 this->onDrawImage(image, x, y, paint); |
| 1933 } | 1936 } |
| 1934 | 1937 |
| 1935 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRe ct& dst, | 1938 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRe ct& dst, |
| 1936 const SkPaint* paint, SrcRectConstraint constraint) { | 1939 const SkPaint* paint, SrcRectConstraint constraint) { |
| 1940 return_on_null(image); | |
| 1937 if (dst.isEmpty() || src.isEmpty()) { | 1941 if (dst.isEmpty() || src.isEmpty()) { |
| 1938 return; | 1942 return; |
| 1939 } | 1943 } |
| 1940 this->onDrawImageRect(image, &src, dst, paint, constraint); | 1944 this->onDrawImageRect(image, &src, dst, paint, constraint); |
| 1941 } | 1945 } |
| 1942 | 1946 |
| 1943 void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const Sk Rect& dst, | 1947 void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const Sk Rect& dst, |
| 1944 const SkPaint* paint, SrcRectConstraint constraint) { | 1948 const SkPaint* paint, SrcRectConstraint constraint) { |
| 1949 return_on_null(image); | |
| 1945 this->drawImageRect(image, SkRect::Make(isrc), dst, paint, constraint); | 1950 this->drawImageRect(image, SkRect::Make(isrc), dst, paint, constraint); |
| 1946 } | 1951 } |
| 1947 | 1952 |
| 1948 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa int* paint, | 1953 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa int* paint, |
| 1949 SrcRectConstraint constraint) { | 1954 SrcRectConstraint constraint) { |
| 1955 return_on_null(image); | |
| 1950 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint, | 1956 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint, |
| 1951 constraint); | 1957 constraint); |
| 1952 } | 1958 } |
| 1953 | 1959 |
| 1954 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, | 1960 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, |
| 1955 const SkPaint* paint) { | 1961 const SkPaint* paint) { |
| 1962 return_on_null(image); | |
| 1956 if (dst.isEmpty()) { | 1963 if (dst.isEmpty()) { |
| 1957 return; | 1964 return; |
| 1958 } | 1965 } |
| 1959 if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) { | 1966 if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) { |
| 1960 this->drawImageRect(image, dst, paint); | 1967 this->drawImageRect(image, dst, paint); |
| 1961 } | 1968 } |
| 1962 this->onDrawImageNine(image, center, dst, paint); | 1969 this->onDrawImageNine(image, center, dst, paint); |
| 1963 } | 1970 } |
| 1964 | 1971 |
| 1965 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { | 1972 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1995 } | 2002 } |
| 1996 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { | 2003 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { |
| 1997 this->drawBitmapRect(bitmap, dst, paint); | 2004 this->drawBitmapRect(bitmap, dst, paint); |
| 1998 } | 2005 } |
| 1999 this->onDrawBitmapNine(bitmap, center, dst, paint); | 2006 this->onDrawBitmapNine(bitmap, center, dst, paint); |
| 2000 } | 2007 } |
| 2001 | 2008 |
| 2002 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[], | 2009 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[], |
| 2003 const SkColor colors[], int count, SkXfermode::Mode mod e, | 2010 const SkColor colors[], int count, SkXfermode::Mode mod e, |
| 2004 const SkRect* cull, const SkPaint* paint) { | 2011 const SkRect* cull, const SkPaint* paint) { |
| 2012 return_on_null(atlas); | |
| 2005 if (count <= 0) { | 2013 if (count <= 0) { |
| 2006 return; | 2014 return; |
| 2007 } | 2015 } |
| 2008 SkASSERT(atlas); | 2016 SkASSERT(atlas); |
| 2009 SkASSERT(xform); | 2017 SkASSERT(xform); |
| 2010 SkASSERT(tex); | 2018 SkASSERT(tex); |
| 2011 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); | 2019 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); |
| 2012 } | 2020 } |
| 2013 | 2021 |
| 2014 void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, con st SkRect& dst, | 2022 void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, con st SkRect& dst, |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2637 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPosTextH()"); | 2645 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPosTextH()"); |
| 2638 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); | 2646 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); |
| 2639 } | 2647 } |
| 2640 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, | 2648 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 2641 const SkMatrix* matrix, const SkPaint& paint) { | 2649 const SkMatrix* matrix, const SkPaint& paint) { |
| 2642 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextOnPath()"); | 2650 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextOnPath()"); |
| 2643 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); | 2651 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); |
| 2644 } | 2652 } |
| 2645 void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 2653 void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 2646 const SkPaint& paint) { | 2654 const SkPaint& paint) { |
| 2655 return_on_null(blob); | |
| 2647 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextBlob()"); | 2656 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawTextBlob()"); |
| 2648 if (blob) { | 2657 this->onDrawTextBlob(blob, x, y, paint); |
| 2649 this->onDrawTextBlob(blob, x, y, paint); | |
| 2650 } | |
| 2651 } | 2658 } |
| 2652 | 2659 |
| 2653 void SkCanvas::onDrawVertices(VertexMode vmode, int vertexCount, | 2660 void SkCanvas::onDrawVertices(VertexMode vmode, int vertexCount, |
| 2654 const SkPoint verts[], const SkPoint texs[], | 2661 const SkPoint verts[], const SkPoint texs[], |
| 2655 const SkColor colors[], SkXfermode* xmode, | 2662 const SkColor colors[], SkXfermode* xmode, |
| 2656 const uint16_t indices[], int indexCount, | 2663 const uint16_t indices[], int indexCount, |
| 2657 const SkPaint& paint) { | 2664 const SkPaint& paint) { |
| 2658 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()"); | 2665 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()"); |
| 2659 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr) | 2666 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr) |
| 2660 | 2667 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2691 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr) | 2698 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr) |
| 2692 | 2699 |
| 2693 while (iter.next()) { | 2700 while (iter.next()) { |
| 2694 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); | 2701 iter.fDevice->drawPatch(iter, cubics, colors, texCoords, xmode, paint); |
| 2695 } | 2702 } |
| 2696 | 2703 |
| 2697 LOOPER_END | 2704 LOOPER_END |
| 2698 } | 2705 } |
| 2699 | 2706 |
| 2700 void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) { | 2707 void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) { |
| 2701 if (dr) { | 2708 return_on_null(dr); |
| 2702 if (x || y) { | 2709 if (x || y) { |
| 2703 SkMatrix matrix = SkMatrix::MakeTrans(x, y); | 2710 SkMatrix matrix = SkMatrix::MakeTrans(x, y); |
| 2704 this->onDrawDrawable(dr, &matrix); | 2711 this->onDrawDrawable(dr, &matrix); |
| 2705 } else { | 2712 } else { |
| 2706 this->onDrawDrawable(dr, nullptr); | 2713 this->onDrawDrawable(dr, nullptr); |
| 2707 } | |
| 2708 } | 2714 } |
| 2709 } | 2715 } |
| 2710 | 2716 |
| 2711 void SkCanvas::drawDrawable(SkDrawable* dr, const SkMatrix* matrix) { | 2717 void SkCanvas::drawDrawable(SkDrawable* dr, const SkMatrix* matrix) { |
| 2712 if (dr) { | 2718 return_on_null(dr); |
| 2713 if (matrix && matrix->isIdentity()) { | 2719 if (matrix && matrix->isIdentity()) { |
| 2714 matrix = nullptr; | 2720 matrix = nullptr; |
| 2715 } | |
| 2716 this->onDrawDrawable(dr, matrix); | |
| 2717 } | 2721 } |
| 2722 this->onDrawDrawable(dr, matrix); | |
| 2718 } | 2723 } |
| 2719 | 2724 |
| 2720 void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) { | 2725 void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) { |
| 2721 SkRect bounds = dr->getBounds(); | 2726 SkRect bounds = dr->getBounds(); |
| 2722 if (matrix) { | 2727 if (matrix) { |
| 2723 matrix->mapRect(&bounds); | 2728 matrix->mapRect(&bounds); |
| 2724 } | 2729 } |
| 2725 if (this->quickReject(bounds)) { | 2730 if (this->quickReject(bounds)) { |
| 2726 return; | 2731 return; |
| 2727 } | 2732 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2877 /** | 2882 /** |
| 2878 * This constant is trying to balance the speed of ref'ing a subpicture into a parent picture, | 2883 * This constant is trying to balance the speed of ref'ing a subpicture into a parent picture, |
| 2879 * against the playback cost of recursing into the subpicture to get at its act ual ops. | 2884 * against the playback cost of recursing into the subpicture to get at its act ual ops. |
| 2880 * | 2885 * |
| 2881 * For now we pick a conservatively small value, though measurement (and other heuristics like | 2886 * For now we pick a conservatively small value, though measurement (and other heuristics like |
| 2882 * the type of ops contained) may justify changing this value. | 2887 * the type of ops contained) may justify changing this value. |
| 2883 */ | 2888 */ |
| 2884 #define kMaxPictureOpsToUnrollInsteadOfRef 1 | 2889 #define kMaxPictureOpsToUnrollInsteadOfRef 1 |
| 2885 | 2890 |
| 2886 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) { | 2891 void SkCanvas::drawPicture(const SkPicture* picture, const SkMatrix* matrix, con st SkPaint* paint) { |
| 2892 return_on_null(picture); | |
| 2893 | |
| 2887 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()"); | 2894 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawPicture()"); |
| 2888 if (picture) { | 2895 if (matrix && matrix->isIdentity()) { |
| 2889 if (matrix && matrix->isIdentity()) { | 2896 matrix = nullptr; |
| 2890 matrix = nullptr; | 2897 } |
| 2891 } | 2898 if (picture->approximateOpCount() <= kMaxPictureOpsToUnrollInsteadOfRef) { |
| 2892 if (picture->approximateOpCount() <= kMaxPictureOpsToUnrollInsteadOfRef) { | 2899 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); |
| 2893 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect( )); | 2900 picture->playback(this); |
| 2894 picture->playback(this); | 2901 } else { |
| 2895 } else { | 2902 this->onDrawPicture(picture, matrix, paint); |
| 2896 this->onDrawPicture(picture, matrix, paint); | |
| 2897 } | |
| 2898 } | 2903 } |
| 2899 } | 2904 } |
| 2900 | 2905 |
| 2901 void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, | 2906 void SkCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
| 2902 const SkPaint* paint) { | 2907 const SkPaint* paint) { |
| 2903 if (!paint || paint->canComputeFastBounds()) { | 2908 if (!paint || paint->canComputeFastBounds()) { |
| 2904 SkRect bounds = picture->cullRect(); | 2909 SkRect bounds = picture->cullRect(); |
| 2905 if (paint) { | 2910 if (paint) { |
| 2906 paint->computeFastBounds(bounds, &bounds); | 2911 paint->computeFastBounds(bounds, &bounds); |
| 2907 } | 2912 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3023 } | 3028 } |
| 3024 | 3029 |
| 3025 if (matrix) { | 3030 if (matrix) { |
| 3026 canvas->concat(*matrix); | 3031 canvas->concat(*matrix); |
| 3027 } | 3032 } |
| 3028 } | 3033 } |
| 3029 | 3034 |
| 3030 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3035 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3031 fCanvas->restoreToCount(fSaveCount); | 3036 fCanvas->restoreToCount(fSaveCount); |
| 3032 } | 3037 } |
| OLD | NEW |