mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Backed out changeset a5ec817740f0. a=orange
This commit is contained in:
parent
8a52f4b99f
commit
9167d8acf3
@ -67,7 +67,6 @@
|
||||
#include "nsSVGFilterElement.h"
|
||||
#include "nsSVGString.h"
|
||||
#include "nsSVGEffects.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// Prevent Windows redefining LoadImage
|
||||
@ -175,7 +174,7 @@ nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance,
|
||||
r.Scale(gfxFloat(scaledSize.width)/aTarget->mImage->Width(),
|
||||
gfxFloat(scaledSize.height)/aTarget->mImage->Height());
|
||||
r.RoundOut();
|
||||
if (!gfxUtils::GfxRectToIntRect(r, &result.mDataRect))
|
||||
if (NS_FAILED(nsLayoutUtils::GfxRectToIntRect(r, &result.mDataRect)))
|
||||
return result;
|
||||
|
||||
#ifdef DEBUG_tor
|
||||
@ -2964,9 +2963,9 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance,
|
||||
// but nothing clips mFilterPrimitiveSubregion so this should be changed.
|
||||
|
||||
nsIntRect tile;
|
||||
PRBool res = gfxUtils::GfxRectToIntRect(aSources[0]->mFilterPrimitiveSubregion, &tile);
|
||||
nsresult res = nsLayoutUtils::GfxRectToIntRect(aSources[0]->mFilterPrimitiveSubregion, &tile);
|
||||
|
||||
NS_ENSURE_TRUE(res, NS_ERROR_FAILURE); // asserts on failure (not
|
||||
NS_ENSURE_SUCCESS(res, res); // asserts on failure (not
|
||||
if (tile.IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
|
@ -333,9 +333,7 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const gfx3DMatrix& aTransformT
|
||||
useIntermediateSurface = PR_TRUE;
|
||||
} else {
|
||||
useIntermediateSurface = PR_FALSE;
|
||||
gfxMatrix contTransform;
|
||||
if (!mEffectiveTransform.Is2D(&contTransform) ||
|
||||
!contTransform.PreservesAxisAlignedRectangles()) {
|
||||
if (!mEffectiveTransform.IsIdentity()) {
|
||||
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
||||
const nsIntRect *clipRect = child->GetEffectiveClipRect();
|
||||
/* We can't (easily) forward our transform to children with a non-empty clip
|
||||
|
@ -37,8 +37,6 @@
|
||||
|
||||
#include "ContainerLayerD3D10.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -145,15 +143,6 @@ ContainerLayerD3D10::GetFirstChildD3D10()
|
||||
return static_cast<LayerD3D10*>(mFirstChild->ImplData());
|
||||
}
|
||||
|
||||
static inline LayerD3D10*
|
||||
GetNextSiblingD3D10(LayerD3D10* aLayer)
|
||||
{
|
||||
Layer* layer = aLayer->GetLayer()->GetNextSibling();
|
||||
return layer ? static_cast<LayerD3D10*>(layer->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D10::RenderLayer()
|
||||
{
|
||||
@ -171,7 +160,6 @@ ContainerLayerD3D10::RenderLayer()
|
||||
|
||||
gfx3DMatrix oldViewMatrix;
|
||||
|
||||
gfxMatrix contTransform;
|
||||
if (useIntermediate) {
|
||||
device()->OMGetRenderTargets(1, getter_AddRefs(previousRTView), NULL);
|
||||
|
||||
@ -204,26 +192,14 @@ ContainerLayerD3D10::RenderLayer()
|
||||
|
||||
previousViewportSize = mD3DManager->GetViewport();
|
||||
mD3DManager->SetViewport(nsIntSize(visibleRect.Size()));
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PRBool is2d =
|
||||
#endif
|
||||
GetEffectiveTransform().Is2D(&contTransform);
|
||||
NS_ASSERTION(is2d, "Transform must be 2D");
|
||||
}
|
||||
|
||||
/*
|
||||
* Render this container's contents.
|
||||
*/
|
||||
for (LayerD3D10* layerToRender = GetFirstChildD3D10();
|
||||
layerToRender != nsnull;
|
||||
layerToRender = GetNextSiblingD3D10(layerToRender)) {
|
||||
|
||||
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
|
||||
if ((clipRect && clipRect->IsEmpty()) ||
|
||||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
LayerD3D10 *layerToRender = GetFirstChildD3D10();
|
||||
while (layerToRender) {
|
||||
const nsIntRect *clipRect = layerToRender->GetLayer()->GetClipRect();
|
||||
|
||||
D3D10_RECT oldScissor;
|
||||
if (clipRect || useIntermediate) {
|
||||
@ -246,24 +222,6 @@ ContainerLayerD3D10::RenderLayer()
|
||||
|
||||
D3D10_RECT d3drect;
|
||||
if (!useIntermediate) {
|
||||
if (clipRect) {
|
||||
gfxRect cliprect(r.left, r.top, r.left + r.right, r.top + r.bottom);
|
||||
gfxRect trScissor = contTransform.TransformBounds(cliprect);
|
||||
trScissor.Round();
|
||||
nsIntRect trIntScissor;
|
||||
if (gfxUtils::GfxRectToIntRect(trScissor, &trIntScissor)) {
|
||||
r.left = trIntScissor.x;
|
||||
r.top = trIntScissor.y;
|
||||
r.right = trIntScissor.XMost();
|
||||
r.bottom = trIntScissor.YMost();
|
||||
} else {
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = visibleRect.width;
|
||||
r.bottom = visibleRect.height;
|
||||
clipRect = nsnull;
|
||||
}
|
||||
}
|
||||
// Scissor rect should be an intersection of the old and current scissor.
|
||||
r.left = NS_MAX<PRInt32>(oldScissor.left, r.left);
|
||||
r.right = NS_MIN<PRInt32>(oldScissor.right, r.right);
|
||||
@ -273,6 +231,10 @@ ContainerLayerD3D10::RenderLayer()
|
||||
|
||||
if (r.left >= r.right || r.top >= r.bottom) {
|
||||
// Entire layer's clipped out, don't bother drawing.
|
||||
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
|
||||
layerToRender = nextSibling ? static_cast<LayerD3D10*>(nextSibling->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -290,6 +252,11 @@ ContainerLayerD3D10::RenderLayer()
|
||||
if (clipRect || useIntermediate) {
|
||||
device()->RSSetScissorRects(1, &oldScissor);
|
||||
}
|
||||
|
||||
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
|
||||
layerToRender = nextSibling ? static_cast<LayerD3D10*>(nextSibling->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
if (useIntermediate) {
|
||||
|
@ -36,8 +36,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "ContainerLayerD3D9.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -144,15 +142,6 @@ ContainerLayerD3D9::GetFirstChildD3D9()
|
||||
return static_cast<LayerD3D9*>(mFirstChild->ImplData());
|
||||
}
|
||||
|
||||
static inline LayerD3D9*
|
||||
GetNextSiblingD3D9(LayerD3D9* aLayer)
|
||||
{
|
||||
Layer* layer = aLayer->GetLayer()->GetNextSibling();
|
||||
return layer ? static_cast<LayerD3D9*>(layer->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D9::RenderLayer()
|
||||
{
|
||||
@ -166,7 +155,6 @@ ContainerLayerD3D9::RenderLayer()
|
||||
nsIntRect visibleRect = mVisibleRegion.GetBounds();
|
||||
PRBool useIntermediate = UseIntermediateSurface();
|
||||
|
||||
gfxMatrix contTransform;
|
||||
if (useIntermediate) {
|
||||
device()->GetRenderTarget(0, getter_AddRefs(previousRenderTarget));
|
||||
device()->CreateTexture(visibleRect.width, visibleRect.height, 1,
|
||||
@ -194,27 +182,14 @@ ContainerLayerD3D9::RenderLayer()
|
||||
|
||||
device()->GetVertexShaderConstantF(CBmProjection, &oldViewMatrix[0][0], 4);
|
||||
device()->SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
PRBool is2d =
|
||||
#endif
|
||||
GetEffectiveTransform().Is2D(&contTransform);
|
||||
NS_ASSERTION(is2d, "Transform must be 2D");
|
||||
}
|
||||
|
||||
/*
|
||||
* Render this container's contents.
|
||||
*/
|
||||
for (LayerD3D9* layerToRender = GetFirstChildD3D9();
|
||||
layerToRender != nsnull;
|
||||
layerToRender = GetNextSiblingD3D9(layerToRender)) {
|
||||
|
||||
const nsIntRect* clipRect = layerToRender->GetLayer()->GetClipRect();
|
||||
if ((clipRect && clipRect->IsEmpty()) ||
|
||||
layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LayerD3D9 *layerToRender = GetFirstChildD3D9();
|
||||
while (layerToRender) {
|
||||
const nsIntRect *clipRect = layerToRender->GetLayer()->GetClipRect();
|
||||
if (clipRect || useIntermediate) {
|
||||
RECT r;
|
||||
device()->GetScissorRect(&oldClipRect);
|
||||
@ -237,25 +212,6 @@ ContainerLayerD3D9::RenderLayer()
|
||||
renderSurface->GetDesc(&desc);
|
||||
|
||||
if (!useIntermediate) {
|
||||
// Transform clip rect
|
||||
if (clipRect) {
|
||||
gfxRect cliprect(r.left, r.top, r.left + r.right, r.top + r.bottom);
|
||||
gfxRect trScissor = contTransform.TransformBounds(cliprect);
|
||||
trScissor.Round();
|
||||
nsIntRect trIntScissor;
|
||||
if (gfxUtils::GfxRectToIntRect(trScissor, &trIntScissor)) {
|
||||
r.left = trIntScissor.x;
|
||||
r.top = trIntScissor.y;
|
||||
r.right = trIntScissor.XMost();
|
||||
r.bottom = trIntScissor.YMost();
|
||||
} else {
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = visibleRect.width;
|
||||
r.bottom = visibleRect.height;
|
||||
clipRect = nsnull;
|
||||
}
|
||||
}
|
||||
// Intersect with current clip rect.
|
||||
r.left = NS_MAX<PRInt32>(oldClipRect.left, r.left);
|
||||
r.right = NS_MIN<PRInt32>(oldClipRect.right, r.right);
|
||||
@ -278,7 +234,10 @@ ContainerLayerD3D9::RenderLayer()
|
||||
device()->SetScissorRect(&oldClipRect);
|
||||
}
|
||||
|
||||
continue;
|
||||
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
|
||||
layerToRender = nextSibling ? static_cast<LayerD3D9*>(nextSibling->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
if (useIntermediate) {
|
||||
|
@ -36,7 +36,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "ContainerLayerOGL.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -129,15 +128,6 @@ ContainerDestroy(Container* aContainer)
|
||||
}
|
||||
}
|
||||
|
||||
static inline LayerOGL*
|
||||
GetNextSibling(LayerOGL* aLayer)
|
||||
{
|
||||
Layer* layer = aLayer->GetLayer()->GetNextSibling();
|
||||
return layer ? static_cast<LayerOGL*>(layer->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
template<class Container>
|
||||
static void
|
||||
ContainerRender(Container* aContainer,
|
||||
@ -160,7 +150,6 @@ ContainerRender(Container* aContainer,
|
||||
float opacity = aContainer->GetEffectiveOpacity();
|
||||
const gfx3DMatrix& transform = aContainer->GetEffectiveTransform();
|
||||
bool needsFramebuffer = aContainer->UseIntermediateSurface();
|
||||
gfxMatrix contTransform;
|
||||
if (needsFramebuffer) {
|
||||
aManager->CreateFBOWithTexture(visibleRect.width,
|
||||
visibleRect.height,
|
||||
@ -177,40 +166,18 @@ ContainerRender(Container* aContainer,
|
||||
aContainer->gl()->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
|
||||
} else {
|
||||
frameBuffer = aPreviousFrameBuffer;
|
||||
#ifdef DEBUG
|
||||
PRBool is2d =
|
||||
#endif
|
||||
transform.Is2D(&contTransform);
|
||||
NS_ASSERTION(is2d, "Transform must be 2D");
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this container's contents.
|
||||
*/
|
||||
for (LayerOGL* layerToRender = aContainer->GetFirstChildOGL();
|
||||
layerToRender != nsnull;
|
||||
layerToRender = GetNextSibling(layerToRender)) {
|
||||
|
||||
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LayerOGL *layerToRender = aContainer->GetFirstChildOGL();
|
||||
while (layerToRender) {
|
||||
nsIntRect scissorRect(visibleRect);
|
||||
|
||||
const nsIntRect *clipRect = layerToRender->GetLayer()->GetEffectiveClipRect();
|
||||
if (clipRect) {
|
||||
if (clipRect->IsEmpty()) {
|
||||
continue;
|
||||
}
|
||||
scissorRect = *clipRect;
|
||||
if (!needsFramebuffer) {
|
||||
gfxRect r(scissorRect.x, scissorRect.y, scissorRect.width, scissorRect.height);
|
||||
gfxRect trScissor = contTransform.TransformBounds(r);
|
||||
trScissor.Round();
|
||||
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissorRect)) {
|
||||
scissorRect = visibleRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsFramebuffer) {
|
||||
@ -248,6 +215,11 @@ ContainerRender(Container* aContainer,
|
||||
}
|
||||
|
||||
layerToRender->RenderLayer(frameBuffer, childOffset);
|
||||
|
||||
Layer *nextSibling = layerToRender->GetLayer()->GetNextSibling();
|
||||
layerToRender = nextSibling ? static_cast<LayerOGL*>(nextSibling->
|
||||
ImplData())
|
||||
: nsnull;
|
||||
}
|
||||
|
||||
aContainer->gl()->PopScissorRect();
|
||||
|
@ -35,6 +35,7 @@ EXPORTS = \
|
||||
gfxTypes.h \
|
||||
gfxTextRunCache.h \
|
||||
gfxTextRunWordCache.h \
|
||||
gfxThebesUtils.h \
|
||||
gfxUtils.h \
|
||||
gfxUserFontSet.h \
|
||||
GLDefs.h \
|
||||
@ -183,6 +184,7 @@ CPPSRCS = \
|
||||
gfxSkipChars.cpp \
|
||||
gfxTextRunCache.cpp \
|
||||
gfxTextRunWordCache.cpp \
|
||||
gfxThebesUtils.cpp \
|
||||
gfxUserFontSet.cpp \
|
||||
gfxUtils.cpp \
|
||||
gfxUnicodeProperties.cpp \
|
||||
|
@ -88,9 +88,8 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
||||
gfxRect skipRect = *aSkipRect;
|
||||
skipRect.RoundIn();
|
||||
skipRect.Inset(aBlurRadius + aSpreadRadius);
|
||||
gfxUtils::GfxRectToIntRect(skipRect, &mSkipRect);
|
||||
nsIntRect shadowIntRect;
|
||||
gfxUtils::GfxRectToIntRect(rect, &shadowIntRect);
|
||||
mSkipRect = gfxThebesUtils::GfxRectToIntRect(skipRect);
|
||||
nsIntRect shadowIntRect = gfxThebesUtils::GfxRectToIntRect(rect);
|
||||
mSkipRect.IntersectRect(mSkipRect, shadowIntRect);
|
||||
if (mSkipRect == shadowIntRect)
|
||||
return nsnull;
|
||||
|
@ -41,8 +41,7 @@
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxTypes.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "nsRect.h"
|
||||
#include "gfxThebesUtils.h"
|
||||
|
||||
/**
|
||||
* Implementation of a triple box blur approximation of a Gaussian blur.
|
||||
|
@ -265,15 +265,6 @@ public:
|
||||
*/
|
||||
void NudgeToIntegers(void);
|
||||
|
||||
/**
|
||||
* Returns true if matrix is multiple of 90 degrees rotation with flipping,
|
||||
* scaling and translation.
|
||||
*/
|
||||
PRBool PreservesAxisAlignedRectangles() const {
|
||||
return ((FuzzyEqual(xx, 0.0) && FuzzyEqual(yy, 0.0))
|
||||
|| (FuzzyEqual(xy, 0.0) && FuzzyEqual(yx, 0.0)));
|
||||
}
|
||||
|
||||
private:
|
||||
static PRBool FuzzyEqual(gfxFloat aV1, gfxFloat aV2) {
|
||||
return fabs(aV2 - aV1) < 1e-6;
|
||||
|
49
gfx/thebes/gfxThebesUtils.cpp
Normal file
49
gfx/thebes/gfxThebesUtils.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is gfx thebes code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Michael Ventnor <m.ventnor@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxThebesUtils.h"
|
||||
|
||||
// Converts a gfxRect to an nsIntRect for speed
|
||||
nsIntRect
|
||||
gfxThebesUtils::GfxRectToIntRect(const gfxRect& aIn)
|
||||
{
|
||||
nsIntRect result(PRInt32(aIn.X()), PRInt32(aIn.Y()),
|
||||
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
|
||||
NS_ASSERTION(gfxRect(result.x, result.y, result.width, result.height) == aIn,
|
||||
"The given gfxRect isn't rounded properly!");
|
||||
return result;
|
||||
}
|
53
gfx/thebes/gfxThebesUtils.h
Normal file
53
gfx/thebes/gfxThebesUtils.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is gfx thebes code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Michael Ventnor <m.ventnor@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxRect.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
#ifndef GFX_THEBES_UTILS_H
|
||||
#define GFX_THEBES_UTILS_H
|
||||
|
||||
class THEBES_API gfxThebesUtils
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Converts a gfxRect into nsIntRect for speed reasons.
|
||||
*/
|
||||
static nsIntRect GfxRectToIntRect(const gfxRect& aIn);
|
||||
};
|
||||
|
||||
#endif /* GFX_THEBES_UTILS_H */
|
@ -458,12 +458,3 @@ gfxUtils::ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion)
|
||||
{
|
||||
ClipToRegionInternal(aContext, aRegion, PR_TRUE);
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
|
||||
{
|
||||
*aOut = nsIntRect(PRInt32(aIn.X()), PRInt32(aIn.Y()),
|
||||
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
|
||||
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height) == aIn;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,6 @@
|
||||
|
||||
class gfxDrawable;
|
||||
class nsIntRegion;
|
||||
class nsIntRect;
|
||||
|
||||
class THEBES_API gfxUtils {
|
||||
public:
|
||||
@ -100,13 +99,6 @@ public:
|
||||
* Convert image format to depth value
|
||||
*/
|
||||
static int ImageFormatToDepth(gfxASurface::gfxImageFormat aFormat);
|
||||
|
||||
/**
|
||||
* If aIn can be represented exactly using an nsIntRect (i.e.
|
||||
* integer-aligned edges and coordinates in the PRInt32 range) then we
|
||||
* set aOut to that rectangle, otherwise return failure.
|
||||
*/
|
||||
static PRBool GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "nsSubDocumentFrame.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
@ -748,7 +747,7 @@ SetVisibleRectForLayer(Layer* aLayer, const nsIntRect& aRect)
|
||||
gfxRect(aRect.x, aRect.y, aRect.width, aRect.height));
|
||||
layerVisible.RoundOut();
|
||||
nsIntRect visibleRect;
|
||||
if (!gfxUtils::GfxRectToIntRect(layerVisible, &visibleRect)) {
|
||||
if (NS_FAILED(nsLayoutUtils::GfxRectToIntRect(layerVisible, &visibleRect))) {
|
||||
visibleRect = nsIntRect(0, 0, 0, 0);
|
||||
NS_WARNING("Visible rect transformed out of bounds");
|
||||
}
|
||||
|
@ -985,6 +985,15 @@ nsLayoutUtils::InvertTransformsToRoot(nsIFrame *aFrame,
|
||||
return MatrixTransformPoint(aPoint, ctm.Invert(), aFrame->PresContext()->AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLayoutUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
|
||||
{
|
||||
*aOut = nsIntRect(PRInt32(aIn.X()), PRInt32(aIn.Y()),
|
||||
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
|
||||
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height) == aIn
|
||||
? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
|
||||
nsIntPoint offset(0, 0);
|
||||
nsIWidget* parent = aWidget->GetParent();
|
||||
|
@ -512,6 +512,13 @@ public:
|
||||
*/
|
||||
static nsRect RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor);
|
||||
|
||||
/**
|
||||
* If aIn can be represented exactly using an nsIntRect (i.e.
|
||||
* integer-aligned edges and coordinates in the PRInt32 range) then we
|
||||
* set aOut to that rectangle, otherwise return failure.
|
||||
*/
|
||||
static nsresult GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
|
||||
|
||||
enum {
|
||||
PAINT_IN_TRANSFORM = 0x01,
|
||||
PAINT_SYNC_DECODE_IMAGES = 0x02,
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "nsSVGFilterPaintCallback.h"
|
||||
#include "nsSVGRect.h"
|
||||
#include "nsSVGFilterInstance.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
nsIFrame*
|
||||
NS_NewSVGFilterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
@ -68,7 +67,7 @@ MapDeviceRectToFilterSpace(const gfxMatrix& aMatrix,
|
||||
aDeviceRect->width, aDeviceRect->height));
|
||||
r.RoundOut();
|
||||
nsIntRect intRect;
|
||||
if (gfxUtils::GfxRectToIntRect(r, &intRect)) {
|
||||
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(r, &intRect))) {
|
||||
rect = intRect;
|
||||
}
|
||||
}
|
||||
@ -237,8 +236,9 @@ TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRe
|
||||
r = m.TransformBounds(r);
|
||||
r.RoundOut();
|
||||
nsIntRect deviceRect;
|
||||
if (!gfxUtils::GfxRectToIntRect(r, &deviceRect))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv = nsLayoutUtils::GfxRectToIntRect(r, &deviceRect);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
*aRect = deviceRect;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsSVGFilterPaintCallback.h"
|
||||
#include "nsSVGFilterElement.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
static double Square(double aX)
|
||||
{
|
||||
@ -166,7 +165,7 @@ nsSVGFilterInstance::BuildSources()
|
||||
gfxRect sourceBounds = UserSpaceToFilterSpace(mTargetBBox);
|
||||
sourceBounds.RoundOut();
|
||||
// Detect possible float->int overflow
|
||||
if (!gfxUtils::GfxRectToIntRect(sourceBounds, &sourceBoundsInt))
|
||||
if (NS_FAILED(nsLayoutUtils::GfxRectToIntRect(sourceBounds, &sourceBoundsInt)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mSourceColorAlpha.mResultBoundingBox = sourceBoundsInt;
|
||||
@ -357,8 +356,9 @@ nsSVGFilterInstance::BuildSourceImages()
|
||||
r = m.TransformBounds(r);
|
||||
r.RoundOut();
|
||||
nsIntRect dirty;
|
||||
if (!gfxUtils::GfxRectToIntRect(r, &dirty))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv = nsLayoutUtils::GfxRectToIntRect(r, &dirty);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// SVG graphics paint to device space, so we need to set an initial device
|
||||
// space to filter space transform on the gfxContext that SourceGraphic
|
||||
|
@ -92,7 +92,6 @@
|
||||
#include "prdtoa.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsIDOMSVGNumberList.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -638,7 +637,7 @@ nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
|
||||
TransformBounds(gfxRect(x, y, width, height));
|
||||
bounds.RoundOut();
|
||||
nsIntRect r;
|
||||
if (gfxUtils::GfxRectToIntRect(bounds, &r)) {
|
||||
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(bounds, &r))) {
|
||||
rect = r;
|
||||
} else {
|
||||
NS_NOTREACHED("Not going to invalidate the correct area");
|
||||
@ -957,7 +956,7 @@ public:
|
||||
gfxRect dirtyBounds = userToDeviceSpace.TransformBounds(
|
||||
gfxRect(aDirtyRect->x, aDirtyRect->y, aDirtyRect->width, aDirtyRect->height));
|
||||
dirtyBounds.RoundOut();
|
||||
if (gfxUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect)) {
|
||||
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect))) {
|
||||
dirtyRect = &tmpDirtyRect;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user