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

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

Issue 1648773002: SaveFlags begone! (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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
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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 fClipStack->clipDevRect(ir, SkRegion::kReplace_Op); 1108 fClipStack->clipDevRect(ir, SkRegion::kReplace_Op);
1109 fMCRec->fRasterClip.setRect(ir); 1109 fMCRec->fRasterClip.setRect(ir);
1110 } 1110 }
1111 1111
1112 if (intersection) { 1112 if (intersection) {
1113 *intersection = ir; 1113 *intersection = ir;
1114 } 1114 }
1115 return true; 1115 return true;
1116 } 1116 }
1117 1117
1118 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
1119 uint32_t SkCanvas::SaveFlagsToSaveLayerFlags(SaveFlags flags) {
1120 uint32_t layerFlags = 0;
1121
1122 if (0 == (flags & kClipToLayer_SaveFlag)) {
1123 layerFlags |= kDontClipToLayer_PrivateSaveLayerFlag;
1124 }
1125 if (0 == (flags & kHasAlphaLayer_SaveFlag)) {
1126 layerFlags |= kIsOpaque_SaveLayerFlag;
1127 }
1128 return layerFlags;
1129 }
1130
1131 uint32_t SkCanvas::SaveLayerFlagsToSaveFlags(SaveLayerFlags layerFlags) {
1132 uint32_t saveFlags = 0;
1133
1134 if (0 == (layerFlags & kDontClipToLayer_PrivateSaveLayerFlag)) {
1135 saveFlags |= kClipToLayer_SaveFlag;
1136 }
1137 if (0 == (layerFlags & kIsOpaque_SaveLayerFlag)) {
1138 saveFlags |= kHasAlphaLayer_SaveFlag;
1139 }
1140 return saveFlags;
1141 }
1142 #endif
1143 1118
1144 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { 1119 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) {
1145 return this->saveLayer(SaveLayerRec(bounds, paint, 0)); 1120 return this->saveLayer(SaveLayerRec(bounds, paint, 0));
1146 } 1121 }
1147 1122
1148 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
1149 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl ags) {
1150 return this->saveLayer(SaveLayerRec(bounds, paint, SaveFlagsToSaveLayerFlags (flags)));
1151 }
1152 #endif
1153
1154 int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPai nt* paint) { 1123 int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPai nt* paint) {
1155 return this->saveLayer(SaveLayerRec(bounds, paint, kPreserveLCDText_SaveLaye rFlag)); 1124 return this->saveLayer(SaveLayerRec(bounds, paint, kPreserveLCDText_SaveLaye rFlag));
1156 } 1125 }
1157 1126
1158 int SkCanvas::saveLayer(const SaveLayerRec& origRec) { 1127 int SkCanvas::saveLayer(const SaveLayerRec& origRec) {
1159 SaveLayerRec rec(origRec); 1128 SaveLayerRec rec(origRec);
1160 if (gIgnoreSaveLayerBounds) { 1129 if (gIgnoreSaveLayerBounds) {
1161 rec.fBounds = nullptr; 1130 rec.fBounds = nullptr;
1162 } 1131 }
1163 SaveLayerStrategy strategy = this->getSaveLayerStrategy(rec); 1132 SaveLayerStrategy strategy = this->getSaveLayerStrategy(rec);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) { 1252 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) {
1284 if (0xFF == alpha) { 1253 if (0xFF == alpha) {
1285 return this->saveLayer(bounds, nullptr); 1254 return this->saveLayer(bounds, nullptr);
1286 } else { 1255 } else {
1287 SkPaint tmpPaint; 1256 SkPaint tmpPaint;
1288 tmpPaint.setAlpha(alpha); 1257 tmpPaint.setAlpha(alpha);
1289 return this->saveLayer(bounds, &tmpPaint); 1258 return this->saveLayer(bounds, &tmpPaint);
1290 } 1259 }
1291 } 1260 }
1292 1261
1293 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
1294 int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
1295 SaveFlags flags) {
1296 if (0xFF == alpha) {
1297 return this->saveLayer(bounds, nullptr, flags);
1298 } else {
1299 SkPaint tmpPaint;
1300 tmpPaint.setAlpha(alpha);
1301 return this->saveLayer(bounds, &tmpPaint, flags);
1302 }
1303 }
1304 #endif
1305
1306 void SkCanvas::internalRestore() { 1262 void SkCanvas::internalRestore() {
1307 SkASSERT(fMCStack.count() != 0); 1263 SkASSERT(fMCStack.count() != 0);
1308 1264
1309 fDeviceCMDirty = true; 1265 fDeviceCMDirty = true;
1310 fCachedLocalClipBoundsDirty = true; 1266 fCachedLocalClipBoundsDirty = true;
1311 1267
1312 fClipStack->restore(); 1268 fClipStack->restore();
1313 1269
1314 // reserve our layer (if any) 1270 // reserve our layer (if any)
1315 DeviceCM* layer = fMCRec->fLayer; // may be null 1271 DeviceCM* layer = fMCRec->fLayer; // may be null
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
3015 } 2971 }
3016 2972
3017 if (matrix) { 2973 if (matrix) {
3018 canvas->concat(*matrix); 2974 canvas->concat(*matrix);
3019 } 2975 }
3020 } 2976 }
3021 2977
3022 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2978 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3023 fCanvas->restoreToCount(fSaveCount); 2979 fCanvas->restoreToCount(fSaveCount);
3024 } 2980 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698