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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 | 1842 |
1843 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds) | 1843 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds) |
1844 | 1844 |
1845 while (iter.next()) { | 1845 while (iter.next()) { |
1846 iter.fDevice->drawPath(iter, path, looper.paint()); | 1846 iter.fDevice->drawPath(iter, path, looper.paint()); |
1847 } | 1847 } |
1848 | 1848 |
1849 LOOPER_END | 1849 LOOPER_END |
1850 } | 1850 } |
1851 | 1851 |
1852 void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const
SkPaint* paint) { | 1852 void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, |
| 1853 const SkPaint* paint) { |
1853 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()"); | 1854 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()"); |
1854 image->draw(this, dx, dy, paint); | 1855 |
| 1856 SkRect bounds = SkRect::MakeXYWH(dx, dy, image->width(), image->height()); |
| 1857 if (NULL == paint || paint->canComputeFastBounds()) { |
| 1858 if (NULL != paint) { |
| 1859 paint->computeFastBounds(bounds, &bounds); |
| 1860 } |
| 1861 if (this->quickReject(bounds)) { |
| 1862 return; |
| 1863 } |
| 1864 } |
| 1865 |
| 1866 SkLazyPaint lazy; |
| 1867 if (NULL == paint) { |
| 1868 paint = lazy.init(); |
| 1869 } |
| 1870 |
| 1871 LOOPER_BEGIN(*paint, SkDrawFilter::kImage_Type, &bounds) |
| 1872 |
| 1873 while (iter.next()) { |
| 1874 SkPaint p = looper.paint(); |
| 1875 p.setLooper(NULL); |
| 1876 image->draw(this, dx, dy, &p); |
| 1877 } |
| 1878 |
| 1879 LOOPER_END |
1855 } | 1880 } |
1856 | 1881 |
1857 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, | 1882 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
Rect& dst, |
1858 const SkPaint* paint) { | 1883 const SkPaint* paint) { |
1859 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); | 1884 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); |
1860 image->drawRect(this, src, dst, paint); | 1885 SkRect storage; |
| 1886 const SkRect* bounds = &dst; |
| 1887 if (NULL == paint || paint->canComputeFastBounds()) { |
| 1888 if (NULL != paint) { |
| 1889 bounds = &paint->computeFastBounds(dst, &storage); |
| 1890 } |
| 1891 if (this->quickReject(*bounds)) { |
| 1892 return; |
| 1893 } |
| 1894 } |
| 1895 |
| 1896 SkLazyPaint lazy; |
| 1897 if (NULL == paint) { |
| 1898 paint = lazy.init(); |
| 1899 } |
| 1900 |
| 1901 LOOPER_BEGIN(*paint, SkDrawFilter::kImage_Type, bounds) |
| 1902 |
| 1903 while (iter.next()) { |
| 1904 SkPaint p = looper.paint(); |
| 1905 p.setLooper(NULL); |
| 1906 image->drawRect(this, src, dst, &p); |
| 1907 } |
| 1908 |
| 1909 LOOPER_END |
1861 } | 1910 } |
1862 | 1911 |
1863 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { | 1912 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons
t SkPaint* paint) { |
1864 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); | 1913 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); |
1865 SkDEBUGCODE(bitmap.validate();) | 1914 SkDEBUGCODE(bitmap.validate();) |
1866 | 1915 |
1867 if (NULL == paint || paint->canComputeFastBounds()) { | 1916 if (NULL == paint || paint->canComputeFastBounds()) { |
1868 SkRect bounds = { | 1917 SkRect bounds = { |
1869 x, y, | 1918 x, y, |
1870 x + SkIntToScalar(bitmap.width()), | 1919 x + SkIntToScalar(bitmap.width()), |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 } | 2573 } |
2525 | 2574 |
2526 if (matrix) { | 2575 if (matrix) { |
2527 canvas->concat(*matrix); | 2576 canvas->concat(*matrix); |
2528 } | 2577 } |
2529 } | 2578 } |
2530 | 2579 |
2531 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2580 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2532 fCanvas->restoreToCount(fSaveCount); | 2581 fCanvas->restoreToCount(fSaveCount); |
2533 } | 2582 } |
OLD | NEW |