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

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

Issue 168653002: Change device factories to take SkImageInfo instead of SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix PdfViewer Created 6 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 | Annotate | Revision Log
« 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 "SkMetaData.h" 9 #include "SkMetaData.h"
10 10
(...skipping 24 matching lines...) Expand all
35 #endif 35 #endif
36 { 36 {
37 fOrigin.setZero(); 37 fOrigin.setZero();
38 fMetaData = NULL; 38 fMetaData = NULL;
39 } 39 }
40 40
41 SkBaseDevice::~SkBaseDevice() { 41 SkBaseDevice::~SkBaseDevice() {
42 delete fMetaData; 42 delete fMetaData;
43 } 43 }
44 44
45 SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
46 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
47 // We call the old method to support older subclasses.
48 // If they have, we return their device, else we use the new impl.
49 SkBitmap::Config config = SkColorTypeToBitmapConfig(info.colorType());
50 SkBaseDevice* dev = this->onCreateCompatibleDevice(config,
51 info.width(),
52 info.height(),
53 info.isOpaque(),
54 kGeneral_Usage);
55 if (dev) {
56 return dev;
57 }
58 // fall through to new impl
59 #endif
60 return this->onCreateDevice(info, kGeneral_Usage);
61 }
62
63 SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(const SkImageInfo & info) {
64 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
65 // We call the old method to support older subclasses.
66 // If they have, we return their device, else we use the new impl.
67 SkBitmap::Config config = SkColorTypeToBitmapConfig(info.colorType());
68 SkBaseDevice* dev = this->onCreateCompatibleDevice(config,
69 info.width(),
70 info.height(),
71 info.isOpaque(),
72 kSaveLayer_Usage);
73 if (dev) {
74 return dev;
75 }
76 // fall through to new impl
77 #endif
78 return this->onCreateDevice(info, kSaveLayer_Usage);
79 }
80
81 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
45 SkBaseDevice* SkBaseDevice::createCompatibleDevice(SkBitmap::Config config, 82 SkBaseDevice* SkBaseDevice::createCompatibleDevice(SkBitmap::Config config,
46 int width, int height, 83 int width, int height,
47 bool isOpaque) { 84 bool isOpaque) {
48 return this->onCreateCompatibleDevice(config, width, height, 85 SkImageInfo info = SkImageInfo::Make(width, height,
49 isOpaque, kGeneral_Usage); 86 SkBitmapConfigToColorType(config),
87 isOpaque ? kOpaque_SkAlphaType
88 : kPremul_SkAlphaType);
89 return this->createCompatibleDevice(info);
50 } 90 }
51 91 #endif
52 SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
53 int width, int he ight,
54 bool isOpaque) {
55 return this->onCreateCompatibleDevice(config, width, height,
56 isOpaque, kSaveLayer_Usage);
57 }
58 92
59 SkMetaData& SkBaseDevice::getMetaData() { 93 SkMetaData& SkBaseDevice::getMetaData() {
60 // metadata users are rare, so we lazily allocate it. If that changes we 94 // metadata users are rare, so we lazily allocate it. If that changes we
61 // can decide to just make it a field in the device (rather than a ptr) 95 // can decide to just make it a field in the device (rather than a ptr)
62 if (NULL == fMetaData) { 96 if (NULL == fMetaData) {
63 fMetaData = new SkMetaData; 97 fMetaData = new SkMetaData;
64 } 98 }
65 return *fMetaData; 99 return *fMetaData;
66 } 100 }
67 101
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 config8888); 152 config8888);
119 if (result && bmp == &tmp) { 153 if (result && bmp == &tmp) {
120 tmp.swap(*bitmap); 154 tmp.swap(*bitmap);
121 } 155 }
122 return result; 156 return result;
123 } 157 }
124 158
125 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; } 159 SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; }
126 160
127 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; } 161 const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; }
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