Bug 621227 - Optimize thebes layer render function. r=vladimir a=approval2.0
authorOleg Romashin <romaxa@gmail.com>
Tue, 04 Jan 2011 17:37:22 +0200
changeset 59837 566d6ebc113e598d0fb9bf266cb7bcd315d92bfc
parent 59836 8075249cd0507666b50f8fff2fc2bdea38ead484
child 59838 88a95c3e9373ed3d06bf8afa3d68752577d6ee07
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersvladimir, approval2.0
bugs621227
milestone2.0b9pre
Bug 621227 - Optimize thebes layer render function. r=vladimir a=approval2.0
gfx/layers/opengl/ThebesLayerOGL.cpp
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -190,25 +190,26 @@ ThebesLayerBufferOGL::RenderTo(const nsI
   // Note BGR: Cairo's image surfaces are always in what
   // OpenGL and our shaders consider BGR format.
   ColorTextureLayerProgram *program =
     aManager->GetColorTextureLayerProgram(mTexImage->GetShaderProgramType());
 
   float xres = mLayer->GetXResolution();
   float yres = mLayer->GetYResolution();
 
+  program->Activate();
+  program->SetLayerOpacity(mLayer->GetEffectiveOpacity());
+  program->SetLayerTransform(mLayer->GetEffectiveTransform());
+  program->SetRenderOffset(aOffset);
+  program->SetTextureUnit(0);
+
   nsIntRegionRectIterator iter(mLayer->GetEffectiveVisibleRegion());
   while (const nsIntRect *iterRect = iter.Next()) {
     nsIntRect quadRect = *iterRect;
-    program->Activate();
     program->SetLayerQuadRect(quadRect);
-    program->SetLayerOpacity(mLayer->GetEffectiveOpacity());
-    program->SetLayerTransform(mLayer->GetEffectiveTransform());
-    program->SetRenderOffset(aOffset);
-    program->SetTextureUnit(0);
     DEBUG_GL_ERROR_CHECK(gl());
 
     quadRect.MoveBy(-GetOriginOffset());
 
     // The buffer rect and rotation are resolution-neutral; with a
     // non-1.0 resolution, only the texture size is scaled by the
     // resolution.  So map the quadrent rect into the space scaled to
     // the texture size and let GL do the rest.