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

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

Issue 719253002: rename filterTextFlags to disableLCD (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rename disableLCD to shouldDisableLCD Created 6 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDeviceImageFilterProxy.h » ('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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 "SkDevice.h" 8 #include "SkDevice.h"
9 #include "SkDeviceProperties.h" 9 #include "SkDeviceProperties.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
11 #include "SkMetaData.h" 11 #include "SkMetaData.h"
12 #include "SkPatchUtils.h" 12 #include "SkPatchUtils.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 #include "SkTextBlob.h" 14 #include "SkTextBlob.h"
15 15
16 SkBaseDevice::SkBaseDevice() 16 SkBaseDevice::SkBaseDevice()
17 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega cyLCD_InitType))) 17 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::kLega cyLCD_InitType)))
18 #ifdef SK_DEBUG 18 #ifdef SK_DEBUG
19 , fAttachedToCanvas(false) 19 , fAttachedToCanvas(false)
20 #endif 20 #endif
21 { 21 {
22 fOrigin.setZero(); 22 fOrigin.setZero();
23 fMetaData = NULL; 23 fMetaData = NULL;
24 } 24 }
25 25
26 SkBaseDevice::SkBaseDevice(const SkDeviceProperties& dp)
27 : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (dp)))
28 #ifdef SK_DEBUG
29 , fAttachedToCanvas(false)
30 #endif
31 {
32 fOrigin.setZero();
33 fMetaData = NULL;
34 }
35
26 SkBaseDevice::~SkBaseDevice() { 36 SkBaseDevice::~SkBaseDevice() {
27 SkDELETE(fLeakyProperties); 37 SkDELETE(fLeakyProperties);
28 SkDELETE(fMetaData); 38 SkDELETE(fMetaData);
29 } 39 }
30 40
31 SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
32 return this->onCreateCompatibleDevice(CreateInfo(info, kGeneral_Usage));
33 }
34
35 SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(const SkImageInfo & info) {
36 return this->onCreateCompatibleDevice(CreateInfo(info, kSaveLayer_Usage));
37 }
38
39 SkBaseDevice* SkBaseDevice::createCompatibleDeviceForImageFilter(const SkImageIn fo& info) {
40 return this->onCreateCompatibleDevice(CreateInfo(info, kImageFilter_Usage));
41 }
42
43 SkMetaData& SkBaseDevice::getMetaData() { 41 SkMetaData& SkBaseDevice::getMetaData() {
44 // metadata users are rare, so we lazily allocate it. If that changes we 42 // metadata users are rare, so we lazily allocate it. If that changes we
45 // can decide to just make it a field in the device (rather than a ptr) 43 // can decide to just make it a field in the device (rather than a ptr)
46 if (NULL == fMetaData) { 44 if (NULL == fMetaData) {
47 fMetaData = new SkMetaData; 45 fMetaData = new SkMetaData;
48 } 46 }
49 return *fMetaData; 47 return *fMetaData;
50 } 48 }
51 49
52 SkImageInfo SkBaseDevice::imageInfo() const { 50 SkImageInfo SkBaseDevice::imageInfo() const {
53 return SkImageInfo::MakeUnknown(); 51 return SkImageInfo::MakeUnknown();
54 } 52 }
55 53
56 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) { 54 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
57 const SkBitmap& bitmap = this->onAccessBitmap(); 55 const SkBitmap& bitmap = this->onAccessBitmap();
58 if (changePixels) { 56 if (changePixels) {
59 bitmap.notifyPixelsChanged(); 57 bitmap.notifyPixelsChanged();
60 } 58 }
61 return bitmap; 59 return bitmap;
62 } 60 }
63 61
64 void SkBaseDevice::setPixelGeometry(SkPixelGeometry geo) { 62 SkPixelGeometry SkBaseDevice::CreateInfo::AdjustGeometry(const SkImageInfo& info ,
65 fLeakyProperties->setPixelGeometry(geo); 63 Usage usage,
64 SkPixelGeometry geo) {
65 switch (usage) {
66 case kGeneral_Usage:
67 break;
68 case kSaveLayer_Usage:
69 if (info.alphaType() != kOpaque_SkAlphaType) {
70 geo = kUnknown_SkPixelGeometry;
71 }
72 break;
73 case kImageFilter_Usage:
74 geo = kUnknown_SkPixelGeometry;
75 break;
76 }
77 return geo;
78 }
79
80 void SkBaseDevice::initForRootLayer(SkPixelGeometry geo) {
81 // For now we don't expect to change the geometry for the root-layer, but we make the call
82 // anyway to document logically what is going on.
83 //
84 fLeakyProperties->setPixelGeometry(CreateInfo::AdjustGeometry(this->imageInf o(),
85 kGeneral_Usage ,
86 geo));
66 } 87 }
67 88
68 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&, const SkSurfaceProps&) { return NULL; } 89 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&, const SkSurfaceProps&) { return NULL; }
69 90
70 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; } 91 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; }
71 92
72 void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, 93 void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
73 const SkRRect& inner, const SkPaint& paint) { 94 const SkRRect& inner, const SkPaint& paint) {
74 SkPath path; 95 SkPath path;
75 path.addRRect(outer); 96 path.addRRect(outer);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 201
181 void* SkBaseDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) { 202 void* SkBaseDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
182 return NULL; 203 return NULL;
183 } 204 }
184 205
185 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*, 206 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*,
186 const SkPaint*) { 207 const SkPaint*) {
187 // The base class doesn't perform any accelerated picture rendering 208 // The base class doesn't perform any accelerated picture rendering
188 return false; 209 return false;
189 } 210 }
211
212 //////////////////////////////////////////////////////////////////////////////// //////////
213
214 bool SkBaseDevice::shouldDisableLCD(const SkPaint& paint) const {
215 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
216 return false;
217 }
218
219 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry()) {
220 return true;
221 }
222
223 return this->onShouldDisableLCD(paint);
224 }
225
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDeviceImageFilterProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698