OLD | NEW |
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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl
ags) { | 1133 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl
ags) { |
1134 if (gIgnoreSaveLayerBounds) { | 1134 if (gIgnoreSaveLayerBounds) { |
1135 bounds = nullptr; | 1135 bounds = nullptr; |
1136 } | 1136 } |
1137 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); | 1137 SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); |
1138 fSaveCount += 1; | 1138 fSaveCount += 1; |
1139 this->internalSaveLayer(bounds, paint, flags, strategy); | 1139 this->internalSaveLayer(bounds, paint, flags, strategy); |
1140 return this->getSaveCount() - 1; | 1140 return this->getSaveCount() - 1; |
1141 } | 1141 } |
1142 | 1142 |
| 1143 int SkCanvas::saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPai
nt* paint) { |
| 1144 unsigned flags = kARGB_ClipLayer_SaveFlag | kPreserveLCDText_PrivateSaveFlag
; |
| 1145 return this->saveLayer(bounds, paint, (SaveFlags)flags); |
| 1146 } |
| 1147 |
| 1148 |
1143 void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
eFlags flags, | 1149 void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
eFlags flags, |
1144 SaveLayerStrategy strategy) { | 1150 SaveLayerStrategy strategy) { |
1145 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 1151 #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
1146 flags |= kClipToLayer_SaveFlag; | 1152 flags |= kClipToLayer_SaveFlag; |
1147 #endif | 1153 #endif |
1148 | 1154 |
1149 // do this before we create the layer. We don't call the public save() since | 1155 // do this before we create the layer. We don't call the public save() since |
1150 // that would invoke a possibly overridden virtual | 1156 // that would invoke a possibly overridden virtual |
1151 this->internalSave(); | 1157 this->internalSave(); |
1152 | 1158 |
(...skipping 23 matching lines...) Expand all Loading... |
1176 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 1182 isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
1177 | 1183 |
1178 SkBaseDevice* device = this->getTopDevice(); | 1184 SkBaseDevice* device = this->getTopDevice(); |
1179 if (nullptr == device) { | 1185 if (nullptr == device) { |
1180 SkDebugf("Unable to find device for layer."); | 1186 SkDebugf("Unable to find device for layer."); |
1181 return; | 1187 return; |
1182 } | 1188 } |
1183 | 1189 |
1184 bool forceSpriteOnRestore = false; | 1190 bool forceSpriteOnRestore = false; |
1185 { | 1191 { |
| 1192 const bool preserveLCDText = kOpaque_SkAlphaType == info.alphaType() || |
| 1193 SkToBool(flags & kPreserveLCDText_PrivateSa
veFlag); |
1186 const SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; | 1194 const SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; |
1187 const SkBaseDevice::CreateInfo createInfo = SkBaseDevice::CreateInfo(inf
o, usage, geo); | 1195 const SkBaseDevice::CreateInfo createInfo = SkBaseDevice::CreateInfo(inf
o, usage, geo, |
| 1196 pres
erveLCDText, false); |
1188 SkBaseDevice* newDev = device->onCreateDevice(createInfo, paint); | 1197 SkBaseDevice* newDev = device->onCreateDevice(createInfo, paint); |
1189 if (nullptr == newDev) { | 1198 if (nullptr == newDev) { |
1190 // If onCreateDevice didn't succeed, try raster (e.g. PDF couldn't h
andle the paint) | 1199 // If onCreateDevice didn't succeed, try raster (e.g. PDF couldn't h
andle the paint) |
1191 const SkSurfaceProps surfaceProps(fProps.flags(), createInfo.fPixelG
eometry); | 1200 const SkSurfaceProps surfaceProps(fProps.flags(), createInfo.fPixelG
eometry); |
1192 newDev = SkBitmapDevice::Create(createInfo.fInfo, surfaceProps); | 1201 newDev = SkBitmapDevice::Create(createInfo.fInfo, surfaceProps); |
1193 if (nullptr == newDev) { | 1202 if (nullptr == newDev) { |
1194 SkErrorInternals::SetError(kInternalError_SkError, | 1203 SkErrorInternals::SetError(kInternalError_SkError, |
1195 "Unable to create device for layer.")
; | 1204 "Unable to create device for layer.")
; |
1196 return; | 1205 return; |
1197 } | 1206 } |
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3004 } | 3013 } |
3005 | 3014 |
3006 if (matrix) { | 3015 if (matrix) { |
3007 canvas->concat(*matrix); | 3016 canvas->concat(*matrix); |
3008 } | 3017 } |
3009 } | 3018 } |
3010 | 3019 |
3011 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3020 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3012 fCanvas->restoreToCount(fSaveCount); | 3021 fCanvas->restoreToCount(fSaveCount); |
3013 } | 3022 } |
OLD | NEW |