Backing out changeset 1ff04cca465b (bug 956266) due to compilation failures on Android.
authorMarkus Stange <mstange@themasta.com>
Wed, 08 Jan 2014 11:36:13 +0100
changeset 167877 7c991409dc20fe7e1e65cca21143d15d9e1679d6
parent 167873 9bbdc400dc1fdd9b577dbf89fd176479894dee55
child 167879 eda85da692679a9b300490889f0cd0198ea52d5e
push idunknown
push userunknown
push dateunknown
bugs956266
milestone29.0a1
Backing out changeset 1ff04cca465b (bug 956266) due to compilation failures on Android.
gfx/gl/DecomposeIntoNoRepeatTriangles.cpp
gfx/gl/DecomposeIntoNoRepeatTriangles.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
--- a/gfx/gl/DecomposeIntoNoRepeatTriangles.cpp
+++ b/gfx/gl/DecomposeIntoNoRepeatTriangles.cpp
@@ -1,38 +1,24 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "DecomposeIntoNoRepeatTriangles.h"
-#include "gfxMatrix.h"
 
 namespace mozilla {
 namespace gl {
 
 void
 RectTriangles::addRect(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
                        GLfloat tx0, GLfloat ty0, GLfloat tx1, GLfloat ty1,
                        bool flip_y /* = false */)
 {
-    if (vertexCoords.IsEmpty() &&
-        x0 == 0.0f && y0 == 0.0f && x1 == 1.0f && y1 == 1.0f) {
-      mIsSimpleQuad = true;
-      if (flip_y) {
-        mTextureTransform = gfx3DMatrix::From2D(gfxMatrix(tx1 - tx0, 0, 0, ty0 - ty1, tx0, ty1));
-      } else {
-        mTextureTransform = gfx3DMatrix::From2D(gfxMatrix(tx1 - tx0, 0, 0, ty1 - ty0, tx0, ty0));
-      }
-    } else if (mIsSimpleQuad) {
-      mIsSimpleQuad = false;
-      mTextureTransform = gfx3DMatrix();
-    }
-
     vert_coord v;
     v.x = x0; v.y = y0;
     vertexCoords.AppendElement(v);
     v.x = x1; v.y = y0;
     vertexCoords.AppendElement(v);
     v.x = x0; v.y = y1;
     vertexCoords.AppendElement(v);
 
--- a/gfx/gl/DecomposeIntoNoRepeatTriangles.h
+++ b/gfx/gl/DecomposeIntoNoRepeatTriangles.h
@@ -5,44 +5,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DecomposeIntoNoRepeatTriangles_h_
 #define DecomposeIntoNoRepeatTriangles_h_
 
 #include "GLTypes.h"
 #include "nsRect.h"
 #include "nsTArray.h"
-#include "gfx3DMatrix.h"
 
 namespace mozilla {
 namespace gl {
 
 /** Helper for DecomposeIntoNoRepeatTriangles
   */
 class RectTriangles {
 public:
-    RectTriangles() : mIsSimpleQuad(false) { }
+    RectTriangles() { }
 
     // Always pass texture coordinates upright. If you want to flip the
     // texture coordinates emitted to the tex_coords array, set flip_y to
     // true.
     void addRect(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
                   GLfloat tx0, GLfloat ty0, GLfloat tx1, GLfloat ty1,
                   bool flip_y = false);
 
-    // Returns whether this object is made of only one rect that can be drawn
-    // with a pre-buffered unity quad which has 0,0,1,1 as both vertex
-    // positions and texture coordinates.
-    // aOutTextureTransform returns the transform that maps 0,0,1,1 texture
-    // coordinates to the correct ones.
-    bool IsSimpleQuad(gfx3DMatrix& aOutTextureTransform) const {
-      aOutTextureTransform = mTextureTransform;
-      return mIsSimpleQuad;
-    }
-
     /**
       * these return a float pointer to the start of each array respectively.
       * Use it for glVertexAttribPointer calls.
       * We can return nullptr if we choose to use Vertex Buffer Objects here.
       */
     float* vertexPointer() {
         return &vertexCoords[0].x;
     }
@@ -56,18 +45,16 @@ public:
     }
 
     typedef struct { GLfloat x,y; } vert_coord;
     typedef struct { GLfloat u,v; } tex_coord;
 private:
     // default is 4 rectangles, each made up of 2 triangles (3 coord vertices each)
     nsAutoTArray<vert_coord, 6> vertexCoords;
     nsAutoTArray<tex_coord, 6>  texCoords;
-    gfx3DMatrix mTextureTransform;
-    bool mIsSimpleQuad;
 };
 
 /**
   * Decompose drawing the possibly-wrapped aTexCoordRect rectangle
   * of a texture of aTexSize into one or more rectangles (represented
   * as 2 triangles) and associated tex coordinates, such that
   * we don't have to use the REPEAT wrap mode. If aFlipY is true, the
   * texture coordinates will be specified vertically flipped.
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -552,29 +552,25 @@ CompositorOGL::Initialize()
     // We have to dispatch an event to the main thread to read the pref.
     NS_DispatchToMainThread(new ReadDrawFPSPref());
   }
 
   reporter.SetSuccessful();
   return true;
 }
 
-// |aTextureTransform| is the texture transform that will be set on
-// aProg, possibly multiplied with another texture transform of our
-// own.
 // |aTexCoordRect| is the rectangle from the texture that we want to
 // draw using the given program.  The program already has a necessary
 // offset and scale, so the geometry that needs to be drawn is a unit
 // square from 0,0 to 1,1.
 //
 // |aTexture| is the texture we are drawing. Its actual size can be
 // larger than the rectangle given by |aTexCoordRect|.
 void
 CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
-                                              const gfx3DMatrix& aTextureTransform,
                                               const Rect& aTexCoordRect,
                                               TextureSource *aTexture)
 {
   // Given what we know about these textures and coordinates, we can
   // compute fmod(t, 1.0f) to get the same texture coordinate out.  If
   // the texCoordRect dimension is < 0 or > width/height, then we have
   // wraparound that we need to deal with by drawing multiple quads,
   // because we can't rely on full non-power-of-two texture support
@@ -621,24 +617,17 @@ CompositorOGL::BindAndDrawQuadWithTextur
   } else {
     nsIntRect tcRect(texCoordRect.x, texCoordRect.y,
                      texCoordRect.width, texCoordRect.height);
     DecomposeIntoNoRepeatTriangles(tcRect,
                                    nsIntSize(realTexSize.width, realTexSize.height),
                                    rects, flipped);
   }
 
-  gfx3DMatrix textureTransform;
-  if (rects.IsSimpleQuad(textureTransform)) {
-    aProg->SetTextureTransform(aTextureTransform * textureTransform);
-    BindAndDrawQuad(aProg, false);
-  } else {
-    aProg->SetTextureTransform(aTextureTransform);
-    DrawQuads(mGLContext, mVBOs, aProg, rects);
-  }
+  DrawQuads(mGLContext, mVBOs, aProg, rects);
 }
 
 void
 CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
                                const gfxMatrix& aWorldTransform)
 {
   // Set the viewport correctly.
   mGLContext->fViewport(0, 0, aSize.width, aSize.height);
@@ -1197,16 +1186,19 @@ CompositorOGL::DrawQuadInternal(const Re
 
       if (!texturedEffect->mPremultiplied) {
         mGLContext->fBlendFuncSeparate(LOCAL_GL_SRC_ALPHA, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                                        LOCAL_GL_ONE, LOCAL_GL_ONE);
       }
 
       AutoBindTexture bindSource(mGLContext, source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
 
+      gfx3DMatrix textureTransform = source->AsSourceOGL()->GetTextureTransform();
+      program->SetTextureTransform(textureTransform);
+
       GraphicsFilter filter = ThebesFilter(texturedEffect->mFilter);
       gfxMatrix textureTransform2D;
 #ifdef MOZ_WIDGET_ANDROID
       if (filter != GraphicsFilter::FILTER_NEAREST &&
           aTransform.Is2DIntegerTranslation() &&
           textureTransform.Is2D(&textureTransform2D) &&
           textureTransform2D.HasOnlyIntegerTranslation()) {
         // On Android we encounter small resampling errors in what should be
@@ -1221,18 +1213,17 @@ CompositorOGL::DrawQuadInternal(const Re
       program->SetTextureUnit(0);
       program->SetLayerOpacity(aOpacity);
 
       AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1);
       if (maskType != MaskNone) {
         BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE1, maskQuadTransform);
       }
 
-      BindAndDrawQuadWithTextureRect(program, source->AsSourceOGL()->GetTextureTransform(),
-                                     texturedEffect->mTextureCoords, source);
+      BindAndDrawQuadWithTextureRect(program, texturedEffect->mTextureCoords, source);
 
       if (!texturedEffect->mPremultiplied) {
         mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                                        LOCAL_GL_ONE, LOCAL_GL_ONE);
       }
     }
     break;
   case EFFECT_YCBCR: {
@@ -1255,25 +1246,23 @@ CompositorOGL::DrawQuadInternal(const Re
       ApplyFilterToBoundTexture(mGLContext, filter);
       AutoBindTexture bindCb(mGLContext, sourceCb, LOCAL_GL_TEXTURE1);
       ApplyFilterToBoundTexture(mGLContext, filter);
       AutoBindTexture bindCr(mGLContext, sourceCr, LOCAL_GL_TEXTURE2);
       ApplyFilterToBoundTexture(mGLContext, filter);
 
       program->SetYCbCrTextureUnits(Y, Cb, Cr);
       program->SetLayerOpacity(aOpacity);
+      program->SetTextureTransform(gfx3DMatrix());
 
       AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE3);
       if (maskType != MaskNone) {
         BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE3, maskQuadTransform);
       }
-      BindAndDrawQuadWithTextureRect(program,
-                                     gfx3DMatrix(),
-                                     effectYCbCr->mTextureCoords,
-                                     sourceYCbCr->GetSubSource(Y));
+      BindAndDrawQuadWithTextureRect(program, effectYCbCr->mTextureCoords, sourceYCbCr->GetSubSource(Y));
     }
     break;
   case EFFECT_RENDER_TARGET: {
       EffectRenderTarget* effectRenderTarget =
         static_cast<EffectRenderTarget*>(aEffectChain.mPrimaryEffect.get());
       RefPtr<CompositingRenderTargetOGL> surface
         = static_cast<CompositingRenderTargetOGL*>(effectRenderTarget->mRenderTarget.get());
 
@@ -1338,27 +1327,25 @@ CompositorOGL::DrawQuadInternal(const Re
         AutoBindTexture bindSourceOnBlack(mGLContext, sourceOnBlack, LOCAL_GL_TEXTURE0);
         AutoBindTexture bindSourceOnWhite(mGLContext, sourceOnWhite, LOCAL_GL_TEXTURE1);
 
         program->Activate();
         program->SetBlackTextureUnit(0);
         program->SetWhiteTextureUnit(1);
         program->SetLayerOpacity(aOpacity);
         program->SetLayerTransform(aTransform);
+        program->SetTextureTransform(gfx3DMatrix());
         program->SetRenderOffset(offset.x, offset.y);
         program->SetLayerQuadRect(aRect);
         AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE2);
         if (maskType != MaskNone) {
           BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
         }
 
-        BindAndDrawQuadWithTextureRect(program,
-                                       gfx3DMatrix(),
-                                       effectComponentAlpha->mTextureCoords,
-                                       effectComponentAlpha->mOnBlack);
+        BindAndDrawQuadWithTextureRect(program, effectComponentAlpha->mTextureCoords, effectComponentAlpha->mOnBlack);
 
         mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
                                        LOCAL_GL_ONE, LOCAL_GL_ONE);
       }
     }
     break;
   default:
     MOZ_ASSERT(false, "Unhandled effect type");
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -304,17 +304,16 @@ private:
   void BindAndDrawQuad(GLuint aVertAttribIndex,
                        GLuint aTexCoordAttribIndex,
                        bool aFlipped = false,
                        GLuint aDrawMode = LOCAL_GL_TRIANGLE_STRIP);
   void BindAndDrawQuad(ShaderProgramOGL *aProg,
                        bool aFlipped = false,
                        GLuint aDrawMode = LOCAL_GL_TRIANGLE_STRIP);
   void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
-                                      const gfx3DMatrix& aTextureTransform,
                                       const gfx::Rect& aTexCoordRect,
                                       TextureSource *aTexture);
 
   void CleanupResources();
 
   /**
    * Copies the content of our backbuffer to the set transaction target.
    * Does not restore the target FBO, so only call from EndFrame.