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

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

Issue 51033004: add SK_ATTR_DEPRECATED -- will need to disable for chrome, since it triggers a warning (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMipMap.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 7
8 #include "SkDraw.h" 8 #include "SkDraw.h"
9 #include "SkBlitter.h" 9 #include "SkBlitter.h"
10 #include "SkBounder.h" 10 #include "SkBounder.h"
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 go ahead and treat it as if it were, so that subsequent code can go fast. 1149 go ahead and treat it as if it were, so that subsequent code can go fast.
1150 */ 1150 */
1151 static bool just_translate(const SkMatrix& matrix, const SkBitmap& bitmap) { 1151 static bool just_translate(const SkMatrix& matrix, const SkBitmap& bitmap) {
1152 unsigned bits = 0; // TODO: find a way to allow the caller to tell us to 1152 unsigned bits = 0; // TODO: find a way to allow the caller to tell us to
1153 // respect filtering. 1153 // respect filtering.
1154 return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits); 1154 return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits);
1155 } 1155 }
1156 1156
1157 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, 1157 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
1158 const SkPaint& paint) const { 1158 const SkPaint& paint) const {
1159 SkASSERT(bitmap.getConfig() == SkBitmap::kA8_Config); 1159 SkASSERT(bitmap.config() == SkBitmap::kA8_Config);
1160 1160
1161 if (just_translate(*fMatrix, bitmap)) { 1161 if (just_translate(*fMatrix, bitmap)) {
1162 int ix = SkScalarRound(fMatrix->getTranslateX()); 1162 int ix = SkScalarRound(fMatrix->getTranslateX());
1163 int iy = SkScalarRound(fMatrix->getTranslateY()); 1163 int iy = SkScalarRound(fMatrix->getTranslateY());
1164 1164
1165 SkAutoLockPixels alp(bitmap); 1165 SkAutoLockPixels alp(bitmap);
1166 if (!bitmap.readyToDraw()) { 1166 if (!bitmap.readyToDraw()) {
1167 return; 1167 return;
1168 } 1168 }
1169 1169
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 clip.quickContains(x, y, x + bitmap.width(), y + bitmap.height()); 1257 clip.quickContains(x, y, x + bitmap.width(), y + bitmap.height());
1258 } 1258 }
1259 1259
1260 void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix, 1260 void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
1261 const SkPaint& origPaint) const { 1261 const SkPaint& origPaint) const {
1262 SkDEBUGCODE(this->validate();) 1262 SkDEBUGCODE(this->validate();)
1263 1263
1264 // nothing to draw 1264 // nothing to draw
1265 if (fRC->isEmpty() || 1265 if (fRC->isEmpty() ||
1266 bitmap.width() == 0 || bitmap.height() == 0 || 1266 bitmap.width() == 0 || bitmap.height() == 0 ||
1267 bitmap.getConfig() == SkBitmap::kNo_Config) { 1267 bitmap.config() == SkBitmap::kNo_Config) {
1268 return; 1268 return;
1269 } 1269 }
1270 1270
1271 SkPaint paint(origPaint); 1271 SkPaint paint(origPaint);
1272 paint.setStyle(SkPaint::kFill_Style); 1272 paint.setStyle(SkPaint::kFill_Style);
1273 1273
1274 SkMatrix matrix; 1274 SkMatrix matrix;
1275 if (!matrix.setConcat(*fMatrix, prematrix)) { 1275 if (!matrix.setConcat(*fMatrix, prematrix)) {
1276 return; 1276 return;
1277 } 1277 }
1278 1278
1279 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { 1279 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) {
1280 return; 1280 return;
1281 } 1281 }
1282 1282
1283 if (fBounder && just_translate(matrix, bitmap)) { 1283 if (fBounder && just_translate(matrix, bitmap)) {
1284 SkIRect ir; 1284 SkIRect ir;
1285 int32_t ix = SkScalarRound(matrix.getTranslateX()); 1285 int32_t ix = SkScalarRound(matrix.getTranslateX());
1286 int32_t iy = SkScalarRound(matrix.getTranslateY()); 1286 int32_t iy = SkScalarRound(matrix.getTranslateY());
1287 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); 1287 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
1288 if (!fBounder->doIRect(ir)) { 1288 if (!fBounder->doIRect(ir)) {
1289 return; 1289 return;
1290 } 1290 }
1291 } 1291 }
1292 1292
1293 if (bitmap.getConfig() != SkBitmap::kA8_Config && 1293 if (bitmap.config() != SkBitmap::kA8_Config &&
1294 just_translate(matrix, bitmap)) { 1294 just_translate(matrix, bitmap)) {
1295 // 1295 //
1296 // It is safe to call lock pixels now, since we know the matrix is 1296 // It is safe to call lock pixels now, since we know the matrix is
1297 // (more or less) identity. 1297 // (more or less) identity.
1298 // 1298 //
1299 SkAutoLockPixels alp(bitmap); 1299 SkAutoLockPixels alp(bitmap);
1300 if (!bitmap.readyToDraw()) { 1300 if (!bitmap.readyToDraw()) {
1301 return; 1301 return;
1302 } 1302 }
1303 int ix = SkScalarRound(matrix.getTranslateX()); 1303 int ix = SkScalarRound(matrix.getTranslateX());
(...skipping 12 matching lines...) Expand all
1316 return; 1316 return;
1317 } 1317 }
1318 } 1318 }
1319 } 1319 }
1320 1320
1321 // now make a temp draw on the stack, and use it 1321 // now make a temp draw on the stack, and use it
1322 // 1322 //
1323 SkDraw draw(*this); 1323 SkDraw draw(*this);
1324 draw.fMatrix = &matrix; 1324 draw.fMatrix = &matrix;
1325 1325
1326 if (bitmap.getConfig() == SkBitmap::kA8_Config) { 1326 if (bitmap.config() == SkBitmap::kA8_Config) {
1327 draw.drawBitmapAsMask(bitmap, paint); 1327 draw.drawBitmapAsMask(bitmap, paint);
1328 } else { 1328 } else {
1329 SkAutoBitmapShaderInstall install(bitmap, paint); 1329 SkAutoBitmapShaderInstall install(bitmap, paint);
1330 1330
1331 SkRect r; 1331 SkRect r;
1332 r.set(0, 0, SkIntToScalar(bitmap.width()), 1332 r.set(0, 0, SkIntToScalar(bitmap.width()),
1333 SkIntToScalar(bitmap.height())); 1333 SkIntToScalar(bitmap.height()));
1334 // is this ok if paint has a rasterizer? 1334 // is this ok if paint has a rasterizer?
1335 draw.drawRect(r, install.paintWithShader()); 1335 draw.drawRect(r, install.paintWithShader());
1336 } 1336 }
1337 } 1337 }
1338 1338
1339 void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, 1339 void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
1340 const SkPaint& origPaint) const { 1340 const SkPaint& origPaint) const {
1341 SkDEBUGCODE(this->validate();) 1341 SkDEBUGCODE(this->validate();)
1342 1342
1343 // nothing to draw 1343 // nothing to draw
1344 if (fRC->isEmpty() || 1344 if (fRC->isEmpty() ||
1345 bitmap.width() == 0 || bitmap.height() == 0 || 1345 bitmap.width() == 0 || bitmap.height() == 0 ||
1346 bitmap.getConfig() == SkBitmap::kNo_Config) { 1346 bitmap.config() == SkBitmap::kNo_Config) {
1347 return; 1347 return;
1348 } 1348 }
1349 1349
1350 SkIRect bounds; 1350 SkIRect bounds;
1351 bounds.set(x, y, x + bitmap.width(), y + bitmap.height()); 1351 bounds.set(x, y, x + bitmap.width(), y + bitmap.height());
1352 1352
1353 if (fRC->quickReject(bounds)) { 1353 if (fRC->quickReject(bounds)) {
1354 return; // nothing to draw 1354 return; // nothing to draw
1355 } 1355 }
1356 1356
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 mask->fImage = SkMask::AllocImage(size); 2826 mask->fImage = SkMask::AllocImage(size);
2827 memset(mask->fImage, 0, mask->computeImageSize()); 2827 memset(mask->fImage, 0, mask->computeImageSize());
2828 } 2828 }
2829 2829
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { 2830 if (SkMask::kJustComputeBounds_CreateMode != mode) {
2831 draw_into_mask(*mask, devPath, style); 2831 draw_into_mask(*mask, devPath, style);
2832 } 2832 }
2833 2833
2834 return true; 2834 return true;
2835 } 2835 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698