Bug 952977: Various other changes of gfx3DMatrix -> Matrix4x4 r=nical

This commit is contained in:
David Zbarsky 2014-08-22 09:40:02 -04:00
parent 4b4513563e
commit 07112b161c
5 changed files with 31 additions and 22 deletions

View File

@ -100,6 +100,8 @@ using namespace mozilla::layers;
using namespace mozilla::gl;
using namespace mozilla::widget;
using mozilla::gfx::Matrix4x4;
#undef DEBUG_UPDATE
#undef INVALIDATE_DEBUGGING // flash areas as they are invalidated
@ -325,7 +327,7 @@ public:
void Draw(mozilla::layers::GLManager* aManager,
const nsIntPoint& aLocation,
const gfx3DMatrix& aTransform = gfx3DMatrix());
const Matrix4x4& aTransform = Matrix4x4());
static nsIntSize TextureSizeForSize(const nsIntSize& aSize);
@ -2522,8 +2524,8 @@ nsChildView::MaybeDrawRoundedCorners(GLManager* aManager, const nsIntRect& aRect
aManager->gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA,
LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA);
gfx3DMatrix flipX = gfx3DMatrix::ScalingMatrix(-1, 1, 1);
gfx3DMatrix flipY = gfx3DMatrix::ScalingMatrix(1, -1, 1);
Matrix4x4 flipX = Matrix4x4().Scale(-1, 1, 1);
Matrix4x4 flipY = Matrix4x4().Scale(1, -1, 1);
if (mIsCoveringTitlebar && !mIsFullscreen) {
// Mask the top corners.
@ -2849,7 +2851,7 @@ RectTextureImage::UpdateFromDrawTarget(const nsIntSize& aNewSize,
void
RectTextureImage::Draw(GLManager* aManager,
const nsIntPoint& aLocation,
const gfx3DMatrix& aTransform)
const Matrix4x4& aTransform)
{
ShaderProgramOGL* program = aManager->GetProgram(LOCAL_GL_TEXTURE_RECTANGLE_ARB,
gfx::SurfaceFormat::R8G8B8A8);
@ -2858,8 +2860,7 @@ RectTextureImage::Draw(GLManager* aManager,
program->Activate();
program->SetProjectionMatrix(aManager->GetProjMatrix());
gfx::Matrix4x4 transform = gfx::ToMatrix4x4(aTransform);
program->SetLayerTransform(transform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0));
program->SetLayerTransform(aTransform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0));
program->SetTextureTransform(gfx::Matrix4x4());
program->SetRenderOffset(nsIntPoint(0, 0));
program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height);

View File

