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

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

Issue 1513513002: try adding flag to allow lcd text even in a layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: hobgoblins Created 5 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/SkDevice.h ('k') | src/core/SkDevice.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 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
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
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
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 }
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698