Example #1
0
void
LayerManagerOGL::SetupPipeline(int aWidth, int aHeight, WorldTransforPolicy aTransformPolicy)
{
    // Set the viewport correctly.
    mGLContext->fViewport(0, 0, aWidth, aHeight);

    // We flip the view matrix around so that everything is right-side up; we're
    // drawing directly into the window's back buffer, so this keeps things
    // looking correct.
    //
    // XXX: We keep track of whether the window size changed, so we could skip
    // this update if it hadn't changed since the last call. We will need to
    // track changes to aTransformPolicy and mWorldMatrix for this to work
    // though.

    // Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
    // 2, 2) and flip the contents.
    gfxMatrix viewMatrix;
    viewMatrix.Translate(-gfxPoint(1.0, -1.0));
    viewMatrix.Scale(2.0f / float(aWidth), 2.0f / float(aHeight));
    viewMatrix.Scale(1.0f, -1.0f);

    if (aTransformPolicy == ApplyWorldTransform) {
        viewMatrix = mWorldMatrix * viewMatrix;
    }

    gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
    matrix3d._33 = 0.0f;

    SetLayerProgramProjectionMatrix(matrix3d);
}
void
CompositorOGL::PrepareViewport(const gfx::IntSize& aSize,
                               const gfxMatrix& aWorldTransform)
{
  // Set the viewport correctly.
  mGLContext->fViewport(0, 0, aSize.width, aSize.height);

  // We flip the view matrix around so that everything is right-side up; we're
  // drawing directly into the window's back buffer, so this keeps things
  // looking correct.
  // XXX: We keep track of whether the window size changed, so we could skip
  // this update if it hadn't changed since the last call. We will need to
  // track changes to aTransformPolicy and aWorldTransform for this to work
  // though.

  // Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0,
  // 2, 2) and flip the contents.
  gfxMatrix viewMatrix;
  viewMatrix.Translate(-gfxPoint(1.0, -1.0));
  viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
  viewMatrix.Scale(1.0f, -1.0f);
  if (!mTarget) {
    viewMatrix.Translate(gfxPoint(mRenderOffset.x, mRenderOffset.y));
  }

  viewMatrix = aWorldTransform * viewMatrix;

  gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix);
  matrix3d._33 = 0.0f;

  SetLayerProgramProjectionMatrix(matrix3d);
}