@ -59,6 +59,7 @@
#define LAYER_COUNT_INCREMENTS 5
using namespace android;
using namespace mozilla::gfx;
using namespace mozilla::layers;
namespace mozilla {
@ -193,8 +194,8 @@ HwcComposer2D::setHwcGeometry(bool aGeometryChanged)
bool
HwcComposer2D::PrepareLayerList(Layer* aLayer,
const nsIntRect& aClip,
const gfxMatrix& aParentTransform,
const gfxMatrix& aGLWorldTransform)
const Matrix& aParentTransform,
const Matrix& aGLWorldTransform)
{
// NB: we fall off this path whenever there are container layers
// that require intermediate surfaces. That means all the
@ -234,8 +235,8 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
//
// A 2D transform with PreservesAxisAlignedRectangles() has all the attributes
// above
gfxMatrix transform;
gfx3DMatrix transform3D = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
Matrix transform;
Matrix4x4 transform3D = aLayer->GetEffectiveTransform();
if (!transform3D.Is2D(&transform) || !transform.PreservesAxisAlignedRectangles()) {
LOGD("Layer has a 3D transform or a non-square angle rotation");
@ -377,7 +378,7 @@ HwcComposer2D::PrepareLayerList(Layer* aLayer,
// And ignore scaling.
//
// Reflection is applied before rotation
gfxMatrix rotation = transform * aGLWorldTransform;
gfx::Matrix rotation = transform * aGLWorldTransform;
// Compute fuzzy zero like PreservesAxisAlignedRectangles()
if (fabs(rotation._11) < 1e-6) {
if (rotation._21 < 0) {
@ -775,10 +776,9 @@ HwcComposer2D::Reset()
bool
HwcComposer2D::TryRender(Layer* aRoot,
const gfx::Matrix& GLWorldTransform,
const gfx::Matrix& aGLWorldTransform,
bool aGeometryChanged)
{
gfxMatrix aGLWorldTransform = ThebesMatrix(GLWorldTransform);
if (!aGLWorldTransform.PreservesAxisAlignedRectangles()) {
LOGD("Render aborted. World transform has non-square angle rotation");
return false;
@ -802,7 +802,7 @@ HwcComposer2D::TryRender(Layer* aRoot,
MOZ_ASSERT(mHwcLayerMap.IsEmpty());
if (!PrepareLayerList(aRoot,
mScreenRect,
gfxMatrix(),
gfx::Matrix(),
aGLWorldTransform))
{
mHwcLayerMap.Clear();

View File

@ -94,7 +94,7 @@ private:
bool TryHwComposition();
bool ReallocLayerList();
bool PrepareLayerList(layers::Layer* aContainer, const nsIntRect& aClip,
const gfxMatrix& aParentTransform, const gfxMatrix& aGLWorldTransform);
const gfx::Matrix& aParentTransform, const gfx::Matrix& aGLWorldTransform);
void setCrop(HwcLayer* layer, hwc_rect_t srcCrop);
void setHwcGeometry(bool aGeometryChanged);
void SendtoLayerScope();

View File

@ -17,6 +17,7 @@
#include <android/log.h>
#include "HwcUtils.h"
#include "gfxUtils.h"
#include "gfx2DGlue.h"
#define LOG_TAG "HwcUtils"
@ -36,11 +37,12 @@ namespace mozilla {
/* static */ bool
HwcUtils::PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
HwcUtils::PrepareLayerRects(nsIntRect aVisible, const gfx::Matrix& transform,
nsIntRect aClip, nsIntRect aBufferRect,
bool aYFlipped,
hwc_rect_t* aSourceCrop, hwc_rect_t* aVisibleRegionScreen) {
gfxMatrix aTransform = gfx::ThebesMatrix(transform);
gfxRect visibleRect(aVisible);
gfxRect clip(aClip);
gfxRect visibleRectScreen = aTransform.TransformBounds(visibleRect);
@ -51,7 +53,7 @@ HwcUtils::PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
return false;
}
gfxMatrix inverse(aTransform);
gfxMatrix inverse = aTransform;
inverse.Invert();
gfxRect crop = inverse.TransformBounds(visibleRectScreen);
@ -88,10 +90,11 @@ HwcUtils::PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
/* static */ bool
HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible,
const gfxMatrix& aTransform,
const gfx::Matrix& transform,
nsIntRect aClip, nsIntRect aBufferRect,
RectVector* aVisibleRegionScreen) {
gfxMatrix aTransform = gfx::ThebesMatrix(transform);
nsIntRegionRectIterator rect(aVisible);
bool isVisible = false;
while (const nsIntRect* visibleRect = rect.Next()) {
@ -117,10 +120,11 @@ HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible,
}
/* static */ bool
HwcUtils::CalculateClipRect(const gfxMatrix& aTransform,
HwcUtils::CalculateClipRect(const gfx::Matrix& transform,
const nsIntRect* aLayerClip,
nsIntRect aParentClip, nsIntRect* aRenderClip) {
gfxMatrix aTransform = gfx::ThebesMatrix(transform);
*aRenderClip = aParentClip;
if (!aLayerClip) {

View File

@ -23,6 +23,10 @@
namespace mozilla {
namespace gfx {
class Matrix;
}
class HwcUtils {
public:
@ -62,7 +66,7 @@ typedef std::vector<hwc_rect_t> RectVector;
* @return true if the layer should be rendered.
* false if the layer can be skipped
*/
static bool CalculateClipRect(const gfxMatrix& aTransform,
static bool CalculateClipRect(const gfx::Matrix& aTransform,
const nsIntRect* aLayerClip,
nsIntRect aParentClip, nsIntRect* aRenderClip);
@ -84,7 +88,7 @@ static bool CalculateClipRect(const gfxMatrix& aTransform,
* false if the layer can be skipped
*/
static bool PrepareVisibleRegion(const nsIntRegion& aVisible,
const gfxMatrix& aTransform,
const gfx::Matrix& aTransform,
nsIntRect aClip, nsIntRect aBufferRect,
RectVector* aVisibleRegionScreen);
@ -108,7 +112,7 @@ static bool PrepareVisibleRegion(const nsIntRegion& aVisible,
* @return true if the layer should be rendered.
* false if the layer can be skipped
*/
static bool PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
static bool PrepareLayerRects(nsIntRect aVisible, const gfx::Matrix& aTransform,
nsIntRect aClip, nsIntRect aBufferRect,
bool aYFlipped,
hwc_rect_t* aSourceCrop,