hide deviceproperties, prepare the way for surfaceprops
BUG=skia:
NOTRY=True
R=bungeman@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/577023002
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 3af47f6..44ce217 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -61,12 +61,14 @@
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
}
+#if 0
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
: SkBaseDevice(deviceProperties)
, fBitmap(bitmap)
{
SkASSERT(valid_for_bitmap_device(bitmap.info(), NULL));
}
+#endif
SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
const SkDeviceProperties* props) {
@@ -91,8 +93,8 @@
}
}
- if (props) {
- return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
+ if (props && false) {
+// return SkNEW_ARGS(SkBitmapDevice, (bitmap, *props));
} else {
return SkNEW_ARGS(SkBitmapDevice, (bitmap));
}
@@ -110,7 +112,7 @@
}
SkBaseDevice* SkBitmapDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
- return SkBitmapDevice::Create(info, &this->getDeviceProperties());
+ return SkBitmapDevice::Create(info);// &this->getDeviceProperties());
}
void SkBitmapDevice::lockPixels() {
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index d22b227..9b37da1 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -6,23 +6,14 @@
*/
#include "SkDevice.h"
+#include "SkDeviceProperties.h"
#include "SkDraw.h"
#include "SkMetaData.h"
#include "SkPatchUtils.h"
#include "SkTextBlob.h"
SkBaseDevice::SkBaseDevice()
- : fLeakyProperties(SkDeviceProperties::MakeDefault())
-#ifdef SK_DEBUG
- , fAttachedToCanvas(false)
-#endif
-{
- fOrigin.setZero();
- fMetaData = NULL;
-}
-
-SkBaseDevice::SkBaseDevice(const SkDeviceProperties& deviceProperties)
- : fLeakyProperties(deviceProperties)
+ : fLeakyProperties(SkNEW_ARGS(SkDeviceProperties, (SkDeviceProperties::MakeDefault())))
#ifdef SK_DEBUG
, fAttachedToCanvas(false)
#endif
@@ -32,7 +23,8 @@
}
SkBaseDevice::~SkBaseDevice() {
- delete fMetaData;
+ SkDELETE(fLeakyProperties);
+ SkDELETE(fMetaData);
}
SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
diff --git a/src/core/SkDeviceProperties.h b/src/core/SkDeviceProperties.h
new file mode 100644
index 0000000..80e0177
--- /dev/null
+++ b/src/core/SkDeviceProperties.h
@@ -0,0 +1,103 @@
+#ifndef SkDeviceProperties_DEFINED
+#define SkDeviceProperties_DEFINED
+
+//TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import.
+#include "SkFontLCDConfig.h"
+
+struct SkDeviceProperties {
+ struct Geometry {
+ /** The orientation of the pixel specifies the interpretation of the
+ * layout. If the orientation is horizontal, the layout is interpreted as
+ * left to right. It the orientation is vertical, the layout is
+ * interpreted top to bottom (rotated 90deg cw from horizontal).
+ */
+ enum Orientation {
+ kUnknown_Orientation = 0x0,
+ kKnown_Orientation = 0x2,
+
+ kHorizontal_Orientation = 0x2, //!< this is the default
+ kVertical_Orientation = 0x3,
+
+ kOrientationMask = 0x3,
+ };
+
+ /** The layout of the pixel specifies its subpixel geometry.
+ *
+ * kUnknown_Layout means that the subpixel elements are not spatially
+ * separated in any known or usable fashion.
+ */
+ enum Layout {
+ kUnknown_Layout = 0x0,
+ kKnown_Layout = 0x8,
+
+ kRGB_Layout = 0x8, //!< this is the default
+ kBGR_Layout = 0xC,
+
+ kLayoutMask = 0xC,
+ };
+
+ Orientation getOrientation() {
+ return static_cast<Orientation>(fGeometry & kOrientationMask);
+ }
+ Layout getLayout() {
+ return static_cast<Layout>(fGeometry & kLayoutMask);
+ }
+
+ bool isOrientationKnown() {
+ return SkToBool(fGeometry & kKnown_Orientation);
+ }
+ bool isLayoutKnown() {
+ return SkToBool(fGeometry & kKnown_Layout);
+ }
+
+ private:
+ //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and replace these calls with constants.
+ static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation orientation) {
+ switch (orientation) {
+ case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal_Orientation;
+ case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Orientation;
+ default: return kUnknown_Orientation;
+ }
+ }
+ static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) {
+ switch (order) {
+ case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout;
+ case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout;
+ default: return kUnknown_Layout;
+ }
+ }
+ public:
+ static Geometry MakeDefault() {
+ Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSubpixelOrientation()); //kHorizontal_Orientation
+ Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout
+ Geometry ret = { SkToU8(orientation | layout) };
+ return ret;
+ }
+
+ static Geometry Make(Orientation orientation, Layout layout) {
+ Geometry ret = { SkToU8(orientation | layout) };
+ return ret;
+ }
+
+ uint8_t fGeometry;
+ };
+
+ static SkDeviceProperties MakeDefault() {
+ SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT };
+ return ret;
+ }
+
+ static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) {
+ SkDeviceProperties ret = { geometry, gamma };
+ return ret;
+ }
+
+ /** Each pixel of an image will have some number of channels.
+ * Can the layout of those channels be exploited? */
+ Geometry fGeometry;
+
+ /** Represents the color space of the image. This is a woefully inadequate beginning. */
+ SkScalar fGamma;
+};
+
+#endif
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 4b878ba..e905f4b 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1576,7 +1576,7 @@
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
+ SkAutoGlyphCache autoCache(paint, &fDevice->getLeakyProperties(), fMatrix);
SkGlyphCache* cache = autoCache.getCache();
// transform our starting point
@@ -1724,7 +1724,7 @@
}
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix);
+ SkAutoGlyphCache autoCache(paint, &fDevice->getLeakyProperties(), fMatrix);
SkGlyphCache* cache = autoCache.getCache();
SkAAClipBlitterWrapper wrapper;