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

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

Issue 1569873003: Revert of SkTreatAsSprite should take AA into account (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « src/core/SkCanvas.cpp ('k') | src/core/SkMatrix.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 2006 The Android Open Source Project 2 * Copyright 2006 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 #define __STDC_LIMIT_MACROS 7 #define __STDC_LIMIT_MACROS
8 8
9 #include "SkDraw.h" 9 #include "SkDraw.h"
10 #include "SkBlitter.h" 10 #include "SkBlitter.h"
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 SkDEBUGFAIL("unknown paint cap type"); 1165 SkDEBUGFAIL("unknown paint cap type");
1166 } 1166 }
1167 #ifdef SK_SUPPORT_LEGACY_HAIR_IGNORES_CAPS 1167 #ifdef SK_SUPPORT_LEGACY_HAIR_IGNORES_CAPS
1168 proc = SkScan::HairPath; 1168 proc = SkScan::HairPath;
1169 #endif 1169 #endif
1170 } 1170 }
1171 } 1171 }
1172 proc(*devPathPtr, *fRC, blitter); 1172 proc(*devPathPtr, *fRC, blitter);
1173 } 1173 }
1174 1174
1175 /** For the purposes of drawing bitmaps, if a matrix is "almost" translate
1176 go ahead and treat it as if it were, so that subsequent code can go fast.
1177 */
1178 static bool just_translate(const SkMatrix& matrix, const SkBitmap& bitmap) {
1179 unsigned bits = 0; // TODO: find a way to allow the caller to tell us to
1180 // respect filtering.
1181 return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits);
1182 }
1183
1175 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, 1184 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
1176 const SkPaint& paint) const { 1185 const SkPaint& paint) const {
1177 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType); 1186 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
1178 1187
1179 if (SkTreatAsSprite(*fMatrix, bitmap.dimensions(), paint)) { 1188 if (just_translate(*fMatrix, bitmap)) {
1180 int ix = SkScalarRoundToInt(fMatrix->getTranslateX()); 1189 int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
1181 int iy = SkScalarRoundToInt(fMatrix->getTranslateY()); 1190 int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
1182 1191
1183 SkAutoPixmapUnlock result; 1192 SkAutoPixmapUnlock result;
1184 if (!bitmap.requestLock(&result)) { 1193 if (!bitmap.requestLock(&result)) {
1185 return; 1194 return;
1186 } 1195 }
1187 const SkPixmap& pmap = result.pixmap(); 1196 const SkPixmap& pmap = result.pixmap();
1188 SkMask mask; 1197 SkMask mask;
1189 mask.fBounds.set(ix, iy, ix + pmap.width(), iy + pmap.height()); 1198 mask.fBounds.set(ix, iy, ix + pmap.width(), iy + pmap.height());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 SkPaint paint(origPaint); 1293 SkPaint paint(origPaint);
1285 paint.setStyle(SkPaint::kFill_Style); 1294 paint.setStyle(SkPaint::kFill_Style);
1286 1295
1287 SkMatrix matrix; 1296 SkMatrix matrix;
1288 matrix.setConcat(*fMatrix, prematrix); 1297 matrix.setConcat(*fMatrix, prematrix);
1289 1298
1290 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { 1299 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) {
1291 return; 1300 return;
1292 } 1301 }
1293 1302
1294 if (bitmap.colorType() != kAlpha_8_SkColorType 1303 if (bitmap.colorType() != kAlpha_8_SkColorType && just_translate(matrix, bit map)) {
1295 && SkTreatAsSprite(matrix, bitmap.dimensions(), paint)) {
1296 // 1304 //
1297 // It is safe to call lock pixels now, since we know the matrix is 1305 // It is safe to call lock pixels now, since we know the matrix is
1298 // (more or less) identity. 1306 // (more or less) identity.
1299 // 1307 //
1300 SkAutoPixmapUnlock unlocker; 1308 SkAutoPixmapUnlock unlocker;
1301 if (!bitmap.requestLock(&unlocker)) { 1309 if (!bitmap.requestLock(&unlocker)) {
1302 return; 1310 return;
1303 } 1311 }
1304 const SkPixmap& pmap = unlocker.pixmap(); 1312 const SkPixmap& pmap = unlocker.pixmap();
1305 int ix = SkScalarRoundToInt(matrix.getTranslateX()); 1313 int ix = SkScalarRoundToInt(matrix.getTranslateX());
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 mask->fImage = SkMask::AllocImage(size); 2076 mask->fImage = SkMask::AllocImage(size);
2069 memset(mask->fImage, 0, mask->computeImageSize()); 2077 memset(mask->fImage, 0, mask->computeImageSize());
2070 } 2078 }
2071 2079
2072 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2080 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2073 draw_into_mask(*mask, devPath, style); 2081 draw_into_mask(*mask, devPath, style);
2074 } 2082 }
2075 2083
2076 return true; 2084 return true;
2077 } 2085 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698