Bug 900133 - Only draw the picture rect of a tiled image. r=nical
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 01 Aug 2013 21:12:16 -0400
changeset 141169 9ea3f06786ea4c63d7e9c47e1dca01b31768a079
parent 141168 fc4eb733fd773f5ad0a011cb875564776e239a84
child 141170 b1b429edac78cf9c7c0ac5396534c759b08ac5cd
push id32003
push usermwoodrow@mozilla.com
push dateFri, 02 Aug 2013 17:05:20 +0000
treeherdermozilla-inbound@b1b429edac78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs900133
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 900133 - Only draw the picture rect of a tiled image. r=nical
gfx/layers/composite/ImageHost.cpp
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -62,38 +62,53 @@ ImageHost::Composite(EffectChain& aEffec
   RefPtr<NewTextureSource> source = mFrontBuffer->GetTextureSources();
   if (!source) {
     return;
   }
   RefPtr<TexturedEffect> effect = CreateTexturedEffect(mFrontBuffer->GetFormat(),
                                                        source,
                                                        aFilter);
   aEffectChain.mPrimaryEffect = effect;
+
+  gfx::Rect pictureRect(0, 0,
+                        mPictureRect.width,
+                        mPictureRect.height);
+  //XXX: We might have multiple texture sources here (e.g. 3 YCbCr textures), and we're
+  // only iterating over the tiles of the first one. Are we assuming that the tiling
+  // will be identical? Can we ensure that somehow?
   TileIterator* it = source->AsTileIterator();
   if (it) {
     it->BeginTileIteration();
     do {
       nsIntRect tileRect = it->GetTileRect();
       gfx::Rect rect(tileRect.x, tileRect.y, tileRect.width, tileRect.height);
+      if (mHasPictureRect) {
+        rect = rect.Intersect(pictureRect);
+        effect->mTextureCoords = Rect(Float(rect.x - tileRect.x)/ tileRect.width,
+                                      Float(rect.y - tileRect.y) / tileRect.height,
+                                      Float(rect.width) / tileRect.width,
+                                      Float(rect.height) / tileRect.height);
+      } else {
+        effect->mTextureCoords = Rect(0, 0, 1, 1);
+      }
       GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain,
                                 aOpacity, aTransform, aOffset);
       GetCompositor()->DrawDiagnostics(gfx::Color(0.5,0.0,0.0,1.0),
                                        rect, aClipRect, aTransform, aOffset);
     } while (it->NextTile());
     it->EndTileIteration();
   } else {
     IntSize textureSize = source->GetSize();
-    gfx::Rect rect(0, 0,
-                   mPictureRect.width,
-                   mPictureRect.height);
+    gfx::Rect rect;
     if (mHasPictureRect) {
       effect->mTextureCoords = Rect(Float(mPictureRect.x) / textureSize.width,
                                     Float(mPictureRect.y) / textureSize.height,
                                     Float(mPictureRect.width) / textureSize.width,
                                     Float(mPictureRect.height) / textureSize.height);
+      rect = pictureRect;
     } else {
       effect->mTextureCoords = Rect(0, 0, 1, 1);
       rect = gfx::Rect(0, 0, textureSize.width, textureSize.height);
     }
 
     if (mFrontBuffer->GetFlags() & NeedsYFlip) {
       effect->mTextureCoords.y = effect->mTextureCoords.YMost();
       effect->mTextureCoords.height = -effect->mTextureCoords.height;