From 532470f34dbe9fc0b8b71e3917eca8894feaf336 Mon Sep 17 00:00:00 2001 From: "bungeman@google.com" Date: Tue, 22 Jan 2013 19:25:14 +0000 Subject: [PATCH] Expose geometry and gamma on device. https://codereview.appspot.com/6499101/ git-svn-id: http://skia.googlecode.com/svn/trunk@7317 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/core.gypi | 2 + include/core/SkDevice.h | 38 +++++++++++++ include/core/SkDeviceProperties.h | 112 ++++++++++++++++++++++++++++++++++++++ include/core/SkFontHost.h | 8 +++ include/core/SkPaint.h | 5 +- src/core/SkDevice.cpp | 36 +++++++++++- src/core/SkDraw.cpp | 4 +- src/core/SkGlyphCache.h | 7 ++- src/core/SkPaint.cpp | 92 +++++++++++++++++-------------- src/core/SkScalerContext.h | 3 +- src/pdf/SkPDFDevice.cpp | 2 +- src/pdf/SkPDFFont.cpp | 2 +- src/utils/SkDeferredCanvas.cpp | 6 +- 13 files changed, 261 insertions(+), 56 deletions(-) create mode 100644 include/core/SkDeviceProperties.h diff --git a/gyp/core.gypi b/gyp/core.gypi index 4830645..1dc1392 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -141,6 +141,7 @@ '<(skia_src_path)/core/SkRTree.cpp', '<(skia_src_path)/core/SkScalar.cpp', '<(skia_src_path)/core/SkScalerContext.cpp', + '<(skia_src_path)/core/SkScalerContext.h', '<(skia_src_path)/core/SkScan.cpp', '<(skia_src_path)/core/SkScan.h', '<(skia_src_path)/core/SkScanPriv.h', @@ -210,6 +211,7 @@ '<(skia_include_path)/core/SkData.h', '<(skia_include_path)/core/SkDeque.h', '<(skia_include_path)/core/SkDevice.h', + '<(skia_include_path)/core/SkDeviceProperties.h', '<(skia_include_path)/core/SkDither.h', '<(skia_include_path)/core/SkDraw.h', '<(skia_include_path)/core/SkDrawFilter.h', diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 5c32f76..81bbf43 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -14,6 +14,7 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkColor.h" +#include "SkDeviceProperties.h" class SkClipStack; class SkDraw; @@ -37,6 +38,13 @@ public: SkDevice(const SkBitmap& bitmap); /** + * Construct a new device with the specified bitmap as its backend. It is + * valid for the bitmap to have no pixels associated with it. In that case, + * any drawing to this device will have no effect. + */ + SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties); + + /** * Create a new raster device and have the pixels be automatically * allocated. The rowBytes of the device will be computed automatically * based on the config and the width. @@ -51,6 +59,23 @@ public: */ SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false); + /** + * Create a new raster device and have the pixels be automatically + * allocated. The rowBytes of the device will be computed automatically + * based on the config and the width. + * + * @param config The desired config for the pixels. If the request cannot + * be met, the closest matching support config will be used. + * @param width width (in pixels) of the device + * @param height height (in pixels) of the device + * @param isOpaque Set to true if it is known that all of the pixels will + * be drawn to opaquely. Used as an accelerator when drawing + * these pixels to another device. + * @param deviceProperties Properties which affect compositing. + */ + SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque, + const SkDeviceProperties& deviceProperties); + virtual ~SkDevice(); /** @@ -84,6 +109,12 @@ public: */ virtual int height() const { return fBitmap.height(); } + /** Return the image properties of the device. */ + virtual const SkDeviceProperties& getDeviceProperties() const { + //Currently, all the properties are leaky. + return fLeakyProperties; + } + /** * Return the bounds of the device in the coordinate space of the root * canvas. The root device will have its top-left at 0,0, but other devices @@ -418,6 +449,13 @@ private: SkBitmap fBitmap; SkIPoint fOrigin; SkMetaData* fMetaData; + /** + * Leaky properties are those which the device should be applying but it isn't. + * These properties will be applied by the draw, when and as it can. + * If the device does handle a property, that property should be set to the identity value + * for that property, effectively making it non-leaky. + */ + SkDeviceProperties fLeakyProperties; #ifdef SK_DEBUG bool fAttachedToCanvas; diff --git a/include/core/SkDeviceProperties.h b/include/core/SkDeviceProperties.h new file mode 100644 index 0000000..fcab9ad --- /dev/null +++ b/include/core/SkDeviceProperties.h @@ -0,0 +1,112 @@ +#ifndef SkDeviceProperties_DEFINED +#define SkDeviceProperties_DEFINED + +#ifndef SK_GAMMA_EXPONENT + #define SK_GAMMA_EXPONENT (2.2f) +#endif + +#ifdef SK_GAMMA_SRGB + #undef SK_GAMMA_EXPONENT + #define SK_GAMMA_EXPONENT (0.0f) +#endif + +//TODO: get everyone to stop using SkFontHost::SetSubpixel* and remove this import. +#include "SkFontHost.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(fGeometry | kOrientationMask); + } + Layout getLayout() { + return static_cast(fGeometry | kLayoutMask); + } + + bool isOrientationKnown() { + return fGeometry & kKnown_Orientation; + } + bool isLayoutKnown() { + return fGeometry & kKnown_Layout; + } + + private: + //TODO: get everyone to stop using SkFontHost::SetSubpixel* and replace these calls with constants. + static Orientation fromOldOrientation(SkFontHost::LCDOrientation orientation) { + switch (orientation) { + case SkFontHost::kHorizontal_LCDOrientation: return kHorizontal_Orientation; + case SkFontHost::kVertical_LCDOrientation: return kVertical_Orientation; + default: return kUnknown_Orientation; + } + } + static Layout fromOldLayout(SkFontHost::LCDOrder order) { + switch (order) { + case SkFontHost::kRGB_LCDOrder: return kRGB_Layout; + case SkFontHost::kBGR_LCDOrder: return kBGR_Layout; + default: return kUnknown_Layout; + } + } + public: + static Geometry MakeDefault() { + Orientation orientation = fromOldOrientation(SkFontHost::GetSubpixelOrientation()); //kHorizontal_Orientation + Layout layout = fromOldLayout(SkFontHost::GetSubpixelOrder()); //kRGB_Layout + Geometry ret = { orientation | layout }; + return ret; + } + + static Geometry Make(Orientation orientation, Layout layout) { + Geometry ret = { 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/include/core/SkFontHost.h b/include/core/SkFontHost.h index 737b2eb..3c2ed09 100644 --- a/include/core/SkFontHost.h +++ b/include/core/SkFontHost.h @@ -236,13 +236,17 @@ public: Note, if you change this after startup, you'll need to flush the glyph cache because it'll have the wrong type of masks cached. + + @deprecated use SkPixelGeometry instead. */ enum LCDOrientation { kHorizontal_LCDOrientation = 0, //!< this is the default kVertical_LCDOrientation = 1 }; + /** @deprecated set on Device creation. */ static void SetSubpixelOrientation(LCDOrientation orientation); + /** @deprecated get from Device. */ static LCDOrientation GetSubpixelOrientation(); /** LCD color elements can vary in order. For subpixel text we need to know @@ -254,6 +258,8 @@ public: kNONE_LCDOrder means that the subpixel elements are not spatially separated in any usable fashion. + + @deprecated use SkPixelGeometry instead. */ enum LCDOrder { kRGB_LCDOrder = 0, //!< this is the default @@ -261,7 +267,9 @@ public: kNONE_LCDOrder = 2 }; + /** @deprecated set on Device creation. */ static void SetSubpixelOrder(LCDOrder order); + /** @deprecated get from Device. */ static LCDOrder GetSubpixelOrder(); #ifdef SK_BUILD_FOR_ANDROID diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 16b1b84..8c4a7a4 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -19,6 +19,7 @@ class SkAnnotation; class SkAutoGlyphCache; class SkColorFilter; class SkDescriptor; +struct SkDeviceProperties; class SkFlattenableReadBuffer; class SkFlattenableWriteBuffer; struct SkGlyph; @@ -962,9 +963,9 @@ private: SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, int* count, SkRect* bounds) const; - SkGlyphCache* detachCache(const SkMatrix*) const; + SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*) const; - void descriptorProc(const SkMatrix* deviceMatrix, + void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix, void (*proc)(const SkDescriptor*, void*), void* context, bool ignoreGamma = false) const; diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index b3209b3..c79b4f8 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -6,6 +6,7 @@ * found in the LICENSE file. */ #include "SkDevice.h" +#include "SkDeviceProperties.h" #include "SkDraw.h" #include "SkImageFilter.h" #include "SkMetaData.h" @@ -23,7 +24,17 @@ SK_DEFINE_INST_COUNT(SkDevice) /////////////////////////////////////////////////////////////////////////////// SkDevice::SkDevice(const SkBitmap& bitmap) - : fBitmap(bitmap) + : fBitmap(bitmap), fLeakyProperties(SkDeviceProperties::MakeDefault()) +#ifdef SK_DEBUG + , fAttachedToCanvas(false) +#endif +{ + fOrigin.setZero(); + fMetaData = NULL; +} + +SkDevice::SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) + : fBitmap(bitmap), fLeakyProperties(deviceProperties) #ifdef SK_DEBUG , fAttachedToCanvas(false) #endif @@ -33,8 +44,27 @@ SkDevice::SkDevice(const SkBitmap& bitmap) } SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque) + : fLeakyProperties(SkDeviceProperties::MakeDefault()) +#ifdef SK_DEBUG + , fAttachedToCanvas(false) +#endif +{ + fOrigin.setZero(); + fMetaData = NULL; + + fBitmap.setConfig(config, width, height); + fBitmap.allocPixels(); + fBitmap.setIsOpaque(isOpaque); + if (!isOpaque) { + fBitmap.eraseColor(SK_ColorTRANSPARENT); + } +} + +SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque, + const SkDeviceProperties& deviceProperties) + : fLeakyProperties(deviceProperties) #ifdef SK_DEBUG - : fAttachedToCanvas(false) + , fAttachedToCanvas(false) #endif { fOrigin.setZero(); @@ -77,7 +107,7 @@ SkDevice* SkDevice::onCreateCompatibleDevice(SkBitmap::Config config, int width, int height, bool isOpaque, Usage usage) { - return SkNEW_ARGS(SkDevice,(config, width, height, isOpaque)); + return SkNEW_ARGS(SkDevice,(config, width, height, isOpaque, fLeakyProperties)); } SkMetaData& SkDevice::getMetaData() { diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index cf638e9..ad8a0be 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1658,7 +1658,7 @@ void SkDraw::drawText(const char text[], size_t byteLength, const SkMatrix* matrix = fMatrix; - SkAutoGlyphCache autoCache(paint, matrix); + SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, matrix); SkGlyphCache* cache = autoCache.getCache(); // transform our starting point @@ -1852,7 +1852,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, const SkMatrix* matrix = fMatrix; SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); - SkAutoGlyphCache autoCache(paint, matrix); + SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, matrix); SkGlyphCache* cache = autoCache.getCache(); SkAAClipBlitterWrapper wrapper; diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index 472bcde..8509011 100644 --- a/src/core/SkGlyphCache.h +++ b/src/core/SkGlyphCache.h @@ -18,6 +18,7 @@ #include "SkTemplates.h" #include "SkTDArray.h" +struct SkDeviceProperties; class SkPaint; class SkGlyphCache_Globals; @@ -275,8 +276,10 @@ public: SkAutoGlyphCache(const SkDescriptor* desc) { fCache = SkGlyphCache::DetachCache(desc); } - SkAutoGlyphCache(const SkPaint& paint, const SkMatrix* matrix) { - fCache = paint.detachCache(matrix); + SkAutoGlyphCache(const SkPaint& paint, + const SkDeviceProperties* deviceProperties, + const SkMatrix* matrix) { + fCache = paint.detachCache(deviceProperties, matrix); } ~SkAutoGlyphCache() { if (fCache) { diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 8270e3b..754098c 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -9,6 +9,7 @@ #include "SkPaint.h" #include "SkAnnotation.h" #include "SkColorFilter.h" +#include "SkDeviceProperties.h" #include "SkFontHost.h" #include "SkImageFilter.h" #include "SkMaskFilter.h" @@ -476,7 +477,7 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, return byteLength >> 1; } - SkAutoGlyphCache autoCache(*this, NULL); + SkAutoGlyphCache autoCache(*this, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); const char* text = (const char*)textData; @@ -530,7 +531,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const { return true; } - SkAutoGlyphCache autoCache(*this, NULL); + SkAutoGlyphCache autoCache(*this, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); switch (this->getTextEncoding()) { @@ -580,7 +581,7 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkASSERT(glyphs != NULL); SkASSERT(textData != NULL); - SkAutoGlyphCache autoCache(*this, NULL); + SkAutoGlyphCache autoCache(*this, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); for (int index = 0; index < count; index++) { @@ -1048,7 +1049,7 @@ SkScalar SkPaint::measureText(const void* textData, size_t length, zoomPtr = &zoomMatrix; } - SkAutoGlyphCache autoCache(*this, zoomPtr); + SkAutoGlyphCache autoCache(*this, NULL, zoomPtr); SkGlyphCache* cache = autoCache.getCache(); SkScalar width = 0; @@ -1124,7 +1125,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths)); } - SkAutoGlyphCache autoCache(*this, NULL); + SkAutoGlyphCache autoCache(*this, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); SkMeasureCacheProc glyphCacheProc = this->getMeasureCacheProc(tbd, false); @@ -1212,7 +1213,7 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { metrics = &storage; } - this->descriptorProc(zoomPtr, FontMetricsDescProc, metrics, true); + this->descriptorProc(NULL, zoomPtr, FontMetricsDescProc, metrics, true); if (scale) { metrics->fTop = SkScalarMul(metrics->fTop, scale); @@ -1254,7 +1255,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength, ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths)); } - SkAutoGlyphCache autoCache(*this, NULL); + SkAutoGlyphCache autoCache(*this, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); SkMeasureCacheProc glyphCacheProc; glyphCacheProc = this->getMeasureCacheProc(kForward_TextBufferDirection, @@ -1487,22 +1488,10 @@ static SkScalar sk_relax(SkScalar x) { #endif } -//#define SK_GAMMA_SRGB -#ifndef SK_GAMMA_CONTRAST - /** - * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise. - * With lower values small text appears washed out (though correctly so). - * With higher values lcd fringing is worse and the smoothing effect of - * partial coverage is diminished. - */ - #define SK_GAMMA_CONTRAST (0.5f) -#endif -#ifndef SK_GAMMA_EXPONENT - #define SK_GAMMA_EXPONENT (2.2f) -#endif - void SkScalerContext::MakeRec(const SkPaint& paint, - const SkMatrix* deviceMatrix, Rec* rec) { + const SkDeviceProperties* deviceProperties, + const SkMatrix* deviceMatrix, + Rec* rec) { SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); SkTypeface* typeface = paint.getTypeface(); @@ -1572,19 +1561,18 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); - if (SkMask::kLCD16_Format == rec->fMaskFormat || - SkMask::kLCD32_Format == rec->fMaskFormat) - { - SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder(); - SkFontHost::LCDOrientation orient = SkFontHost::GetSubpixelOrientation(); - if (SkFontHost::kNONE_LCDOrder == order || tooBigForLCD(*rec)) { + SkDeviceProperties::Geometry geometry = deviceProperties + ? deviceProperties->fGeometry + : SkDeviceProperties::Geometry::MakeDefault(); + if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == rec->fMaskFormat) { + if (!geometry.isOrientationKnown() || !geometry.isLayoutKnown() || tooBigForLCD(*rec)) { // eeek, can't support LCD rec->fMaskFormat = SkMask::kA8_Format; } else { - if (SkFontHost::kVertical_LCDOrientation == orient) { + if (SkDeviceProperties::Geometry::kVertical_Orientation == geometry.getOrientation()) { flags |= SkScalerContext::kLCD_Vertical_Flag; } - if (SkFontHost::kBGR_LCDOrder == order) { + if (SkDeviceProperties::Geometry::kBGR_Layout == geometry.getLayout()) { flags |= SkScalerContext::kLCD_BGROrder_Flag; } } @@ -1611,14 +1599,32 @@ void SkScalerContext::MakeRec(const SkPaint& paint, rec->setHinting(computeHinting(paint)); rec->setLuminanceColor(computeLuminanceColor(paint)); -#ifdef SK_GAMMA_SRGB - rec->setDeviceGamma(0); - rec->setPaintGamma(0); + + if (NULL == deviceProperties) { + rec->setDeviceGamma(SK_GAMMA_EXPONENT); + rec->setPaintGamma(SK_GAMMA_EXPONENT); + } else { + rec->setDeviceGamma(deviceProperties->fGamma); + + //For now always set the paint gamma equal to the device gamma. + //The math in SkMaskGamma can handle them being different, + //but it requires superluminous masks when + //Ex : deviceGamma(x) < paintGamma(x) and x is sufficiently large. + rec->setPaintGamma(deviceProperties->fGamma); + } + +#ifdef SK_GAMMA_CONTRAST + rec->setContrast(SK_GAMMA_CONTRAST); #else - rec->setDeviceGamma(SkFloatToScalar(SK_GAMMA_EXPONENT)); - rec->setPaintGamma(SkFloatToScalar(SK_GAMMA_EXPONENT)); + /** + * A value of 0.5 for SK_GAMMA_CONTRAST appears to be a good compromise. + * With lower values small text appears washed out (though correctly so). + * With higher values lcd fringing is worse and the smoothing effect of + * partial coverage is diminished. + */ + rec->setContrast(SkFloatToScalar(0.5f)); #endif - rec->setContrast(SkFloatToScalar(SK_GAMMA_CONTRAST)); + rec->fReservedAlign = 0; /* Allow the fonthost to modify our rec before we use it as a key into the @@ -1712,7 +1718,7 @@ void SkScalerContext::PostMakeRec(const SkPaint& paint, SkScalerContext::Rec* re } case SkMask::kBW_Format: // No need to differentiate gamma if we're BW - rec->setLuminanceColor(0); + rec->ignorePreBlend(); break; } } @@ -1730,12 +1736,13 @@ void SkScalerContext::PostMakeRec(const SkPaint& paint, SkScalerContext::Rec* re * would be for the fontcache lookup to know to ignore the luminance field * entirely, but not sure how to do that and keep it fast. */ -void SkPaint::descriptorProc(const SkMatrix* deviceMatrix, +void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, + const SkMatrix* deviceMatrix, void (*proc)(const SkDescriptor*, void*), void* context, bool ignoreGamma) const { SkScalerContext::Rec rec; - SkScalerContext::MakeRec(*this, deviceMatrix, &rec); + SkScalerContext::MakeRec(*this, deviceProperties, deviceMatrix, &rec); if (ignoreGamma) { rec.setLuminanceColor(0); } @@ -1846,9 +1853,10 @@ void SkPaint::descriptorProc(const SkMatrix* deviceMatrix, proc(desc, context); } -SkGlyphCache* SkPaint::detachCache(const SkMatrix* deviceMatrix) const { +SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties, + const SkMatrix* deviceMatrix) const { SkGlyphCache* cache; - this->descriptorProc(deviceMatrix, DetachDescProc, &cache); + this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, false); return cache; } @@ -2241,7 +2249,7 @@ SkTextToPathIter::SkTextToPathIter( const char text[], size_t length, fPaint.setPathEffect(NULL); } - fCache = fPaint.detachCache(NULL); + fCache = fPaint.detachCache(NULL, NULL); SkPaint::Style style = SkPaint::kFill_Style; SkPathEffect* pe = NULL; diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 05d5bc0..f30bbd3 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -202,7 +202,8 @@ public: } #endif - static inline void MakeRec(const SkPaint&, const SkMatrix*, Rec* rec); + static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties, + const SkMatrix*, Rec* rec); static inline void PostMakeRec(const SkPaint&, Rec*); static SkScalerContext* Create(const SkDescriptor*); diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 7f189aa..63cc8c4 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -75,7 +75,7 @@ static void align_text(SkDrawCacheProc glyphCacheProc, const SkPaint& paint, SkMatrix ident; ident.reset(); - SkAutoGlyphCache autoCache(paint, &ident); + SkAutoGlyphCache autoCache(paint, NULL, &ident); SkGlyphCache* cache = autoCache.getCache(); const char* start = reinterpret_cast(glyphs); diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index f2b3f53..89b4fc9 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -1341,7 +1341,7 @@ bool SkPDFType3Font::populate(int16_t glyphID) { SkPaint paint; paint.setTypeface(typeface()); paint.setTextSize(1000); - SkAutoGlyphCache autoCache(paint, NULL); + SkAutoGlyphCache autoCache(paint, NULL, NULL); SkGlyphCache* cache = autoCache.getCache(); // If fLastGlyphID isn't set (because there is not fFontInfo), look it up. if (lastGlyphID() == 0) { diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index 26ac088..3c6dc2c 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -320,8 +320,10 @@ private: DeferredDevice::DeferredDevice( SkDevice* immediateDevice, SkDeferredCanvas::NotificationClient* notificationClient) : - SkDevice(SkBitmap::kNo_Config, immediateDevice->width(), - immediateDevice->height(), immediateDevice->isOpaque()) + SkDevice(SkBitmap::kNo_Config, + immediateDevice->width(), immediateDevice->height(), + immediateDevice->isOpaque(), + immediateDevice->getDeviceProperties()) , fRecordingCanvas(NULL) , fFreshFrame(true) , fPreviousStorageAllocated(0) -- 2.7.4