Skip to content

Commit

Permalink
Bug 1074280 - Use AsContainerLayer() in order to avoid a bad cast. r=roc
Browse files Browse the repository at this point in the history
  • Loading branch information
mstange committed Oct 7, 2014
1 parent a5902d4 commit 391dd9a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions gfx/layers/basic/BasicLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,26 +795,24 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
RenderTraceScope trace("BasicLayerManager::PaintLayer", "707070");

const nsIntRect* clipRect = aLayer->GetEffectiveClipRect();
// aLayer might not be a container layer, but if so we take care not to use
// the container variable
BasicContainerLayer* container = static_cast<BasicContainerLayer*>(aLayer);
bool needsGroup = aLayer->GetFirstChild() &&
container->UseIntermediateSurface();
BasicContainerLayer* container =
static_cast<BasicContainerLayer*>(aLayer->AsContainerLayer());
bool needsGroup = container && container->UseIntermediateSurface();
BasicImplData* data = ToData(aLayer);
bool needsClipToVisibleRegion =
data->GetClipToVisibleRegion() && !aLayer->AsPaintedLayer();
NS_ASSERTION(needsGroup || !aLayer->GetFirstChild() ||
NS_ASSERTION(needsGroup || !container ||
container->GetOperator() == CompositionOp::OP_OVER,
"non-OVER operator should have forced UseIntermediateSurface");
NS_ASSERTION(!aLayer->GetFirstChild() || !aLayer->GetMaskLayer() ||
NS_ASSERTION(!container || !aLayer->GetMaskLayer() ||
container->UseIntermediateSurface(),
"ContainerLayer with mask layer should force UseIntermediateSurface");

gfxContextAutoSaveRestore contextSR;
gfxMatrix transform;
// Will return an identity matrix for 3d transforms, and is handled separately below.
bool is2D = paintLayerContext.Setup2DTransform();
NS_ABORT_IF_FALSE(is2D || needsGroup || !aLayer->GetFirstChild(), "Must PushGroup for 3d transforms!");
NS_ABORT_IF_FALSE(is2D || needsGroup || !container, "Must PushGroup for 3d transforms!");

bool needsSaveRestore =
needsGroup || clipRect || needsClipToVisibleRegion || !is2D;
Expand Down

0 comments on commit 391dd9a

Please sign in to comment.