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

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

Issue 1992283002: Add drawBitmapLattice() API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rewrite picture impls Created 4 years, 4 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/private/SkRecords.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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
11 #include "SkClipStack.h" 11 #include "SkClipStack.h"
12 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
13 #include "SkDraw.h" 13 #include "SkDraw.h"
14 #include "SkDrawable.h" 14 #include "SkDrawable.h"
15 #include "SkDrawFilter.h" 15 #include "SkDrawFilter.h"
16 #include "SkDrawLooper.h" 16 #include "SkDrawLooper.h"
17 #include "SkErrorInternals.h" 17 #include "SkErrorInternals.h"
18 #include "SkImage.h" 18 #include "SkImage.h"
19 #include "SkImage_Base.h" 19 #include "SkImage_Base.h"
20 #include "SkImageFilter.h" 20 #include "SkImageFilter.h"
21 #include "SkImageFilterCache.h" 21 #include "SkImageFilterCache.h"
22 #include "SkLatticeIter.h"
22 #include "SkMatrixUtils.h" 23 #include "SkMatrixUtils.h"
23 #include "SkMetaData.h" 24 #include "SkMetaData.h"
24 #include "SkNinePatchIter.h"
25 #include "SkPaintPriv.h" 25 #include "SkPaintPriv.h"
26 #include "SkPatchUtils.h" 26 #include "SkPatchUtils.h"
27 #include "SkPicture.h" 27 #include "SkPicture.h"
28 #include "SkRasterClip.h" 28 #include "SkRasterClip.h"
29 #include "SkReadPixelsRec.h" 29 #include "SkReadPixelsRec.h"
30 #include "SkRRect.h" 30 #include "SkRRect.h"
31 #include "SkSmallAllocator.h" 31 #include "SkSmallAllocator.h"
32 #include "SkSpecialImage.h" 32 #include "SkSpecialImage.h"
33 #include "SkSurface_Base.h" 33 #include "SkSurface_Base.h"
34 #include "SkTextBlob.h" 34 #include "SkTextBlob.h"
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint, 1978 this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint,
1979 constraint); 1979 constraint);
1980 } 1980 }
1981 1981
1982 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst, 1982 void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
1983 const SkPaint* paint) { 1983 const SkPaint* paint) {
1984 RETURN_ON_NULL(image); 1984 RETURN_ON_NULL(image);
1985 if (dst.isEmpty()) { 1985 if (dst.isEmpty()) {
1986 return; 1986 return;
1987 } 1987 }
1988 if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) { 1988 if (!SkLatticeIter::Valid(image->width(), image->height(), center)) {
1989 this->drawImageRect(image, dst, paint); 1989 this->drawImageRect(image, dst, paint);
1990 } 1990 }
1991 this->onDrawImageNine(image, center, dst, paint); 1991 this->onDrawImageNine(image, center, dst, paint);
1992 } 1992 }
1993 1993
1994 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) { 1994 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons t SkPaint* paint) {
1995 if (bitmap.drawsNothing()) { 1995 if (bitmap.drawsNothing()) {
1996 return; 1996 return;
1997 } 1997 }
1998 this->onDrawBitmap(bitmap, dx, dy, paint); 1998 this->onDrawBitmap(bitmap, dx, dy, paint);
(...skipping 16 matching lines...) Expand all
2015 SrcRectConstraint constraint) { 2015 SrcRectConstraint constraint) {
2016 this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height() ), dst, paint, 2016 this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height() ), dst, paint,
2017 constraint); 2017 constraint);
2018 } 2018 }
2019 2019
2020 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con st SkRect& dst, 2020 void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con st SkRect& dst,
2021 const SkPaint* paint) { 2021 const SkPaint* paint) {
2022 if (bitmap.drawsNothing() || dst.isEmpty()) { 2022 if (bitmap.drawsNothing() || dst.isEmpty()) {
2023 return; 2023 return;
2024 } 2024 }
2025 if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) { 2025 if (!SkLatticeIter::Valid(bitmap.width(), bitmap.height(), center)) {
2026 this->drawBitmapRect(bitmap, dst, paint); 2026 this->drawBitmapRect(bitmap, dst, paint);
2027 } 2027 }
2028 this->onDrawBitmapNine(bitmap, center, dst, paint); 2028 this->onDrawBitmapNine(bitmap, center, dst, paint);
2029 } 2029 }
2030 2030
2031 void SkCanvas::drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst,
2032 const SkPaint* paint) {
2033 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
2034 this->drawImageLattice(image.get(), lattice, dst, paint);
2035 }
2036
2037 void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, co nst SkRect& dst,
2038 const SkPaint* paint) {
2039 RETURN_ON_NULL(image);
2040 if (dst.isEmpty()) {
2041 return;
2042 }
2043 if (!SkLatticeIter::Valid(image->width(), image->height(), lattice)) {
2044 this->drawImageRect(image, dst, paint);
2045 }
2046 this->onDrawImageLattice(image, lattice, dst, paint);
2047 }
2048
2031 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[], 2049 void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk Rect tex[],
2032 const SkColor colors[], int count, SkXfermode::Mode mod e, 2050 const SkColor colors[], int count, SkXfermode::Mode mod e,
2033 const SkRect* cull, const SkPaint* paint) { 2051 const SkRect* cull, const SkPaint* paint) {
2034 RETURN_ON_NULL(atlas); 2052 RETURN_ON_NULL(atlas);
2035 if (count <= 0) { 2053 if (count <= 0) {
2036 return; 2054 return;
2037 } 2055 }
2038 SkASSERT(atlas); 2056 SkASSERT(atlas);
2039 SkASSERT(xform); 2057 SkASSERT(xform);
2040 SkASSERT(tex); 2058 SkASSERT(tex);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 SkScalarRoundToInt(pt.fX), 2343 SkScalarRoundToInt(pt.fX),
2326 SkScalarRoundToInt(pt.fY), pnt); 2344 SkScalarRoundToInt(pt.fY), pnt);
2327 } else { 2345 } else {
2328 iter.fDevice->drawImage(iter, image, x, y, pnt); 2346 iter.fDevice->drawImage(iter, image, x, y, pnt);
2329 } 2347 }
2330 } 2348 }
2331 2349
2332 LOOPER_END 2350 LOOPER_END
2333 } 2351 }
2334 2352
2353 void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
2354 const SkPaint* paint) {
2355 if (nullptr == paint || paint->canComputeFastBounds()) {
2356 SkRect storage;
2357 if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) : dst)) {
2358 return;
2359 }
2360 }
2361
2362 SkLazyPaint lazy;
2363 if (nullptr == paint) {
2364 paint = lazy.init();
2365 }
2366
2367 LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
2368
2369 while (iter.next()) {
2370 iter.fDevice->drawImageLattice(iter, image, lattice, dst, looper.paint() );
2371 }
2372
2373 LOOPER_END
2374 }
2375
2335 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst, 2376 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst,
2336 const SkPaint* paint, SrcRectConstraint constrain t) { 2377 const SkPaint* paint, SrcRectConstraint constrain t) {
2337 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); 2378 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
2338 if (nullptr == paint || paint->canComputeFastBounds()) { 2379 if (nullptr == paint || paint->canComputeFastBounds()) {
2339 SkRect storage = dst; 2380 SkRect storage = dst;
2340 if (paint) { 2381 if (paint) {
2341 paint->computeFastBounds(dst, &storage); 2382 paint->computeFastBounds(dst, &storage);
2342 } 2383 }
2343 if (this->quickReject(storage)) { 2384 if (this->quickReject(storage)) {
2344 return; 2385 return;
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 3164
3124 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3165 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3125 fCanvas->restoreToCount(fSaveCount); 3166 fCanvas->restoreToCount(fSaveCount);
3126 } 3167 }
3127 3168
3128 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3169 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3129 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3170 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3130 return this->makeSurface(info, props).release(); 3171 return this->makeSurface(info, props).release();
3131 } 3172 }
3132 #endif 3173 #endif
OLDNEW
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698