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 153321 2f603fe51b715a19afd47196f4758ab9c46cd786
parent 153320 d623d68577ec83320fb4b63cf93e2a0f8c456550
child 153322 0b0a0b49174071bb5ac12a5c5f6552647af2ad6d
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [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;