b=606218; webgl Y axis upside down; followup to fix opacity; r=cjones

This commit is contained in:
Vladimir Vukicevic 2011-01-25 14:18:41 -08:00
Родитель 87cde5d902
Коммит d7ebc933dc
1 изменённых файлов: 21 добавлений и 8 удалений

Просмотреть файл

@ -824,6 +824,9 @@ public:
LayerManager::DrawThebesLayerCallback aCallback, LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData); void* aCallbackData);
virtual void PaintWithOpacity(gfxContext* aContext,
float aOpacity);
protected: protected:
BasicLayerManager* BasicManager() BasicLayerManager* BasicManager()
{ {
@ -932,6 +935,13 @@ void
BasicCanvasLayer::Paint(gfxContext* aContext, BasicCanvasLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback, LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) void* aCallbackData)
{
PaintWithOpacity(aContext, GetEffectiveOpacity());
}
void
BasicCanvasLayer::PaintWithOpacity(gfxContext* aContext,
float aOpacity)
{ {
NS_ASSERTION(BasicManager()->InDrawing(), NS_ASSERTION(BasicManager()->InDrawing(),
"Can only draw in drawing phase"); "Can only draw in drawing phase");
@ -948,16 +958,14 @@ BasicCanvasLayer::Paint(gfxContext* aContext,
aContext->Scale(1.0, -1.0); aContext->Scale(1.0, -1.0);
} }
float opacity = GetEffectiveOpacity();
aContext->NewPath(); aContext->NewPath();
// No need to snap here; our transform is already set up to snap our rect // No need to snap here; our transform is already set up to snap our rect
aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height)); aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height));
aContext->SetPattern(pat); aContext->SetPattern(pat);
if (opacity != 1.0) { if (aOpacity != 1.0) {
aContext->Save(); aContext->Save();
aContext->Clip(); aContext->Clip();
aContext->Paint(opacity); aContext->Paint(aOpacity);
aContext->Restore(); aContext->Restore();
} else { } else {
aContext->Fill(); aContext->Fill();
@ -2020,14 +2028,19 @@ BasicShadowableCanvasLayer::Paint(gfxContext* aContext,
if (!HasShadow()) if (!HasShadow())
return; return;
// XXX this is yucky and slow. It'd be nice to draw directly into // It'd be nice to draw directly into the shmem back buffer.
// the shmem back buffer // Doing so is complex -- for 2D canvases, we'd need to copy
// changed areas, much like we do for Thebes layers, as well as
// do all sorts of magic to swap out the surface underneath the
// canvas' thebes/cairo context.
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackBuffer); nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackBuffer);
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE); tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
// call BasicCanvasLayer::Paint to draw to our tmp context, because // call BasicCanvasLayer::Paint to draw to our tmp context, because
// it'll handle things like flipping correctly // it'll handle things like flipping correctly. We always want
BasicCanvasLayer::Paint(tmpCtx, nsnull, nsnull); // to do this with 1.0 opacity though, because opacity is a layer
// property that's handled by the shadow tree.
BasicCanvasLayer::PaintWithOpacity(tmpCtx, 1.0f);
BasicManager()->PaintedCanvas(BasicManager()->Hold(this), BasicManager()->PaintedCanvas(BasicManager()->Hold(this),
mBackBuffer); mBackBuffer);