Bug 602431, part 2: Add a ShadowColorLayer base class and BasicShadowColorLayer implementation. sr=roc

This commit is contained in:
Chris Jones 2010-10-13 17:55:45 -05:00
Родитель 6072b647fd
Коммит 7b524759fa
4 изменённых файлов: 64 добавлений и 8 удалений

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

@ -676,7 +676,13 @@ public:
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
float aOpacity);
float aOpacity)
{
PaintColorTo(mColor, mOpacity, aContext);
}
static void PaintColorTo(gfxRGBA aColor, float aOpacity,
gfxContext* aContext);
protected:
BasicLayerManager* BasicManager()
@ -685,13 +691,11 @@ protected:
}
};
void
BasicColorLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
float aOpacity)
/*static*/ void
BasicColorLayer::PaintColorTo(gfxRGBA aColor, float aOpacity,
gfxContext* aContext)
{
aContext->SetColor(mColor);
aContext->SetColor(aColor);
aContext->Paint(aOpacity);
}
@ -2042,6 +2046,29 @@ BasicShadowImageLayer::Paint(gfxContext* aContext,
BasicImageLayer::PaintContext(pat, mSize, aOpacity, aContext);
}
class BasicShadowColorLayer : public ShadowColorLayer,
BasicImplData
{
public:
BasicShadowColorLayer(BasicShadowLayerManager* aLayerManager) :
ShadowColorLayer(aLayerManager, static_cast<BasicImplData*>(this))
{
MOZ_COUNT_CTOR(BasicShadowColorLayer);
}
virtual ~BasicShadowColorLayer()
{
MOZ_COUNT_DTOR(BasicShadowColorLayer);
}
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
float aOpacity)
{
BasicColorLayer::PaintColorTo(mColor, aOpacity, aContext);
}
};
class BasicShadowCanvasLayer : public ShadowCanvasLayer,
BasicImplData
{
@ -2227,6 +2254,14 @@ BasicShadowLayerManager::CreateShadowImageLayer()
return layer.forget();
}
already_AddRefed<ShadowColorLayer>
BasicShadowLayerManager::CreateShadowColorLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<ShadowColorLayer> layer = new BasicShadowColorLayer(this);
return layer.forget();
}
already_AddRefed<ShadowCanvasLayer>
BasicShadowLayerManager::CreateShadowCanvasLayer()
{

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

@ -153,6 +153,8 @@ public:
{ return NULL; }
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer()
{ return NULL; }
virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer()
{ return NULL; }
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer()
{ return NULL; }
@ -244,6 +246,7 @@ public:
virtual already_AddRefed<ColorLayer> CreateColorLayer();
virtual already_AddRefed<ShadowThebesLayer> CreateShadowThebesLayer();
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer();
virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer();
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer();
ShadowableLayer* Hold(Layer* aLayer);

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

@ -59,6 +59,7 @@ class PLayersParent;
class ShadowableLayer;
class ShadowThebesLayer;
class ShadowImageLayer;
class ShadowColorLayer;
class ShadowCanvasLayer;
class SurfaceDescriptor;
class ThebesBuffer;
@ -342,6 +343,8 @@ public:
/** CONSTRUCTION PHASE ONLY */
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer() = 0;
/** CONSTRUCTION PHASE ONLY */
virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer() = 0;
/** CONSTRUCTION PHASE ONLY */
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer() = 0;
static void PlatformSyncBeforeReplyUpdate();
@ -590,6 +593,21 @@ protected:
};
class ShadowColorLayer : public ShadowLayer,
public ColorLayer
{
public:
virtual ShadowLayer* AsShadowLayer() { return this; }
MOZ_LAYER_DECL_NAME("ShadowColorLayer", TYPE_SHADOW)
protected:
ShadowColorLayer(LayerManager* aManager, void* aImplData)
: ColorLayer(aManager, aImplData)
{}
};
} // namespace layers
} // namespace mozilla

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

@ -175,7 +175,7 @@ ShadowLayersParent::RecvUpdate(const nsTArray<Edit>& cset,
case Edit::TOpCreateColorLayer: {
MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer"));
nsRefPtr<ColorLayer> layer = layer_manager()->CreateColorLayer();
nsRefPtr<ShadowColorLayer> layer = layer_manager()->CreateShadowColorLayer();
AsShadowLayer(edit.get_OpCreateColorLayer())->Bind(layer);
break;
}