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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { | 1841 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| 1842 this->onDrawPath(path, paint); | 1842 this->onDrawPath(path, paint); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { | 1845 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) { |
| 1846 this->onDrawImage(image, x, y, paint); | 1846 this->onDrawImage(image, x, y, paint); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 #ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT | |
| 1849 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, | 1850 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, |
| 1850 const SkPaint* paint, SrcRectConstraint constraint) { | 1851 const SkPaint* paint, SrcRectConstraint constraint) { |
| 1851 if (dst.isEmpty()) { | 1852 if (dst.isEmpty()) { |
| 1852 return; | 1853 return; |
| 1853 } | 1854 } |
| 1854 this->onDrawImageRect(image, src, dst, paint, constraint); | 1855 this->onDrawImageRect(image, src, dst, paint, constraint); |
| 1855 } | 1856 } |
| 1857 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const S kRect& dst, | |
| 1858 const SkPaint* paint, SrcRectConstraint constraint ) { | |
| 1859 if (bitmap.drawsNothing() || dst.isEmpty()) { | |
| 1860 return; | |
| 1861 } | |
| 1862 this->onDrawBitmapRect(bitmap, src, dst, paint, constraint); | |
| 1863 } | |
| 1864 #endif | |
| 1865 | |
| 1866 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRe ct& dst, | |
| 1867 const SkPaint* paint, SrcRectConstraint constraint) { | |
| 1868 if (dst.isEmpty() || src.isEmpty()) { | |
| 1869 return; | |
| 1870 } | |
| 1871 this->onDrawImageRect(image, &src, dst, paint, constraint); | |
| 1872 } | |
| 1856 | 1873 |
| 1857 void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const Sk Rect& dst, | 1874 void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const Sk Rect& dst, |
| 1858 const SkPaint* paint, SrcRectConstraint constraint) { | 1875 const SkPaint* paint, SrcRectConstraint constraint) { |
| 1859 SkRect src = SkRect::Make(isrc); | 1876 this->drawImageRect(image, SkRect::Make(isrc), dst, paint, constraint); |
| 1860 this->drawImageRect(image, &src, dst, paint, constraint); | |
| 1861 } | 1877 } |
| 1862 | 1878 |
| 1879 #ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT | |
| 1880 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa int* paint) { | |
| 1881 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint); | |
| 1882 } | |
| 1883 #else | |
| 1884 void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPa int* paint, | |
| 1885 SrcRectConstraint constraint) { | |
| 1886 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint, | |
| 1887 constraint); | |
| 1888 } | |
| 1889 #endif | |
| 1890 | |
| 1863 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, | 1891 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, |
| 1864 const SkPaint* paint) { | 1892 const SkPaint* paint) { |
| 1865 if (dst.isEmpty()) { | 1893 if (dst.isEmpty()) { |
| 1866 return; | 1894 return; |
| 1867 } | 1895 } |
| 1868 if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) { | 1896 if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) { |
| 1869 this->drawImageRect(image, NULL, dst, paint); | 1897 this->drawImageRect(image, dst, paint); |
| 1870 } | 1898 } |
| 1871 this->onDrawImageNine(image, center, dst, paint); | 1899 this->onDrawImageNine(image, center, dst, paint); |
| 1872 } | 1900 } |
| 1873 | 1901 |
| 1874 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { | 1902 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { |
| 1875 if (bitmap.drawsNothing()) { | 1903 if (bitmap.drawsNothing()) { |
| 1876 return; | 1904 return; |
| 1877 } | 1905 } |
| 1878 this->onDrawBitmap(bitmap, dx, dy, paint); | 1906 this->onDrawBitmap(bitmap, dx, dy, paint); |
| 1879 } | 1907 } |
| 1880 | 1908 |
| 1881 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const S kRect& dst, | 1909 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const S kRect& dst, |
| 1882 const SkPaint* paint, SrcRectConstraint constraint ) { | 1910 const SkPaint* paint, SrcRectConstraint constraint ) { |
| 1883 if (bitmap.drawsNothing() || dst.isEmpty()) { | 1911 if (bitmap.drawsNothing() || dst.isEmpty() || src.isEmpty()) { |
| 1884 return; | 1912 return; |
| 1885 } | 1913 } |
|
robertphillips
2015/08/06 17:23:00
We don't want to change onDrawBitmapRect too?
| |
| 1886 this->onDrawBitmapRect(bitmap, src, dst, paint, constraint); | 1914 this->onDrawBitmapRect(bitmap, &src, dst, paint, constraint); |
| 1887 } | 1915 } |
| 1888 | 1916 |
| 1889 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst, | 1917 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst, |
| 1890 const SkPaint* paint, SrcRectConstraint constraint ) { | 1918 const SkPaint* paint, SrcRectConstraint constraint ) { |
| 1891 SkRect src = SkRect::Make(isrc); | 1919 this->drawBitmapRect(bitmap, SkRect::Make(isrc), dst, paint, constraint); |
| 1892 this->drawBitmapRect(bitmap, &src, dst, paint, constraint); | |
| 1893 } | 1920 } |
| 1894 | 1921 |
| 1922 #ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT | |
| 1923 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const S kPaint* paint) { | |
| 1924 this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height() ), dst, paint); | |
| 1925 } | |
| 1926 #else | |
| 1927 void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const S kPaint* paint, | |
| 1928 SrcRectConstraint constraint) { | |
| 1929 this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height() ), dst, paint, | |
| 1930 constraint); | |
| 1931 } | |
| 1932 #endif | |
| 1933 | |
| 1895 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con st SkRect& dst, | 1934 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con st SkRect& dst, |
| 1896 const SkPaint* paint) { | 1935 const SkPaint* paint) { |
| 1897 if (bitmap.drawsNothing() || dst.isEmpty()) { | 1936 if (bitmap.drawsNothing() || dst.isEmpty()) { |
| 1898 return; | 1937 return; |
| 1899 } | 1938 } |
| 1900 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { | 1939 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { |
| 1901 this->drawBitmapRect(bitmap, dst, paint); | 1940 this->drawBitmapRect(bitmap, dst, paint); |
| 1902 } | 1941 } |
| 1903 this->onDrawBitmapNine(bitmap, center, dst, paint); | 1942 this->onDrawBitmapNine(bitmap, center, dst, paint); |
| 1904 } | 1943 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1915 const SkRect* cull, const SkPaint* paint) { | 1954 const SkRect* cull, const SkPaint* paint) { |
| 1916 if (count <= 0) { | 1955 if (count <= 0) { |
| 1917 return; | 1956 return; |
| 1918 } | 1957 } |
| 1919 SkASSERT(atlas); | 1958 SkASSERT(atlas); |
| 1920 SkASSERT(xform); | 1959 SkASSERT(xform); |
| 1921 SkASSERT(tex); | 1960 SkASSERT(tex); |
| 1922 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); | 1961 this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); |
| 1923 } | 1962 } |
| 1924 | 1963 |
| 1964 void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, con st SkRect& dst, | |
| 1965 const SkPaint* paint, SrcRectConstraint cons traint) { | |
| 1966 if (src) { | |
| 1967 this->drawImageRect(image, *src, dst, paint, constraint); | |
| 1968 } else { | |
| 1969 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height ()), | |
| 1970 dst, paint, constraint); | |
| 1971 } | |
| 1972 } | |
| 1973 void SkCanvas::legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, | |
| 1974 const SkPaint* paint, SrcRectConstraint con straint) { | |
| 1975 if (src) { | |
| 1976 this->drawBitmapRect(bitmap, *src, dst, paint, constraint); | |
| 1977 } else { | |
| 1978 this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.heig ht()), | |
| 1979 dst, paint, constraint); | |
| 1980 } | |
| 1981 } | |
| 1982 | |
| 1925 ////////////////////////////////////////////////////////////////////////////// | 1983 ////////////////////////////////////////////////////////////////////////////// |
| 1926 // These are the virtual drawing methods | 1984 // These are the virtual drawing methods |
| 1927 ////////////////////////////////////////////////////////////////////////////// | 1985 ////////////////////////////////////////////////////////////////////////////// |
| 1928 | 1986 |
| 1929 void SkCanvas::onDiscard() { | 1987 void SkCanvas::onDiscard() { |
| 1930 if (fSurfaceBase) { | 1988 if (fSurfaceBase) { |
| 1931 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); | 1989 fSurfaceBase->aboutToDraw(SkSurface::kDiscard_ContentChangeMode); |
| 1932 } | 1990 } |
| 1933 } | 1991 } |
| 1934 | 1992 |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2855 } | 2913 } |
| 2856 | 2914 |
| 2857 if (matrix) { | 2915 if (matrix) { |
| 2858 canvas->concat(*matrix); | 2916 canvas->concat(*matrix); |
| 2859 } | 2917 } |
| 2860 } | 2918 } |
| 2861 | 2919 |
| 2862 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2920 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2863 fCanvas->restoreToCount(fSaveCount); | 2921 fCanvas->restoreToCount(fSaveCount); |
| 2864 } | 2922 } |
| OLD | NEW |