b=561168; convert canvas to use layers for rendering - followup #2; r=roc

This commit is contained in:
Vladimir Vukicevic 2010-05-17 21:04:22 -07:00
parent 57c2111dfe
commit e5d92d3d03
3 changed files with 14 additions and 1 deletions

View File

@ -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;
};
}

View File

@ -488,6 +488,8 @@ BasicCanvasLayer::Paint(gfxContext* aContext)
{
nsRefPtr<gfxPattern> pat = new gfxPattern(mSurface);
pat->SetFilter(mFilter);
gfxRect r(0, 0, mBounds.width, mBounds.height);
gfxMatrix m;
if (mNeedsYFlip) {

View File

@ -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<Layer> result = layer.forget();
return result.forget();