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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index a86cd37cad3b25edd1281a71f7332c331f48a0ea..648059a1965cdbc71c1e6a4eee19931ca6dd9bd1 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -19,9 +19,9 @@
#include "SkImage_Base.h"
#include "SkImageFilter.h"
#include "SkImageFilterCache.h"
+#include "SkLatticeIter.h"
#include "SkMatrixUtils.h"
#include "SkMetaData.h"
-#include "SkNinePatchIter.h"
#include "SkPaintPriv.h"
#include "SkPatchUtils.h"
#include "SkPicture.h"
@@ -1985,7 +1985,7 @@ void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const
if (dst.isEmpty()) {
return;
}
- if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) {
+ if (!SkLatticeIter::Valid(image->width(), image->height(), center)) {
this->drawImageRect(image, dst, paint);
}
this->onDrawImageNine(image, center, dst, paint);
@@ -2022,12 +2022,30 @@ void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, con
if (bitmap.drawsNothing() || dst.isEmpty()) {
return;
}
- if (!SkNinePatchIter::Valid(bitmap.width(), bitmap.height(), center)) {
+ if (!SkLatticeIter::Valid(bitmap.width(), bitmap.height(), center)) {
this->drawBitmapRect(bitmap, dst, paint);
}
this->onDrawBitmapNine(bitmap, center, dst, paint);
}
+void SkCanvas::drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst,
+ const SkPaint* paint) {
+ sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
+ this->drawImageLattice(image.get(), lattice, dst, paint);
+}
+
+void SkCanvas::drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
+ const SkPaint* paint) {
+ RETURN_ON_NULL(image);
+ if (dst.isEmpty()) {
+ return;
+ }
+ if (!SkLatticeIter::Valid(image->width(), image->height(), lattice)) {
+ this->drawImageRect(image, dst, paint);
+ }
+ this->onDrawImageLattice(image, lattice, dst, paint);
+}
+
void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkXfermode::Mode mode,
const SkRect* cull, const SkPaint* paint) {
@@ -2332,6 +2350,29 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
LOOPER_END
}
+void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
+ const SkPaint* paint) {
+ if (nullptr == paint || paint->canComputeFastBounds()) {
+ SkRect storage;
+ if (this->quickReject(paint ? paint->computeFastBounds(dst, &storage) : dst)) {
+ return;
+ }
+ }
+
+ SkLazyPaint lazy;
+ if (nullptr == paint) {
+ paint = lazy.init();
+ }
+
+ LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
+
+ while (iter.next()) {
+ iter.fDevice->drawImageLattice(iter, image, lattice, dst, looper.paint());
+ }
+
+ LOOPER_END
+}
+
void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
« 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