| Index: src/core/SkCanvas.cpp
|
| diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
|
| index 62d60da178bd790582acdf5aba3c7db92791e0bb..b2aef143d41c616d305ba726e0cdc63d0500dfb1 100644
|
| --- a/src/core/SkCanvas.cpp
|
| +++ b/src/core/SkCanvas.cpp
|
| @@ -67,6 +67,38 @@ void SkCanvas::predrawNotify() {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| +static bool disable_lcd(const SkSurfaceProps& props) {
|
| + return kUnknown_SkPixelGeometry == props.pixelGeometry();
|
| +}
|
| +
|
| +static bool disable_lcd(const SkPaint& paint) {
|
| + return paint.getRasterizer() || paint.getPathEffect() || paint.isFakeBoldText() ||
|
| + paint.getStyle() != SkPaint::kFill_Style ||
|
| + !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode);
|
| +}
|
| +
|
| +void apply_props_to_paint(const SkSurfaceProps& props, SkPaint* paint) {
|
| + const uint32_t propFlags = props.flags();
|
| + uint32_t clearMask = 0;
|
| +
|
| + if (paint->isDither() && (propFlags & SkSurfaceProps::kDisallowDither_Flag)) {
|
| + clearMask |= SkPaint::kDither_Flag;
|
| + }
|
| + if (paint->isAntiAlias()) {
|
| + if (propFlags & SkSurfaceProps::kDisallowAntiAlias_Flag) {
|
| + clearMask |= SkPaint::kAntiAlias_Flag;
|
| + } else if (paint->isLCDRenderText() && (disable_lcd(props) || disable_lcd(*paint))) {
|
| + clearMask |= SkPaint::kLCDRenderText_Flag;
|
| + }
|
| + }
|
| +
|
| + if (clearMask) {
|
| + paint->setFlags(paint->getFlags() & ~clearMask);
|
| + }
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +
|
| /* This is the record we keep for each SkBaseDevice that the user installs.
|
| The clip/matrix/proc are fields that reflect the top of the save/restore
|
| stack. Whenever the canvas changes, it marks a dirty flag, and then before
|
| @@ -250,9 +282,9 @@ private:
|
|
|
| class AutoDrawLooper {
|
| public:
|
| - AutoDrawLooper(SkCanvas* canvas, const SkPaint& paint,
|
| + AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint& paint,
|
| bool skipLayerForImageFilter = false,
|
| - const SkRect* bounds = NULL) : fOrigPaint(paint) {
|
| + const SkRect* bounds = NULL) : fProps(props), fOrigPaint(paint) {
|
| fCanvas = canvas;
|
| fFilter = canvas->getDrawFilter();
|
| fPaint = NULL;
|
| @@ -309,6 +341,7 @@ public:
|
| private:
|
| SkLazyPaint fLazyPaint;
|
| SkCanvas* fCanvas;
|
| + const SkSurfaceProps& fProps;
|
| const SkPaint& fOrigPaint;
|
| SkDrawFilter* fFilter;
|
| const SkPaint* fPaint;
|
| @@ -332,6 +365,7 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
| if (fDoClearImageFilter) {
|
| paint->setImageFilter(NULL);
|
| }
|
| + apply_props_to_paint(fProps, paint);
|
|
|
| if (fLooperContext && !fLooperContext->next(fCanvas, paint)) {
|
| fDone = true;
|
| @@ -368,13 +402,13 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
|
|
| #define LOOPER_BEGIN_DRAWDEVICE(paint, type) \
|
| this->predrawNotify(); \
|
| - AutoDrawLooper looper(this, paint, true); \
|
| + AutoDrawLooper looper(this, fProps, paint, true); \
|
| while (looper.next(type)) { \
|
| SkDrawIter iter(this);
|
|
|
| #define LOOPER_BEGIN(paint, type, bounds) \
|
| this->predrawNotify(); \
|
| - AutoDrawLooper looper(this, paint, false, bounds); \
|
| + AutoDrawLooper looper(this, fProps, paint, false, bounds); \
|
| while (looper.next(type)) { \
|
| SkDrawIter iter(this);
|
|
|
| @@ -468,12 +502,14 @@ SkCanvas::SkCanvas(SkBaseDevice* device)
|
| this->init(device, kDefault_InitFlags);
|
| }
|
|
|
| -SkCanvas::SkCanvas(const SkBitmap& bitmap)
|
| +SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps* props)
|
| : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
|
| + , fProps(props ? *props : SkSurfaceProps())
|
| {
|
| inc_canvas();
|
|
|
| - this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)), kDefault_InitFlags)->unref();
|
| + SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
|
| + this->init(device, kDefault_InitFlags);
|
| }
|
|
|
| SkCanvas::~SkCanvas() {
|
|
|