Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: src/core/SkCanvas.cpp

Issue 1126273002: Revert of Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 const SkPoint texs[], const SkColor colors[], SkXfer mode* xmode, 1727 const SkPoint texs[], const SkColor colors[], SkXfer mode* xmode,
1728 const uint16_t indices[], int indexCount, const SkPa int& paint) { 1728 const uint16_t indices[], int indexCount, const SkPa int& paint) {
1729 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode, 1729 this->onDrawVertices(vmode, vertexCount, vertices, texs, colors, xmode,
1730 indices, indexCount, paint); 1730 indices, indexCount, paint);
1731 } 1731 }
1732 1732
1733 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) { 1733 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
1734 this->onDrawPath(path, paint); 1734 this->onDrawPath(path, paint);
1735 } 1735 }
1736 1736
1737 void SkCanvas::drawImage(const SkImage* image, SkScalar dx, SkScalar dy, const S kPaint* paint) { 1737 void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP aint* paint) {
1738 this->onDrawImage(image, dx, dy, paint); 1738 this->onDrawImage(image, x, y, paint);
1739 } 1739 }
1740 1740
1741 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst, 1741 void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe ct& dst,
1742 const SkPaint* paint) { 1742 const SkPaint* paint) {
1743 if (dst.isEmpty()) {
1744 return;
1745 }
1743 this->onDrawImageRect(image, src, dst, paint); 1746 this->onDrawImageRect(image, src, dst, paint);
1744 } 1747 }
1745 1748
1746 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { 1749 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) {
1747 if (bitmap.empty()) { 1750 if (bitmap.empty()) {
1748 return; 1751 return;
1749 } 1752 }
1750 this->onDrawBitmap(bitmap, dx, dy, paint); 1753 this->onDrawBitmap(bitmap, dx, dy, paint);
1751 } 1754 }
1752 1755
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 1955
1953 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds) 1956 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, bounds)
1954 1957
1955 while (iter.next()) { 1958 while (iter.next()) {
1956 iter.fDevice->drawPath(iter, path, looper.paint()); 1959 iter.fDevice->drawPath(iter, path, looper.paint());
1957 } 1960 }
1958 1961
1959 LOOPER_END 1962 LOOPER_END
1960 } 1963 }
1961 1964
1962 void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const SkPaint* paint) { 1965 void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S kPaint* paint) {
1963 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()"); 1966 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()");
1964 image->draw(this, dx, dy, paint); 1967 SkRect bounds = SkRect::MakeXYWH(x, y,
1968 SkIntToScalar(image->width()), SkIntToScala r(image->height()));
1969 if (NULL == paint || paint->canComputeFastBounds()) {
1970 if (paint) {
1971 paint->computeFastBounds(bounds, &bounds);
1972 }
1973 if (this->quickReject(bounds)) {
1974 return;
1975 }
1976 }
1977
1978 SkLazyPaint lazy;
1979 if (NULL == paint) {
1980 paint = lazy.init();
1981 }
1982
1983 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &bounds)
1984
1985 while (iter.next()) {
1986 iter.fDevice->drawImage(iter, image, x, y, looper.paint());
1987 }
1988
1989 LOOPER_END
1965 } 1990 }
1966 1991
1967 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst, 1992 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst,
1968 const SkPaint* paint) { 1993 const SkPaint* paint) {
1969 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); 1994 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
1970 image->drawRect(this, src, dst, paint); 1995 SkRect storage;
1996 const SkRect* bounds = &dst;
1997 if (NULL == paint || paint->canComputeFastBounds()) {
1998 if (paint) {
1999 bounds = &paint->computeFastBounds(dst, &storage);
2000 }
2001 if (this->quickReject(*bounds)) {
2002 return;
2003 }
2004 }
2005 SkLazyPaint lazy;
2006 if (NULL == paint) {
2007 paint = lazy.init();
2008 }
2009
2010 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, bounds)
2011
2012 while (iter.next()) {
2013 iter.fDevice->drawImageRect(iter, image, src, dst, looper.paint());
2014 }
2015
2016 LOOPER_END
1971 } 2017 }
1972 2018
1973 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) { 2019 void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, cons t SkPaint* paint) {
1974 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()"); 2020 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawBitmap()");
1975 SkDEBUGCODE(bitmap.validate();) 2021 SkDEBUGCODE(bitmap.validate();)
1976 2022
1977 if (NULL == paint || paint->canComputeFastBounds()) { 2023 if (NULL == paint || paint->canComputeFastBounds()) {
1978 SkRect bounds = { 2024 SkRect bounds = {
1979 x, y, 2025 x, y,
1980 x + SkIntToScalar(bitmap.width()), 2026 x + SkIntToScalar(bitmap.width()),
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 } 2687 }
2642 2688
2643 if (matrix) { 2689 if (matrix) {
2644 canvas->concat(*matrix); 2690 canvas->concat(*matrix);
2645 } 2691 }
2646 } 2692 }
2647 2693
2648 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2694 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2649 fCanvas->restoreToCount(fSaveCount); 2695 fCanvas->restoreToCount(fSaveCount);
2650 } 2696 }
OLDNEW
« no previous file with comments | « include/utils/SkDeferredCanvas.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698