mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952033 - Part a: Use IntSize in SurfaceCache; r=roc
This commit is contained in:
parent
ef4a47e1ee
commit
2958895ce4
@ -15,6 +15,7 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxPattern.h" // Workaround for flaw in bug 921753 part 2.
|
||||
#include "gfxDrawable.h"
|
||||
@ -30,7 +31,7 @@
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
using mozilla::gfx::DrawTarget;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
@ -58,7 +59,7 @@ static StaticRefPtr<SurfaceCacheImpl> sInstance;
|
||||
*/
|
||||
typedef size_t Cost;
|
||||
|
||||
static Cost ComputeCost(const nsIntSize aSize)
|
||||
static Cost ComputeCost(const IntSize& aSize)
|
||||
{
|
||||
return aSize.width * aSize.height * 4; // width * height * 4 bytes (32bpp)
|
||||
}
|
||||
@ -502,11 +503,12 @@ SurfaceCache::Insert(DrawTarget* aTarget,
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Cost cost = ComputeCost(aSurfaceKey.Size());
|
||||
return sInstance->Insert(aTarget, aSurfaceKey.Size(), cost, aImageKey, aSurfaceKey);
|
||||
return sInstance->Insert(aTarget, ThebesIntSize(aSurfaceKey.Size()), cost,
|
||||
aImageKey, aSurfaceKey);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
SurfaceCache::CanHold(const nsIntSize& aSize)
|
||||
SurfaceCache::CanHold(const IntSize& aSize)
|
||||
{
|
||||
MOZ_ASSERT(sInstance, "Should be initialized");
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "mozilla/HashFunctions.h" // for HashGeneric and AddToHash
|
||||
#include "gfxPoint.h" // for gfxSize
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsSize.h" // for nsIntSize
|
||||
#include "mozilla/gfx/Point.h" // for mozilla::gfx::IntSize
|
||||
#include "SVGImageContext.h" // for SVGImageContext
|
||||
|
||||
class gfxDrawable;
|
||||
@ -43,8 +43,9 @@ typedef Image* ImageKey;
|
||||
*/
|
||||
class SurfaceKey
|
||||
{
|
||||
typedef gfx::IntSize IntSize;
|
||||
public:
|
||||
SurfaceKey(const nsIntSize aSize,
|
||||
SurfaceKey(const IntSize& aSize,
|
||||
const gfxSize aScale,
|
||||
const SVGImageContext* aSVGContext,
|
||||
const float aAnimationTime,
|
||||
@ -80,10 +81,10 @@ public:
|
||||
return hash;
|
||||
}
|
||||
|
||||
nsIntSize Size() const { return mSize; }
|
||||
IntSize Size() const { return mSize; }
|
||||
|
||||
private:
|
||||
nsIntSize mSize;
|
||||
IntSize mSize;
|
||||
gfxSize mScale;
|
||||
SVGImageContext mSVGContext;
|
||||
bool mSVGContextIsValid;
|
||||
@ -101,6 +102,8 @@ private:
|
||||
*/
|
||||
struct SurfaceCache
|
||||
{
|
||||
typedef gfx::IntSize IntSize;
|
||||
|
||||
/*
|
||||
* Initialize static data. Called during imagelib module initialization.
|
||||
*/
|
||||
@ -150,7 +153,7 @@ struct SurfaceCache
|
||||
*
|
||||
* @return false if the surface cache can't hold a surface of that size.
|
||||
*/
|
||||
static bool CanHold(const nsIntSize& aSize);
|
||||
static bool CanHold(const IntSize& aSize);
|
||||
|
||||
/*
|
||||
* Evicts any cached surfaces associated with the given image from the cache.
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "VectorImage.h"
|
||||
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxDrawable.h"
|
||||
#include "gfxPlatform.h"
|
||||
@ -32,6 +33,7 @@
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
using namespace gfx;
|
||||
using namespace layers;
|
||||
|
||||
namespace image {
|
||||
@ -739,10 +741,10 @@ struct SVGDrawingParameters
|
||||
userSpaceToImageSpace = aUserSpaceToImageSpace * unscale;
|
||||
|
||||
// Rescale drawing parameters.
|
||||
gfxIntSize drawableSize(aViewportSize.width / scale.width,
|
||||
aViewportSize.height / scale.height);
|
||||
IntSize drawableSize(aViewportSize.width / scale.width,
|
||||
aViewportSize.height / scale.height);
|
||||
sourceRect = userSpaceToImageSpace.Transform(aFill);
|
||||
imageRect = nsIntRect(0, 0, drawableSize.width, drawableSize.height);
|
||||
imageRect = IntRect(IntPoint(0, 0), drawableSize);
|
||||
subimage = gfxRect(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
|
||||
subimage.ScaleRoundOut(1.0 / scale.width, 1.0 / scale.height);
|
||||
}
|
||||
@ -753,7 +755,7 @@ struct SVGDrawingParameters
|
||||
gfxRect fill;
|
||||
gfxRect subimage;
|
||||
gfxRect sourceRect;
|
||||
nsIntRect imageRect;
|
||||
IntRect imageRect;
|
||||
nsIntSize viewportSize;
|
||||
gfxSize scale;
|
||||
float animationTime;
|
||||
@ -838,7 +840,8 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams)
|
||||
aParams.scale,
|
||||
aParams.flags);
|
||||
|
||||
nsRefPtr<gfxDrawable> svgDrawable = new gfxCallbackDrawable(cb, aParams.imageRect.Size());
|
||||
nsRefPtr<gfxDrawable> svgDrawable =
|
||||
new gfxCallbackDrawable(cb, ThebesIntSize(aParams.imageRect.Size()));
|
||||
|
||||
// Refuse to cache animated images.
|
||||
// XXX(seth): We may remove this restriction in bug 922893.
|
||||
@ -851,7 +854,7 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams)
|
||||
|
||||
// Try to create an offscreen surface.
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> target =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aParams.imageRect.Size().ToIntSize(), gfx::SurfaceFormat::B8G8R8A8);
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(aParams.imageRect.Size(), gfx::SurfaceFormat::B8G8R8A8);
|
||||
|
||||
// If we couldn't create the draw target, it was probably because it would end
|
||||
// up way too big. Generally it also wouldn't fit in the cache, but the prefs
|
||||
@ -863,8 +866,10 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams)
|
||||
|
||||
// Actually draw. (We use FILTER_NEAREST since we never scale here.)
|
||||
gfxUtils::DrawPixelSnapped(ctx, svgDrawable, gfxMatrix(),
|
||||
aParams.imageRect, aParams.imageRect,
|
||||
aParams.imageRect, aParams.imageRect,
|
||||
ThebesIntRect(aParams.imageRect),
|
||||
ThebesIntRect(aParams.imageRect),
|
||||
ThebesIntRect(aParams.imageRect),
|
||||
ThebesIntRect(aParams.imageRect),
|
||||
gfxImageFormat::ARGB32,
|
||||
GraphicsFilter::FILTER_NEAREST, aParams.flags);
|
||||
|
||||
@ -878,7 +883,8 @@ VectorImage::CreateDrawableAndShow(const SVGDrawingParameters& aParams)
|
||||
// Draw. Note that if SurfaceCache::Insert failed for whatever reason,
|
||||
// then |target| is all that is keeping the pixel data alive, so we have
|
||||
// to draw before returning from this function.
|
||||
nsRefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(target, aParams.imageRect.Size());
|
||||
nsRefPtr<gfxDrawable> drawable =
|
||||
new gfxSurfaceDrawable(target, ThebesIntSize(aParams.imageRect.Size()));
|
||||
Show(drawable, aParams);
|
||||
}
|
||||
|
||||
@ -890,7 +896,7 @@ VectorImage::Show(gfxDrawable* aDrawable, const SVGDrawingParameters& aParams)
|
||||
gfxUtils::DrawPixelSnapped(aParams.context, aDrawable,
|
||||
aParams.userSpaceToImageSpace,
|
||||
aParams.subimage, aParams.sourceRect,
|
||||
aParams.imageRect, aParams.fill,
|
||||
ThebesIntRect(aParams.imageRect), aParams.fill,
|
||||
gfxImageFormat::ARGB32,
|
||||
aParams.filter, aParams.flags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user