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

Unified Diff: src/core/SkDraw.cpp

Issue 1156713004: remove bitmaps entirely from sprite blits (as source) (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBlitter_Sprite.cpp ('k') | src/core/SkSpriteBlitter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 918ef765ebbf89d93b3d59086ec19b196aea8c53..918885117cc801321cb4aed61847f0501caa550b 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1242,10 +1242,8 @@ static bool clipped_out(const SkMatrix& matrix, const SkRasterClip& clip,
return clipped_out(matrix, clip, r);
}
-static bool clipHandlesSprite(const SkRasterClip& clip, int x, int y,
- const SkBitmap& bitmap) {
- return clip.isBW() ||
- clip.quickContains(x, y, x + bitmap.width(), y + bitmap.height());
+static bool clipHandlesSprite(const SkRasterClip& clip, int x, int y, const SkPixmap& pmap) {
+ return clip.isBW() || clip.quickContains(x, y, x + pmap.width(), y + pmap.height());
}
void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
@@ -1274,24 +1272,23 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
// It is safe to call lock pixels now, since we know the matrix is
// (more or less) identity.
//
- SkAutoLockPixels alp(bitmap);
- if (!bitmap.readyToDraw()) {
+ SkAutoPixmapUnlock unlocker;
+ if (!bitmap.requestLock(&unlocker)) {
return;
}
+ const SkPixmap& pmap = unlocker.pixmap();
int ix = SkScalarRoundToInt(matrix.getTranslateX());
int iy = SkScalarRoundToInt(matrix.getTranslateY());
- if (clipHandlesSprite(*fRC, ix, iy, bitmap)) {
+ if (clipHandlesSprite(*fRC, ix, iy, pmap)) {
SkTBlitterAllocator allocator;
// blitter will be owned by the allocator.
- SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, bitmap,
- ix, iy, &allocator);
+ SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, pmap, ix, iy, &allocator);
if (blitter) {
- SkIRect ir;
- ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
-
- SkScan::FillIRect(ir, *fRC, blitter);
+ SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.height()),
+ *fRC, blitter);
return;
}
+ // if !blitter, then we fall-through to the slower case
}
}
@@ -1314,8 +1311,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
}
}
-void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
- const SkPaint& origPaint) const {
+void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& origPaint) const {
SkDEBUGCODE(this->validate();)
// nothing to draw
@@ -1325,8 +1321,7 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
return;
}
- SkIRect bounds;
- bounds.set(x, y, x + bitmap.width(), y + bitmap.height());
+ const SkIRect bounds = SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
if (fRC->quickReject(bounds)) {
return; // nothing to draw
@@ -1335,12 +1330,16 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
SkPaint paint(origPaint);
paint.setStyle(SkPaint::kFill_Style);
- if (NULL == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, bitmap)) {
+ SkAutoPixmapUnlock unlocker;
+ if (!bitmap.requestLock(&unlocker)) {
+ return;
+ }
+ const SkPixmap& pmap = unlocker.pixmap();
+
+ if (NULL == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, pmap)) {
SkTBlitterAllocator allocator;
// blitter will be owned by the allocator.
- SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, bitmap,
- x, y, &allocator);
-
+ SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, pmap, x, y, &allocator);
if (blitter) {
SkScan::FillIRect(bounds, *fRC, blitter);
return;
« no previous file with comments | « src/core/SkBlitter_Sprite.cpp ('k') | src/core/SkSpriteBlitter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698