зеркало из https://github.com/mozilla/pjs.git
Bug 627273, part 4: Basic impl of ImageLayer tiling for basic layers. r=roc,vlad
This commit is contained in:
Родитель
daeec56b20
Коммит
e79b649c5b
|
@ -200,6 +200,17 @@ LayerManager::CreateOptimalSurface(const gfxIntSize &aSize,
|
||||||
CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
|
CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
void
|
||||||
|
LayerManager::Mutated(Layer* aLayer)
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(!aLayer->GetTileSourceRect() ||
|
||||||
|
(LAYERS_BASIC == GetBackendType() &&
|
||||||
|
Layer::TYPE_IMAGE == aLayer->GetType()),
|
||||||
|
"Tiling not supported for this manager/layer type");
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Layer
|
// Layer
|
||||||
|
|
||||||
|
|
|
@ -359,8 +359,15 @@ public:
|
||||||
/**
|
/**
|
||||||
* CONSTRUCTION PHASE ONLY
|
* CONSTRUCTION PHASE ONLY
|
||||||
* Called when a managee has mutated.
|
* Called when a managee has mutated.
|
||||||
|
* Subclasses overriding this method must first call their
|
||||||
|
* superclass's impl
|
||||||
*/
|
*/
|
||||||
|
#ifdef DEBUG
|
||||||
|
// In debug builds, we check some properties of |aLayer|.
|
||||||
|
virtual void Mutated(Layer* aLayer);
|
||||||
|
#else
|
||||||
virtual void Mutated(Layer* aLayer) { }
|
virtual void Mutated(Layer* aLayer) { }
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CONSTRUCTION PHASE ONLY
|
* CONSTRUCTION PHASE ONLY
|
||||||
|
@ -641,6 +648,10 @@ public:
|
||||||
* ColorLayers, a source rect for tiling doesn't make sense at all.
|
* ColorLayers, a source rect for tiling doesn't make sense at all.
|
||||||
*
|
*
|
||||||
* If aRect is null no tiling will be performed.
|
* If aRect is null no tiling will be performed.
|
||||||
|
*
|
||||||
|
* NB: this interface is only implemented for BasicImageLayers, and
|
||||||
|
* then only for source rects the same size as the layers'
|
||||||
|
* underlying images.
|
||||||
*/
|
*/
|
||||||
void SetTileSourceRect(const nsIntRect* aRect)
|
void SetTileSourceRect(const nsIntRect* aRect)
|
||||||
{
|
{
|
||||||
|
|
|
@ -667,7 +667,8 @@ public:
|
||||||
void* aCallbackData);
|
void* aCallbackData);
|
||||||
|
|
||||||
static void PaintContext(gfxPattern* aPattern,
|
static void PaintContext(gfxPattern* aPattern,
|
||||||
const gfxIntSize& aSize,
|
const nsIntRegion& aVisible,
|
||||||
|
const nsIntRect* aTileSourceRect,
|
||||||
float aOpacity,
|
float aOpacity,
|
||||||
gfxContext* aContext);
|
gfxContext* aContext);
|
||||||
|
|
||||||
|
@ -712,13 +713,16 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
|
||||||
|
|
||||||
pat->SetFilter(mFilter);
|
pat->SetFilter(mFilter);
|
||||||
|
|
||||||
PaintContext(pat, mSize, aOpacity, aContext);
|
PaintContext(pat,
|
||||||
|
nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
|
||||||
|
GetTileSourceRect(), aOpacity, aContext);
|
||||||
return pat.forget();
|
return pat.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
BasicImageLayer::PaintContext(gfxPattern* aPattern,
|
BasicImageLayer::PaintContext(gfxPattern* aPattern,
|
||||||
const gfxIntSize& aSize,
|
const nsIntRegion& aVisible,
|
||||||
|
const nsIntRect* aTileSourceRect,
|
||||||
float aOpacity,
|
float aOpacity,
|
||||||
gfxContext* aContext)
|
gfxContext* aContext)
|
||||||
{
|
{
|
||||||
|
@ -736,14 +740,34 @@ BasicImageLayer::PaintContext(gfxPattern* aPattern,
|
||||||
extend = gfxPattern::EXTEND_NONE;
|
extend = gfxPattern::EXTEND_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
aPattern->SetExtend(extend);
|
if (!aTileSourceRect) {
|
||||||
|
aContext->NewPath();
|
||||||
|
// No need to snap here; our transform has already taken care of it.
|
||||||
|
// XXX true for arbitrary regions? Don't care yet though
|
||||||
|
gfxUtils::PathFromRegion(aContext, aVisible);
|
||||||
|
aPattern->SetExtend(extend);
|
||||||
|
aContext->SetPattern(aPattern);
|
||||||
|
aContext->FillWithOpacity(aOpacity);
|
||||||
|
} else {
|
||||||
|
nsRefPtr<gfxASurface> source = aPattern->GetSurface();
|
||||||
|
NS_ABORT_IF_FALSE(source, "Expecting a surface pattern");
|
||||||
|
gfxIntSize sourceSize = source->GetSize();
|
||||||
|
nsIntRect sourceRect(0, 0, sourceSize.width, sourceSize.height);
|
||||||
|
NS_ABORT_IF_FALSE(sourceRect == *aTileSourceRect,
|
||||||
|
"Cowardly refusing to create a temporary surface for tiling");
|
||||||
|
|
||||||
/* Draw RGB surface onto frame */
|
gfxContextAutoSaveRestore saveRestore(aContext);
|
||||||
aContext->NewPath();
|
|
||||||
// No need to snap here; our transform has already taken care of it.
|
aContext->NewPath();
|
||||||
aContext->Rectangle(gfxRect(0, 0, aSize.width, aSize.height));
|
gfxUtils::PathFromRegion(aContext, aVisible);
|
||||||
aContext->SetPattern(aPattern);
|
|
||||||
aContext->FillWithOpacity(aOpacity);
|
aPattern->SetExtend(gfxPattern::EXTEND_REPEAT);
|
||||||
|
aContext->SetPattern(aPattern);
|
||||||
|
aContext->FillWithOpacity(aOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset extend mode for callers that need to reuse the pattern
|
||||||
|
aPattern->SetExtend(extend);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicColorLayer : public ColorLayer, BasicImplData {
|
class BasicColorLayer : public ColorLayer, BasicImplData {
|
||||||
|
@ -1890,7 +1914,9 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackSurface);
|
nsRefPtr<gfxContext> tmpCtx = new gfxContext(mBackSurface);
|
||||||
PaintContext(pat, mSize, 1.0, tmpCtx);
|
PaintContext(pat,
|
||||||
|
nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
|
||||||
|
nsnull, 1.0, tmpCtx);
|
||||||
|
|
||||||
BasicManager()->PaintedImage(BasicManager()->Hold(this),
|
BasicManager()->PaintedImage(BasicManager()->Hold(this),
|
||||||
mBackSurface);
|
mBackSurface);
|
||||||
|
@ -2366,7 +2392,8 @@ BasicShadowImageLayer::Paint(gfxContext* aContext,
|
||||||
|
|
||||||
nsRefPtr<gfxPattern> pat = new gfxPattern(mFrontSurface);
|
nsRefPtr<gfxPattern> pat = new gfxPattern(mFrontSurface);
|
||||||
pat->SetFilter(mFilter);
|
pat->SetFilter(mFilter);
|
||||||
BasicImageLayer::PaintContext(pat, mSize, GetEffectiveOpacity(), aContext);
|
BasicImageLayer::PaintContext(
|
||||||
|
pat, GetEffectiveVisibleRegion(), GetTileSourceRect(), GetEffectiveOpacity(), aContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicShadowColorLayer : public ShadowColorLayer,
|
class BasicShadowColorLayer : public ShadowColorLayer,
|
||||||
|
@ -2631,6 +2658,8 @@ BasicShadowLayerManager::SetRoot(Layer* aLayer)
|
||||||
void
|
void
|
||||||
BasicShadowLayerManager::Mutated(Layer* aLayer)
|
BasicShadowLayerManager::Mutated(Layer* aLayer)
|
||||||
{
|
{
|
||||||
|
BasicLayerManager::Mutated(aLayer);
|
||||||
|
|
||||||
NS_ASSERTION(InConstruction() || InDrawing(), "wrong phase");
|
NS_ASSERTION(InConstruction() || InDrawing(), "wrong phase");
|
||||||
if (HasShadowManager()) {
|
if (HasShadowManager()) {
|
||||||
ShadowLayerForwarder::Mutated(Hold(aLayer));
|
ShadowLayerForwarder::Mutated(Hold(aLayer));
|
||||||
|
|
|
@ -122,6 +122,8 @@ struct CommonLayerAttributes {
|
||||||
float opacity;
|
float opacity;
|
||||||
bool useClipRect;
|
bool useClipRect;
|
||||||
nsIntRect clipRect;
|
nsIntRect clipRect;
|
||||||
|
bool useTileSourceRect;
|
||||||
|
nsIntRect tileSourceRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ThebesLayerAttributes {
|
struct ThebesLayerAttributes {
|
||||||
|
|
|
@ -345,6 +345,9 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
|
||||||
common.useClipRect() = !!mutant->GetClipRect();
|
common.useClipRect() = !!mutant->GetClipRect();
|
||||||
common.clipRect() = (common.useClipRect() ?
|
common.clipRect() = (common.useClipRect() ?
|
||||||
*mutant->GetClipRect() : nsIntRect());
|
*mutant->GetClipRect() : nsIntRect());
|
||||||
|
common.useTileSourceRect() = !!mutant->GetTileSourceRect();
|
||||||
|
common.tileSourceRect() = (common.useTileSourceRect() ?
|
||||||
|
*mutant->GetTileSourceRect() : nsIntRect());
|
||||||
attrs.specific() = null_t();
|
attrs.specific() = null_t();
|
||||||
mutant->FillSpecificAttributes(attrs.specific());
|
mutant->FillSpecificAttributes(attrs.specific());
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||||
layer->SetOpacity(common.opacity());
|
layer->SetOpacity(common.opacity());
|
||||||
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
|
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
|
||||||
layer->SetTransform(common.transform());
|
layer->SetTransform(common.transform());
|
||||||
|
layer->SetTileSourceRect(common.useTileSourceRect() ? &common.tileSourceRect() : NULL);
|
||||||
|
|
||||||
typedef SpecificLayerAttributes Specific;
|
typedef SpecificLayerAttributes Specific;
|
||||||
const SpecificLayerAttributes& specific = attrs.specific();
|
const SpecificLayerAttributes& specific = attrs.specific();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче