| Index: src/image/SkSurface.cpp
|
| diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
|
| index 3a28e421a880df9ff6ae9962aa504c6bd63bb040..1108f17a0c84d156c5211d70fb299f6665769486 100644
|
| --- a/src/image/SkSurface.cpp
|
| +++ b/src/image/SkSurface.cpp
|
| @@ -9,14 +9,56 @@
|
| #include "SkImagePriv.h"
|
| #include "SkCanvas.h"
|
|
|
| +#include "SkFontLCDConfig.h"
|
| +static SkPixelGeometry compute_default_geometry() {
|
| + SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
|
| + if (SkFontLCDConfig::kNONE_LCDOrder == order) {
|
| + return kUnknown_SkPixelGeometry;
|
| + } else {
|
| + // Bit0 is RGB(0), BGR(1)
|
| + // Bit1 is H(0), V(1)
|
| + const SkPixelGeometry gGeo[] = {
|
| + kRGB_H_SkPixelGeometry,
|
| + kBGR_H_SkPixelGeometry,
|
| + kRGB_V_SkPixelGeometry,
|
| + kBGR_V_SkPixelGeometry,
|
| + };
|
| + int index = 0;
|
| + if (SkFontLCDConfig::kBGR_LCDOrder == order) {
|
| + index |= 1;
|
| + }
|
| + if (SkFontLCDConfig::kVertical_LCDOrientation == SkFontLCDConfig::GetSubpixelOrientation()){
|
| + index |= 2;
|
| + }
|
| + return gGeo[index];
|
| + }
|
| +}
|
| +
|
| +SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
|
| +
|
| +SkSurfaceProps::SkSurfaceProps(InitType) : fFlags(0), fPixelGeometry(compute_default_geometry()) {}
|
| +
|
| +SkSurfaceProps::SkSurfaceProps(uint32_t flags, InitType)
|
| + : fFlags(flags)
|
| + , fPixelGeometry(compute_default_geometry())
|
| +{}
|
| +
|
| +SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
|
| + : fFlags(flags), fPixelGeometry(pg)
|
| +{}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkSurface_Base::SkSurface_Base(int width, int height) : INHERITED(width, height) {
|
| +SkSurface_Base::SkSurface_Base(int width, int height, const Props* props)
|
| + : INHERITED(width, height, props)
|
| +{
|
| fCachedCanvas = NULL;
|
| fCachedImage = NULL;
|
| }
|
|
|
| -SkSurface_Base::SkSurface_Base(const SkImageInfo& info) : INHERITED(info) {
|
| +SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const Props* props)
|
| + : INHERITED(info, props)
|
| +{
|
| fCachedCanvas = NULL;
|
| fCachedImage = NULL;
|
| }
|
| @@ -74,13 +116,25 @@ static SkSurface_Base* asSB(SkSurface* surface) {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkSurface::SkSurface(int width, int height) : fWidth(width), fHeight(height) {
|
| +static SkSurfaceProps props_or_default(const SkSurfaceProps* props) {
|
| + if (props) {
|
| + return *props;
|
| + } else {
|
| + return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
| + }
|
| +}
|
| +
|
| +SkSurface::SkSurface(int width, int height, const Props* props)
|
| + : fProps(props_or_default(props)), fWidth(width), fHeight(height)
|
| +{
|
| SkASSERT(fWidth >= 0);
|
| SkASSERT(fHeight >= 0);
|
| fGenerationID = 0;
|
| }
|
|
|
| -SkSurface::SkSurface(const SkImageInfo& info) : fWidth(info.width()), fHeight(info.height()) {
|
| +SkSurface::SkSurface(const SkImageInfo& info, const Props* props)
|
| + : fProps(props_or_default(props)), fWidth(info.width()), fHeight(info.height())
|
| +{
|
| SkASSERT(fWidth >= 0);
|
| SkASSERT(fHeight >= 0);
|
| fGenerationID = 0;
|
|
|