diff options
author | miu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 22:39:38 +0000 |
---|---|---|
committer | miu@chromium.org <miu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 22:39:38 +0000 |
commit | d4d844a29b271cabb96ca6d5bdccce8056c1b16f (patch) | |
tree | 8c15542bd470a712ecfde05c480f7844d900d236 /cc | |
parent | 1efbb84347e9c7f030c5ae752c285da80d1b836a (diff) | |
download | chromium_src-d4d844a29b271cabb96ca6d5bdccce8056c1b16f.zip chromium_src-d4d844a29b271cabb96ca6d5bdccce8056c1b16f.tar.gz chromium_src-d4d844a29b271cabb96ca6d5bdccce8056c1b16f.tar.bz2 |
Fix copy_rect calculation in CopyCurrentRendererPassToBitmap().
The calculation was second-guessing the copy request's subrect by force-translating its origin. This manifested as bug 280724, where the compositing layer for Flash fullscreen was being read back with erroneous -64 by -64 translation.
Digging deeper, the RenderPass was drawing to output_rect=(-64, -64, screen_width+64, screen_height+64). The client was requesting area=(0, 0, screen_width, screen_height), and this is actually the correct region within the output_rect for the fullscreen content.
Testing:
1. Ran cc_unittests --gtest_filter='*Readback*'
2. Installed Chromecast extension, and mirrored both normal tab content and fullscreen Flash content to Chromecast device.
BUG=280724
Review URL: https://chromiumcodereview.appspot.com/23967012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/output/gl_renderer.cc | 11 | ||||
-rw-r--r-- | cc/output/software_renderer.cc | 7 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_readback.cc | 150 |
3 files changed, 154 insertions, 14 deletions
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 074d603..89fe9de 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -1967,11 +1967,8 @@ void GLRenderer::CopyCurrentRenderPassToBitmap( DrawingFrame* frame, scoped_ptr<CopyOutputRequest> request) { gfx::Rect copy_rect = frame->current_render_pass->output_rect; - if (request->has_area()) { - // Intersect with the request's area, positioned with its origin at the - // origin of the full copy_rect. - copy_rect.Intersect(request->area() - copy_rect.OffsetFromOrigin()); - } + if (request->has_area()) + copy_rect.Intersect(request->area()); GetFramebufferPixelsAsync(copy_rect, request.Pass()); } @@ -2188,10 +2185,6 @@ void GLRenderer::GetFramebufferPixelsAsync( if (rect.IsEmpty()) return; - DCHECK(gfx::Rect(current_surface_size_).Contains(rect)) << - "current_surface_size_: " << current_surface_size_.ToString() << - " rect: " << rect.ToString(); - gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); if (!request->force_bitmap_result()) { diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index 241968e..394d79a 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -492,11 +492,8 @@ void SoftwareRenderer::CopyCurrentRenderPassToBitmap( DrawingFrame* frame, scoped_ptr<CopyOutputRequest> request) { gfx::Rect copy_rect = frame->current_render_pass->output_rect; - if (request->has_area()) { - // Intersect with the request's area, positioned with its origin at the - // origin of the full copy_rect. - copy_rect.Intersect(request->area() - copy_rect.OffsetFromOrigin()); - } + if (request->has_area()) + copy_rect.Intersect(request->area()); gfx::Rect window_copy_rect = MoveFromDrawToWindowSpace(copy_rect); scoped_ptr<SkBitmap> bitmap(new SkBitmap); diff --git a/cc/trees/layer_tree_host_pixeltest_readback.cc b/cc/trees/layer_tree_host_pixeltest_readback.cc index 28b80b9..d8e2861 100644 --- a/cc/trees/layer_tree_host_pixeltest_readback.cc +++ b/cc/trees/layer_tree_host_pixeltest_readback.cc @@ -335,6 +335,156 @@ TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild_GL) { "green_small_with_blue_corner.png"))); } +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeSurroundsTargetLayer_Software) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(100, 100, 100, 100), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(0, 0, 100, 100); + RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeSurroundsLayer_GL_Bitmap) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(100, 100, 100, 100), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(0, 0, 100, 100); + RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeSurroundsTargetLayer_GL) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(100, 100, 100, 100), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(0, 0, 100, 100); + RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeExtendsBeyondTargetLayer_Software) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(50, 50, 150, 150), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(50, 50, 100, 100); + RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeExtendsBeyondTargetLayer_GL_Bitmap) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(50, 50, 150, 150), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(50, 50, 100, 100); + RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + +TEST_F(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeExtendsBeyondTargetLayer_GL) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( + gfx::Rect(50, 50, 150, 150), SK_ColorRED); + background->AddChild(target); + + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( + gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + + copy_subrect_ = gfx::Rect(50, 50, 100, 100); + RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, + background, + target.get(), + base::FilePath(FILE_PATH_LITERAL( + "green_small_with_blue_corner.png"))); +} + TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_Software) { scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( gfx::Rect(200, 200), SK_ColorWHITE); |