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

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

Issue 806853005: add private flag for sprite-as-bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years 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 | « include/core/SkCanvas.h ('k') | no next file » | 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 2008 The Android Open Source Project 2 * Copyright 2008 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkCanvasDrawable.h" 9 #include "SkCanvasDrawable.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 24 matching lines...) Expand all
35 #endif 35 #endif
36 36
37 static bool gIgnoreSaveLayerBounds; 37 static bool gIgnoreSaveLayerBounds;
38 void SkCanvas::Internal_Private_SetIgnoreSaveLayerBounds(bool ignore) { 38 void SkCanvas::Internal_Private_SetIgnoreSaveLayerBounds(bool ignore) {
39 gIgnoreSaveLayerBounds = ignore; 39 gIgnoreSaveLayerBounds = ignore;
40 } 40 }
41 bool SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds() { 41 bool SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds() {
42 return gIgnoreSaveLayerBounds; 42 return gIgnoreSaveLayerBounds;
43 } 43 }
44 44
45 static bool gTreatSpriteAsBitmap;
46 void SkCanvas::Internal_Private_SetTreatSpriteAsBitmap(bool spriteAsBitmap) {
47 gTreatSpriteAsBitmap = spriteAsBitmap;
48 }
49 bool SkCanvas::Internal_Private_GetTreatSpriteAsBitmap() {
50 return gTreatSpriteAsBitmap;
51 }
52
45 // experimental for faster tiled drawing... 53 // experimental for faster tiled drawing...
46 //#define SK_ENABLE_CLIP_QUICKREJECT 54 //#define SK_ENABLE_CLIP_QUICKREJECT
47 55
48 //#define SK_TRACE_SAVERESTORE 56 //#define SK_TRACE_SAVERESTORE
49 57
50 #ifdef SK_TRACE_SAVERESTORE 58 #ifdef SK_TRACE_SAVERESTORE
51 static int gLayerCounter; 59 static int gLayerCounter;
52 static void inc_layer() { ++gLayerCounter; printf("----- inc layer %d\n", gL ayerCounter); } 60 static void inc_layer() { ++gLayerCounter; printf("----- inc layer %d\n", gL ayerCounter); }
53 static void dec_layer() { --gLayerCounter; printf("----- dec layer %d\n", gL ayerCounter); } 61 static void dec_layer() { --gLayerCounter; printf("----- dec layer %d\n", gL ayerCounter); }
54 62
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 } 1191 }
1184 } else { 1192 } else {
1185 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint); 1193 dstDev->drawDevice(iter, srcDev, pos.x(), pos.y(), *paint);
1186 } 1194 }
1187 } 1195 }
1188 LOOPER_END 1196 LOOPER_END
1189 } 1197 }
1190 1198
1191 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, 1199 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
1192 const SkPaint* paint) { 1200 const SkPaint* paint) {
1201 if (gTreatSpriteAsBitmap) {
1202 this->save();
1203 this->resetMatrix();
1204 this->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), paint);
1205 this->restore();
1206 return;
1207 }
1208
1193 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawSprite()"); 1209 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawSprite()");
1194 if (bitmap.drawsNothing()) { 1210 if (bitmap.drawsNothing()) {
1195 return; 1211 return;
1196 } 1212 }
1197 SkDEBUGCODE(bitmap.validate();) 1213 SkDEBUGCODE(bitmap.validate();)
1198 1214
1199 SkPaint tmp; 1215 SkPaint tmp;
1200 if (NULL == paint) { 1216 if (NULL == paint) {
1201 paint = &tmp; 1217 paint = &tmp;
1202 } 1218 }
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 } 2521 }
2506 2522
2507 if (matrix) { 2523 if (matrix) {
2508 canvas->concat(*matrix); 2524 canvas->concat(*matrix);
2509 } 2525 }
2510 } 2526 }
2511 2527
2512 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2528 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2513 fCanvas->restoreToCount(fSaveCount); 2529 fCanvas->restoreToCount(fSaveCount);
2514 } 2530 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698