From e5d92d3d034eeadbb94fdb28baa38d81af7a4ec1 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Mon, 17 May 2010 21:04:22 -0700 Subject: [PATCH] b=561168; convert canvas to use layers for rendering - followup #2; r=roc --- gfx/layers/Layers.h | 12 +++++++++++- gfx/layers/basic/BasicLayers.cpp | 2 ++ layout/generic/nsHTMLCanvasFrame.cpp | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 3306e1f66ffc..225a88b88de6 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -47,6 +47,7 @@ #include "nsAutoPtr.h" #include "gfx3DMatrix.h" #include "gfxColor.h" +#include "gfxPattern.h" class gfxContext; class nsPaintEvent; @@ -496,9 +497,18 @@ public: */ virtual void Updated(const nsIntRect& aRect) = 0; + /** + * CONSTRUCTION PHASE ONLY + * Set the filter used to resample this image (if necessary). + */ + void SetFilter(gfxPattern::GraphicsFilter aFilter) { mFilter = aFilter; } + gfxPattern::GraphicsFilter GetFilter() const { return mFilter; } + protected: CanvasLayer(LayerManager* aManager, void* aImplData) - : Layer(aManager, aImplData) {} + : Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD) {} + + gfxPattern::GraphicsFilter mFilter; }; } diff --git a/gfx/layers/basic/BasicLayers.cpp b/gfx/layers/basic/BasicLayers.cpp index 3ba05ed5e8ba..1244dd49bd0a 100644 --- a/gfx/layers/basic/BasicLayers.cpp +++ b/gfx/layers/basic/BasicLayers.cpp @@ -488,6 +488,8 @@ BasicCanvasLayer::Paint(gfxContext* aContext) { nsRefPtr pat = new gfxPattern(mSurface); + pat->SetFilter(mFilter); + gfxRect r(0, 0, mBounds.width, mBounds.height); gfxMatrix m; if (mNeedsYFlip) { diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 4ca492d0ffd5..d140dc4385cc 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -261,6 +261,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder, transform.Translate(r.pos); transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height); layer->SetTransform(gfx3DMatrix::From2D(transform)); + layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this)); nsRefPtr result = layer.forget(); return result.forget();