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

Unified Diff: src/core/SkDraw.cpp

Issue 306013010: allow subpixel positioning w/ bitmap filtering Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 6 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/SkBitmapProcState_matrixProcs.cpp ('k') | src/core/SkMatrix.cpp » ('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 84899789cfcbf92e42b10caaeeef5bf0c10163bc..2c0f989a4b2bdb7511597c7a0f307daa6f6564cd 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1107,17 +1107,28 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
/** For the purposes of drawing bitmaps, if a matrix is "almost" translate
go ahead and treat it as if it were, so that subsequent code can go fast.
*/
-static bool just_translate(const SkMatrix& matrix, const SkBitmap& bitmap) {
- unsigned bits = 0; // TODO: find a way to allow the caller to tell us to
- // respect filtering.
- return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits);
+static bool just_translate(const SkMatrix& ctm, const SkBitmap& bm, SkPaint::FilterLevel filter) {
+ unsigned bits = 0;
+ switch (filter) {
+ case SkPaint::kNone_FilterLevel:
+ bits = 0;
+ break;
+ case SkPaint::kLow_FilterLevel:
+ case SkPaint::kMedium_FilterLevel:
+ bits = 4;
+ break;
+ case SkPaint::kHigh_FilterLevel:
+ bits = 4;
+ break;
+ }
+ return SkTreatAsSprite(ctm, bm.width(), bm.height(), bits);
}
void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
const SkPaint& paint) const {
SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
- if (just_translate(*fMatrix, bitmap)) {
+ if (just_translate(*fMatrix, bitmap, paint.getFilterLevel())) {
int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
@@ -1236,7 +1247,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
return;
}
- if (bitmap.colorType() != kAlpha_8_SkColorType && just_translate(matrix, bitmap)) {
+ if (bitmap.colorType() != kAlpha_8_SkColorType && just_translate(matrix, bitmap,
+ paint.getFilterLevel())) {
//
// It is safe to call lock pixels now, since we know the matrix is
// (more or less) identity.
« no previous file with comments | « src/core/SkBitmapProcState_matrixProcs.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698