mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 732988 - Part 1: Add ScaleToSize API to ImageLayers. r=roc
This commit is contained in:
parent
a6618e22c1
commit
a1cb5a3d28
@ -581,6 +581,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
class THEBES_API ImageLayer : public Layer {
|
class THEBES_API ImageLayer : public Layer {
|
||||||
public:
|
public:
|
||||||
|
enum ScaleMode {
|
||||||
|
SCALE_NONE,
|
||||||
|
SCALE_STRETCH // Unimplemented on GL layers and e10s
|
||||||
|
// Unimplemented - SCALE_PRESERVE_ASPECT_RATIO_CONTAIN
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CONSTRUCTION PHASE ONLY
|
* CONSTRUCTION PHASE ONLY
|
||||||
* Set the ImageContainer. aContainer must have the same layer manager
|
* Set the ImageContainer. aContainer must have the same layer manager
|
||||||
@ -596,6 +602,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetFilter(gfxPattern::GraphicsFilter aFilter) { mFilter = aFilter; }
|
void SetFilter(gfxPattern::GraphicsFilter aFilter) { mFilter = aFilter; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CONSTRUCTION PHASE ONLY
|
||||||
|
* Set the size to scale the image to and the mode at which to scale.
|
||||||
|
*/
|
||||||
|
void SetScaleToSize(const gfxIntSize &aSize, ScaleMode aMode)
|
||||||
|
{
|
||||||
|
mScaleToSize = aSize;
|
||||||
|
mScaleMode = aMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImageContainer* GetContainer() { return mContainer; }
|
ImageContainer* GetContainer() { return mContainer; }
|
||||||
gfxPattern::GraphicsFilter GetFilter() { return mFilter; }
|
gfxPattern::GraphicsFilter GetFilter() { return mFilter; }
|
||||||
|
|
||||||
@ -620,12 +637,16 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
ImageLayer(LayerManager* aManager, void* aImplData)
|
ImageLayer(LayerManager* aManager, void* aImplData)
|
||||||
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD) {}
|
: Layer(aManager, aImplData), mFilter(gfxPattern::FILTER_GOOD)
|
||||||
|
, mScaleMode(SCALE_NONE) {}
|
||||||
|
|
||||||
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||||
|
|
||||||
|
|
||||||
nsRefPtr<ImageContainer> mContainer;
|
nsRefPtr<ImageContainer> mContainer;
|
||||||
gfxPattern::GraphicsFilter mFilter;
|
gfxPattern::GraphicsFilter mFilter;
|
||||||
|
gfxIntSize mScaleToSize;
|
||||||
|
ScaleMode mScaleMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****** Image subtypes for the different formats ******/
|
/****** Image subtypes for the different formats ******/
|
||||||
|
@ -867,8 +867,7 @@ BasicThebesLayerBuffer::SetBackingBufferAndUpdateFrom(
|
|||||||
class BasicImageLayer : public ImageLayer, public BasicImplData {
|
class BasicImageLayer : public ImageLayer, public BasicImplData {
|
||||||
public:
|
public:
|
||||||
BasicImageLayer(BasicLayerManager* aLayerManager) :
|
BasicImageLayer(BasicLayerManager* aLayerManager) :
|
||||||
ImageLayer(aLayerManager, static_cast<BasicImplData*>(this)),
|
ImageLayer(aLayerManager, static_cast<BasicImplData*>(this))
|
||||||
mSize(-1, -1)
|
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(BasicImageLayer);
|
MOZ_COUNT_CTOR(BasicImageLayer);
|
||||||
}
|
}
|
||||||
@ -901,8 +900,6 @@ protected:
|
|||||||
already_AddRefed<gfxPattern>
|
already_AddRefed<gfxPattern>
|
||||||
GetAndPaintCurrentImage(gfxContext* aContext,
|
GetAndPaintCurrentImage(gfxContext* aContext,
|
||||||
float aOpacity);
|
float aOpacity);
|
||||||
|
|
||||||
gfxIntSize mSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -926,7 +923,7 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
|
|||||||
nsRefPtr<gfxASurface> surface;
|
nsRefPtr<gfxASurface> surface;
|
||||||
AutoLockImage autoLock(mContainer, getter_AddRefs(surface));
|
AutoLockImage autoLock(mContainer, getter_AddRefs(surface));
|
||||||
Image *image = autoLock.GetImage();
|
Image *image = autoLock.GetImage();
|
||||||
mSize = autoLock.GetSize();
|
gfxIntSize size = autoLock.GetSize();
|
||||||
|
|
||||||
if (!surface || surface->CairoStatus()) {
|
if (!surface || surface->CairoStatus()) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
@ -938,6 +935,15 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pat->SetFilter(mFilter);
|
pat->SetFilter(mFilter);
|
||||||
|
gfxIntSize sourceSize = surface->GetSize();
|
||||||
|
if (mScaleMode != SCALE_NONE) {
|
||||||
|
NS_ASSERTION(mScaleMode == SCALE_STRETCH,
|
||||||
|
"No other scalemodes than stretch and none supported yet.");
|
||||||
|
gfxMatrix mat = pat->GetMatrix();
|
||||||
|
mat.Scale(float(sourceSize.width) / mScaleToSize.width, float(sourceSize.height) / mScaleToSize.height);
|
||||||
|
pat->SetMatrix(mat);
|
||||||
|
size = mScaleToSize;
|
||||||
|
}
|
||||||
|
|
||||||
// The visible region can extend outside the image. If we're not
|
// The visible region can extend outside the image. If we're not
|
||||||
// tiling, we don't want to draw into that area, so just draw within
|
// tiling, we don't want to draw into that area, so just draw within
|
||||||
@ -945,7 +951,7 @@ BasicImageLayer::GetAndPaintCurrentImage(gfxContext* aContext,
|
|||||||
const nsIntRect* tileSrcRect = GetTileSourceRect();
|
const nsIntRect* tileSrcRect = GetTileSourceRect();
|
||||||
AutoSetOperator setOperator(aContext, GetOperator());
|
AutoSetOperator setOperator(aContext, GetOperator());
|
||||||
PaintContext(pat,
|
PaintContext(pat,
|
||||||
tileSrcRect ? GetVisibleRegion() : nsIntRegion(nsIntRect(0, 0, mSize.width, mSize.height)),
|
tileSrcRect ? GetVisibleRegion() : nsIntRegion(nsIntRect(0, 0, size.width, size.height)),
|
||||||
tileSrcRect,
|
tileSrcRect,
|
||||||
aOpacity, aContext);
|
aOpacity, aContext);
|
||||||
|
|
||||||
@ -2469,7 +2475,8 @@ class BasicShadowableImageLayer : public BasicImageLayer,
|
|||||||
public:
|
public:
|
||||||
BasicShadowableImageLayer(BasicShadowLayerManager* aManager) :
|
BasicShadowableImageLayer(BasicShadowLayerManager* aManager) :
|
||||||
BasicImageLayer(aManager),
|
BasicImageLayer(aManager),
|
||||||
mBufferIsOpaque(false)
|
mBufferIsOpaque(false),
|
||||||
|
mSize(-1, -1)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(BasicShadowableImageLayer);
|
MOZ_COUNT_CTOR(BasicShadowableImageLayer);
|
||||||
}
|
}
|
||||||
@ -2536,6 +2543,7 @@ private:
|
|||||||
nsRefPtr<gfxSharedImageSurface> mBackBufferU;
|
nsRefPtr<gfxSharedImageSurface> mBackBufferU;
|
||||||
nsRefPtr<gfxSharedImageSurface> mBackBufferV;
|
nsRefPtr<gfxSharedImageSurface> mBackBufferV;
|
||||||
gfxIntSize mCbCrSize;
|
gfxIntSize mCbCrSize;
|
||||||
|
gfxIntSize mSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -130,6 +130,8 @@ ImageLayerD3D10::RenderLayer()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
|
||||||
|
|
||||||
SetEffectTransformAndOpacity();
|
SetEffectTransformAndOpacity();
|
||||||
|
|
||||||
ID3D10EffectTechnique *technique;
|
ID3D10EffectTechnique *technique;
|
||||||
@ -137,7 +139,6 @@ ImageLayerD3D10::RenderLayer()
|
|||||||
if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP)
|
if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP)
|
||||||
{
|
{
|
||||||
bool hasAlpha = false;
|
bool hasAlpha = false;
|
||||||
gfxIntSize size;
|
|
||||||
|
|
||||||
if (image->GetFormat() == Image::REMOTE_IMAGE_BITMAP) {
|
if (image->GetFormat() == Image::REMOTE_IMAGE_BITMAP) {
|
||||||
RemoteBitmapImage *remoteImage =
|
RemoteBitmapImage *remoteImage =
|
||||||
@ -154,7 +155,6 @@ ImageLayerD3D10::RenderLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasAlpha = remoteImage->mFormat == RemoteImageData::BGRA32;
|
hasAlpha = remoteImage->mFormat == RemoteImageData::BGRA32;
|
||||||
size = remoteImage->mSize;
|
|
||||||
} else {
|
} else {
|
||||||
CairoImage *cairoImage =
|
CairoImage *cairoImage =
|
||||||
static_cast<CairoImage*>(image);
|
static_cast<CairoImage*>(image);
|
||||||
@ -174,7 +174,6 @@ ImageLayerD3D10::RenderLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
|
hasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
|
||||||
size = cairoImage->mSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureD3D10BackendData *data =
|
TextureD3D10BackendData *data =
|
||||||
@ -286,8 +285,8 @@ ImageLayerD3D10::RenderLayer()
|
|||||||
ShaderConstantRectD3D10(
|
ShaderConstantRectD3D10(
|
||||||
(float)0,
|
(float)0,
|
||||||
(float)0,
|
(float)0,
|
||||||
(float)yuvImage->mSize.width,
|
(float)size.width,
|
||||||
(float)yuvImage->mSize.height)
|
(float)size.height)
|
||||||
);
|
);
|
||||||
|
|
||||||
effect()->GetVariableByName("vTextureCoords")->AsVector()->SetFloatVector(
|
effect()->GetVariableByName("vTextureCoords")->AsVector()->SetFloatVector(
|
||||||
|
@ -325,10 +325,11 @@ ImageLayerD3D9::RenderLayer()
|
|||||||
|
|
||||||
SetShaderTransformAndOpacity();
|
SetShaderTransformAndOpacity();
|
||||||
|
|
||||||
|
gfxIntSize size = mScaleMode == SCALE_NONE ? image->GetSize() : mScaleToSize;
|
||||||
|
|
||||||
if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP)
|
if (image->GetFormat() == Image::CAIRO_SURFACE || image->GetFormat() == Image::REMOTE_IMAGE_BITMAP)
|
||||||
{
|
{
|
||||||
bool hasAlpha = false;
|
bool hasAlpha = false;
|
||||||
gfxIntSize size;
|
|
||||||
|
|
||||||
if (image->GetFormat() == Image::REMOTE_IMAGE_BITMAP) {
|
if (image->GetFormat() == Image::REMOTE_IMAGE_BITMAP) {
|
||||||
RemoteBitmapImage *remoteImage =
|
RemoteBitmapImage *remoteImage =
|
||||||
@ -343,7 +344,6 @@ ImageLayerD3D9::RenderLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasAlpha = remoteImage->mFormat == RemoteImageData::BGRA32;
|
hasAlpha = remoteImage->mFormat == RemoteImageData::BGRA32;
|
||||||
size = remoteImage->mSize;
|
|
||||||
} else {
|
} else {
|
||||||
CairoImage *cairoImage =
|
CairoImage *cairoImage =
|
||||||
static_cast<CairoImage*>(image);
|
static_cast<CairoImage*>(image);
|
||||||
@ -361,7 +361,6 @@ ImageLayerD3D9::RenderLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
|
hasAlpha = cairoImage->mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
|
||||||
size = cairoImage->mSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureD3D9BackendData *data =
|
TextureD3D9BackendData *data =
|
||||||
@ -433,8 +432,8 @@ ImageLayerD3D9::RenderLayer()
|
|||||||
device()->SetVertexShaderConstantF(CBvLayerQuad,
|
device()->SetVertexShaderConstantF(CBvLayerQuad,
|
||||||
ShaderConstantRect(0,
|
ShaderConstantRect(0,
|
||||||
0,
|
0,
|
||||||
yuvImage->mSize.width,
|
size.width,
|
||||||
yuvImage->mSize.height),
|
size.height),
|
||||||
1);
|
1);
|
||||||
|
|
||||||
device()->SetVertexShaderConstantF(CBvTextureCoords,
|
device()->SetVertexShaderConstantF(CBvTextureCoords,
|
||||||
|
@ -230,6 +230,8 @@ ImageLayerOGL::RenderLayer(int,
|
|||||||
|
|
||||||
NS_ASSERTION(image->GetFormat() != Image::REMOTE_IMAGE_BITMAP,
|
NS_ASSERTION(image->GetFormat() != Image::REMOTE_IMAGE_BITMAP,
|
||||||
"Remote images aren't handled yet in OGL layers!");
|
"Remote images aren't handled yet in OGL layers!");
|
||||||
|
NS_ASSERTION(mScaleMode == SCALE_NONE || image->GetSize() == mScaleToSize,
|
||||||
|
"Scale modes other than none not handled yet in OGL layers!");
|
||||||
|
|
||||||
if (image->GetFormat() == Image::PLANAR_YCBCR) {
|
if (image->GetFormat() == Image::PLANAR_YCBCR) {
|
||||||
PlanarYCbCrImage *yuvImage =
|
PlanarYCbCrImage *yuvImage =
|
||||||
|
Loading…
Reference in New Issue
Block a user