зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989858 - Part 3: Convert BasicImageLayer. r=roc
This commit is contained in:
Родитель
faaf960268
Коммит
c9f75dcf24
|
@ -3,7 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "BasicLayersImpl.h" // for FillWithMask, etc
|
||||
#include "BasicLayersImpl.h" // for FillRectWithMask, etc
|
||||
#include "ImageContainer.h" // for AutoLockImage, etc
|
||||
#include "ImageLayers.h" // for ImageLayer
|
||||
#include "Layers.h" // for Layer (ptr only), etc
|
||||
|
@ -69,21 +69,10 @@ protected:
|
|||
GetAndPaintCurrentImage(DrawTarget* aTarget,
|
||||
float aOpacity,
|
||||
SourceSurface* aMaskSurface);
|
||||
already_AddRefed<gfxPattern>
|
||||
DeprecatedGetAndPaintCurrentImage(gfxContext* aContext,
|
||||
float aOpacity,
|
||||
Layer* aMaskLayer);
|
||||
|
||||
gfx::IntSize mSize;
|
||||
};
|
||||
|
||||
static void
|
||||
DeprecatedPaintContext(gfxPattern* aPattern,
|
||||
const nsIntRegion& aVisible,
|
||||
float aOpacity,
|
||||
gfxContext* aContext,
|
||||
Layer* aMaskLayer);
|
||||
|
||||
void
|
||||
BasicImageLayer::Paint(DrawTarget* aTarget, SourceSurface* aMaskSurface)
|
||||
{
|
||||
|
@ -96,13 +85,28 @@ BasicImageLayer::Paint(DrawTarget* aTarget, SourceSurface* aMaskSurface)
|
|||
void
|
||||
BasicImageLayer::DeprecatedPaint(gfxContext* aContext, Layer* aMaskLayer)
|
||||
{
|
||||
if (IsHidden()) {
|
||||
if (IsHidden() || !mContainer) {
|
||||
return;
|
||||
}
|
||||
nsRefPtr<gfxPattern> dontcare =
|
||||
DeprecatedGetAndPaintCurrentImage(aContext,
|
||||
GetEffectiveOpacity(),
|
||||
aMaskLayer);
|
||||
|
||||
mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
|
||||
|
||||
RefPtr<gfx::SourceSurface> surface;
|
||||
AutoLockImage autoLock(mContainer, &surface);
|
||||
Image *image = autoLock.GetImage();
|
||||
gfx::IntSize size = mSize = autoLock.GetSize();
|
||||
|
||||
if (!surface || !surface->IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FillRectWithMask(aContext->GetDrawTarget(),
|
||||
Rect(0, 0, size.width, size.height),
|
||||
surface, ToFilter(mFilter),
|
||||
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
||||
aMaskLayer);
|
||||
|
||||
GetContainer()->NotifyPaintedImage(image);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -141,83 +145,6 @@ BasicImageLayer::GetAndPaintCurrentImage(DrawTarget* aTarget,
|
|||
mContainer->UnlockCurrentImage();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxPattern>
|
||||
BasicImageLayer::DeprecatedGetAndPaintCurrentImage(gfxContext* aContext,
|
||||
float aOpacity,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
if (!mContainer)
|
||||
return nullptr;
|
||||
|
||||
mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
|
||||
|
||||
RefPtr<gfx::SourceSurface> surface;
|
||||
AutoLockImage autoLock(mContainer, &surface);
|
||||
Image *image = autoLock.GetImage();
|
||||
gfx::IntSize size = mSize = autoLock.GetSize();
|
||||
|
||||
if (!surface || !surface->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<gfxPattern> pat = new gfxPattern(surface, gfx::Matrix());
|
||||
if (!pat) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pat->SetFilter(mFilter);
|
||||
|
||||
// The visible region can extend outside the image, so just draw
|
||||
// within the image bounds.
|
||||
if (aContext) {
|
||||
CompositionOp op = GetEffectiveOperator(this);
|
||||
AutoSetOperator setOptimizedOperator(aContext, ThebesOp(op));
|
||||
|
||||
DeprecatedPaintContext(pat,
|
||||
nsIntRegion(nsIntRect(0, 0, size.width, size.height)),
|
||||
aOpacity, aContext, aMaskLayer);
|
||||
|
||||
GetContainer()->NotifyPaintedImage(image);
|
||||
}
|
||||
|
||||
return pat.forget();
|
||||
}
|
||||
|
||||
static void
|
||||
DeprecatedPaintContext(gfxPattern* aPattern,
|
||||
const nsIntRegion& aVisible,
|
||||
float aOpacity,
|
||||
gfxContext* aContext,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
// Set PAD mode so that when the video is being scaled, we do not sample
|
||||
// outside the bounds of the video image.
|
||||
gfxPattern::GraphicsExtend extend = gfxPattern::EXTEND_PAD;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// PAD is slow with cairo and old X11 servers, so prefer speed over
|
||||
// correctness and use NONE.
|
||||
if (aContext->IsCairo()) {
|
||||
nsRefPtr<gfxASurface> target = aContext->CurrentSurface();
|
||||
if (target->GetType() == gfxSurfaceType::Xlib &&
|
||||
static_cast<gfxXlibSurface*>(target.get())->IsPadSlow()) {
|
||||
extend = gfxPattern::EXTEND_NONE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
FillWithMask(aContext, aOpacity, aMaskLayer);
|
||||
|
||||
// Reset extend mode for callers that need to reuse the pattern
|
||||
aPattern->SetExtend(extend);
|
||||
}
|
||||
|
||||
bool
|
||||
BasicImageLayer::GetAsSurface(gfxASurface** aSurface,
|
||||
SurfaceDescriptor* aDescriptor)
|
||||
|
|
Загрузка…
Ссылка в новой задаче