Commit adc8e7eb authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Use mirrored layer's content scale instead of mirror layer's

Render surface textures have the surface content scale already applied
to them when they are generated. Because of this, the surface content
scale component of the target draw transform needs to be removed.

In the case of a mirror layer, a RenderPassDrawQuad (RPDQ) is used that
points to the render surface texture of the mirrored layer. Similar to
the RPDQ of the mirrored layer, the RPDQ of the mirror layer also has to
have its surface content scale component removed from its target draw
transform. However, since this RPDQ points to the render surface texture
of the mirrored layer, the inverse surface scale content of the mirrored
layer must be applied rather than that of the mirror layer. This patch
makes this change.

Change-Id: I2696d7af8f62872c623ea6516485671a9341484d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1696581Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676588}
parent 0a6c50bb
...@@ -41,8 +41,8 @@ void MirrorLayerImpl::AppendQuads(viz::RenderPass* render_pass, ...@@ -41,8 +41,8 @@ void MirrorLayerImpl::AppendQuads(viz::RenderPass* render_pass,
viz::SharedQuadState* shared_quad_state = viz::SharedQuadState* shared_quad_state =
render_pass->CreateAndAppendSharedQuadState(); render_pass->CreateAndAppendSharedQuadState();
PopulateScaledSharedQuadStateWithContentRects( PopulateScaledSharedQuadStateWithContentRects(
shared_quad_state, GetIdealContentsScale(), content_rect, content_rect, shared_quad_state, mirrored_layer->GetIdealContentsScale(), content_rect,
contents_opaque); content_rect, contents_opaque);
AppendDebugBorderQuad(render_pass, content_rect, shared_quad_state, AppendDebugBorderQuad(render_pass, content_rect, shared_quad_state,
append_quads_data); append_quads_data);
...@@ -75,7 +75,10 @@ gfx::Rect MirrorLayerImpl::GetDamageRect() const { ...@@ -75,7 +75,10 @@ gfx::Rect MirrorLayerImpl::GetDamageRect() const {
} }
gfx::Rect MirrorLayerImpl::GetEnclosingRectInTargetSpace() const { gfx::Rect MirrorLayerImpl::GetEnclosingRectInTargetSpace() const {
return GetScaledEnclosingRectInTargetSpace(GetIdealContentsScale()); const LayerImpl* mirrored_layer =
layer_tree_impl()->LayerById(mirrored_layer_id_);
return GetScaledEnclosingRectInTargetSpace(
mirrored_layer->GetIdealContentsScale());
} }
const char* MirrorLayerImpl::LayerTypeAsString() const { const char* MirrorLayerImpl::LayerTypeAsString() const {
......
...@@ -17,14 +17,14 @@ namespace { ...@@ -17,14 +17,14 @@ namespace {
class LayerTreeHostMirrorPixelTest class LayerTreeHostMirrorPixelTest
: public LayerTreePixelTest, : public LayerTreePixelTest,
public ::testing::WithParamInterface<LayerTreeTest::RendererType> { public ::testing::WithParamInterface<
::testing::tuple<LayerTreeTest::RendererType, bool>> {
protected: protected:
RendererType renderer_type() { return GetParam(); } RendererType renderer_type() { return std::get<0>(GetParam()); }
void InitializeSettings(LayerTreeSettings* settings) override { void InitializeSettings(LayerTreeSettings* settings) override {
// MirrorLayer is only used by UI compositor; so, match its behavior by settings->layer_transforms_should_scale_layer_contents =
// setting layer_transforms_should_scale_layer_contents to false. std::get<1>(GetParam());
settings->layer_transforms_should_scale_layer_contents = false;
} }
}; };
...@@ -37,9 +37,11 @@ const LayerTreeTest::RendererType kRendererTypes[] = { ...@@ -37,9 +37,11 @@ const LayerTreeTest::RendererType kRendererTypes[] = {
#endif #endif
}; };
INSTANTIATE_TEST_SUITE_P(, INSTANTIATE_TEST_SUITE_P(
LayerTreeHostMirrorPixelTest, ,
::testing::ValuesIn(kRendererTypes)); LayerTreeHostMirrorPixelTest,
::testing::Combine(::testing::ValuesIn(kRendererTypes),
/*layer_transforms_scale_content=*/testing::Bool()));
// Verifies that a mirror layer with a scale mirrors another layer correctly. // Verifies that a mirror layer with a scale mirrors another layer correctly.
TEST_P(LayerTreeHostMirrorPixelTest, MirrorLayer) { TEST_P(LayerTreeHostMirrorPixelTest, MirrorLayer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment