Bug 607653 - avoid temporary fbos/textures on transformed layers, when possible. part2 r=roc a=apporval2.0

This commit is contained in:
Oleg Romashin 2010-11-30 07:51:56 +02:00
parent b19d4e2f0c
commit 900507d5b5
3 changed files with 62 additions and 27 deletions

View File

@ -37,6 +37,8 @@
#include "ContainerLayerD3D10.h"
#include "nsAlgorithm.h"
#include "gfxUtils.h"
#include "nsRect.h"
namespace mozilla {
namespace layers {
@ -143,6 +145,15 @@ ContainerLayerD3D10::GetFirstChildD3D10()
return static_cast<LayerD3D10*>(mFirstChild->ImplData());
}
static inline LayerD3D10*
GetNextSiblingD3D10(LayerD3D10* aLayer)
{
Layer* layer = aLayer->GetLayer()->GetNextSibling();
return layer ? static_cast<LayerD3D10*>(layer->
ImplData())
: nsnull;
}
void
ContainerLayerD3D10::RenderLayer()
{
@ -197,9 +208,15 @@ ContainerLayerD3D10::RenderLayer()
/*
* Render this container's contents.
*/
LayerD3D10 *layerToRender = GetFirstChildD3D10();
while (layerToRender) {
const nsIntRect *clipRect = layerToRender->GetLayer()->GetClipRect();
for (LayerD3D10* layerToRender = GetFirstChildD3D10();
layerToRender != nsnull;
layerToRender = GetNextSiblingD3D10(layerToRender)) {
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
if ((clipRect && clipRect->IsEmpty()) ||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
continue;
}
D3D10_RECT oldScissor;
if (clipRect || useIntermediate) {
@ -231,10 +248,6 @@ ContainerLayerD3D10::RenderLayer()
if (r.left >= r.right || r.top >= r.bottom) {
// Entire layer's clipped out, don't bother drawing.
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
layerToRender = nextSibling ? static_cast<LayerD3D10*>(nextSibling->
ImplData())
: nsnull;
continue;
}
@ -252,11 +265,6 @@ ContainerLayerD3D10::RenderLayer()
if (clipRect || useIntermediate) {
device()->RSSetScissorRects(1, &oldScissor);
}
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
layerToRender = nextSibling ? static_cast<LayerD3D10*>(nextSibling->
ImplData())
: nsnull;
}
if (useIntermediate) {

View File

@ -36,6 +36,8 @@
* ***** END LICENSE BLOCK ***** */
#include "ContainerLayerD3D9.h"
#include "gfxUtils.h"
#include "nsRect.h"
namespace mozilla {
namespace layers {
@ -142,6 +144,15 @@ ContainerLayerD3D9::GetFirstChildD3D9()
return static_cast<LayerD3D9*>(mFirstChild->ImplData());
}
static inline LayerD3D9*
GetNextSiblingD3D9(LayerD3D9* aLayer)
{
Layer* layer = aLayer->GetLayer()->GetNextSibling();
return layer ? static_cast<LayerD3D9*>(layer->
ImplData())
: nsnull;
}
void
ContainerLayerD3D9::RenderLayer()
{
@ -187,9 +198,16 @@ ContainerLayerD3D9::RenderLayer()
/*
* Render this container's contents.
*/
LayerD3D9 *layerToRender = GetFirstChildD3D9();
while (layerToRender) {
const nsIntRect *clipRect = layerToRender->GetLayer()->GetClipRect();
for (LayerD3D9* layerToRender = GetFirstChildD3D9();
layerToRender != nsnull;
layerToRender = GetNextSiblingD3D9(layerToRender)) {
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
if ((clipRect && clipRect->IsEmpty()) ||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
continue;
}
if (clipRect || useIntermediate) {
RECT r;
device()->GetScissorRect(&oldClipRect);
@ -233,11 +251,6 @@ ContainerLayerD3D9::RenderLayer()
if (clipRect || useIntermediate) {
device()->SetScissorRect(&oldClipRect);
}
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
layerToRender = nextSibling ? static_cast<LayerD3D9*>(nextSibling->
ImplData())
: nsnull;
}
if (useIntermediate) {

View File

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#include "ContainerLayerOGL.h"
#include "gfxUtils.h"
namespace mozilla {
namespace layers {
@ -128,6 +129,15 @@ ContainerDestroy(Container* aContainer)
}
}
static inline LayerOGL*
GetNextSibling(LayerOGL* aLayer)
{
Layer* layer = aLayer->GetLayer()->GetNextSibling();
return layer ? static_cast<LayerOGL*>(layer->
ImplData())
: nsnull;
}
template<class Container>
static void
ContainerRender(Container* aContainer,
@ -171,12 +181,21 @@ ContainerRender(Container* aContainer,
/**
* Render this container's contents.
*/
LayerOGL *layerToRender = aContainer->GetFirstChildOGL();
while (layerToRender) {
for (LayerOGL* layerToRender = aContainer->GetFirstChildOGL();
layerToRender != nsnull;
layerToRender = GetNextSibling(layerToRender)) {
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
continue;
}
nsIntRect scissorRect(visibleRect);
const nsIntRect *clipRect = layerToRender->GetLayer()->GetEffectiveClipRect();
if (clipRect) {
if (clipRect->IsEmpty()) {
continue;
}
scissorRect = *clipRect;
}
@ -215,11 +234,6 @@ ContainerRender(Container* aContainer,
}
layerToRender->RenderLayer(frameBuffer, childOffset);
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
layerToRender = nextSibling ? static_cast<LayerOGL*>(nextSibling->
ImplData())
: nsnull;
}
aContainer->gl()->PopScissorRect();