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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDeviceImageFilterProxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 364b106dd8feb023fd8223efdf6e838809a28778..d69e4afab2b6817c3642578247e609fbcf8f18ad 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -42,19 +42,53 @@ SkBaseDevice::~SkBaseDevice() {
delete fMetaData;
}
+SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
+#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
+ // We call the old method to support older subclasses.
+ // If they have, we return their device, else we use the new impl.
+ SkBitmap::Config config = SkColorTypeToBitmapConfig(info.colorType());
+ SkBaseDevice* dev = this->onCreateCompatibleDevice(config,
+ info.width(),
+ info.height(),
+ info.isOpaque(),
+ kGeneral_Usage);
+ if (dev) {
+ return dev;
+ }
+ // fall through to new impl
+#endif
+ return this->onCreateDevice(info, kGeneral_Usage);
+}
+
+SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(const SkImageInfo& info) {
+#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
+ // We call the old method to support older subclasses.
+ // If they have, we return their device, else we use the new impl.
+ SkBitmap::Config config = SkColorTypeToBitmapConfig(info.colorType());
+ SkBaseDevice* dev = this->onCreateCompatibleDevice(config,
+ info.width(),
+ info.height(),
+ info.isOpaque(),
+ kSaveLayer_Usage);
+ if (dev) {
+ return dev;
+ }
+ // fall through to new impl
+#endif
+ return this->onCreateDevice(info, kSaveLayer_Usage);
+}
+
+#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
SkBaseDevice* SkBaseDevice::createCompatibleDevice(SkBitmap::Config config,
int width, int height,
bool isOpaque) {
- return this->onCreateCompatibleDevice(config, width, height,
- isOpaque, kGeneral_Usage);
-}
-
-SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
- int width, int height,
- bool isOpaque) {
- return this->onCreateCompatibleDevice(config, width, height,
- isOpaque, kSaveLayer_Usage);
+ SkImageInfo info = SkImageInfo::Make(width, height,
+ SkBitmapConfigToColorType(config),
+ isOpaque ? kOpaque_SkAlphaType
+ : kPremul_SkAlphaType);
+ return this->createCompatibleDevice(info);
}
+#endif
SkMetaData& SkBaseDevice::getMetaData() {
// metadata users are rare, so we lazily allocate it. If that changes we
« 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