Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11583005: cc: Make occlusion tracker always work in target space. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/layer_tree_host_unittest.cc » ('j') | cc/occlusion_tracker.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 3129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 3140
3141 // Child of the surface layer will produce some quads 3141 // Child of the surface layer will produce some quads
3142 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25, rootSize.height() - 25), &childPtr); 3142 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(5, 5, rootSize.width() - 25, rootSize.height() - 25), &childPtr);
3143 } 3143 }
3144 3144
3145 class GLRendererWithReleaseTextures : public GLRenderer { 3145 class GLRendererWithReleaseTextures : public GLRenderer {
3146 public: 3146 public:
3147 using GLRenderer::releaseRenderPassTextures; 3147 using GLRenderer::releaseRenderPassTextures;
3148 }; 3148 };
3149 3149
3150 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
3151 {
3152 LayerTreeSettings settings;
3153 settings.minimumOcclusionTrackingSize = gfx::Size();
3154 settings.partialSwapEnabled = true;
3155 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy);
3156
3157 LayerImpl* rootPtr;
3158 LayerImpl* surfaceLayerPtr;
3159
3160 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3161
3162 gfx::Size rootSize(100, 100);
3163
3164 myHostImpl->initializeRenderer(outputSurface.Pass());
3165 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3166
3167 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3168 rootPtr = root.get();
3169
3170 root->setAnchorPoint(gfx::PointF(0, 0));
3171 root->setPosition(gfx::PointF(0, 0));
3172 root->setBounds(rootSize);
3173 root->setContentBounds(rootSize);
3174 root->setDrawsContent(true);
3175 root->setMasksToBounds(true);
3176 myHostImpl->setRootLayer(root.Pass());
3177
3178 addDrawingLayerTo(rootPtr, 3, gfx::Rect(0, 0, rootSize.width(), rootSize.hei ght()), &surfaceLayerPtr);
3179 surfaceLayerPtr->setDrawsContent(false);
3180
3181 // Surface layer is the layer that changes its opacity
3182 // It will contain other layers that draw content.
3183 surfaceLayerPtr->setOpacity(0.5f);
3184 surfaceLayerPtr->setForceRenderSurface(true); // This will cause it to have a surface
3185
3186 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0);
3187 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0);
3188
3189 // Rotation will put part of the child ouside the bounds of the root layer.
3190 // Nevertheless, the child layers should be drawn.
3191 gfx::Transform transform = surfaceLayerPtr->transform();
3192 transform.Translate(50, 50);
3193 transform.Rotate(35);
3194 transform.Translate(-50, -50);
3195 surfaceLayerPtr->setTransform(transform);
3196
3197 {
3198 LayerTreeHostImpl::FrameData frame;
3199 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3200
3201 // Must receive two render passes, each with one quad
3202 ASSERT_EQ(2U, frame.renderPasses.size());
3203 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3204 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
3205
3206 // Verify that the child layers are being clipped.
3207 gfx::Rect quadVisibleRect = frame.renderPasses[0]->quad_list[0]->visible _rect;
3208 EXPECT_LT(quadVisibleRect.width(), 100);
3209
3210 quadVisibleRect = frame.renderPasses[0]->quad_list[1]->visible_rect;
3211 EXPECT_LT(quadVisibleRect.width(), 100);
3212
3213 // Verify that the render surface texture is *not* clipped.
3214 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), frame.renderPasses[0]->output_ rect);
3215
3216 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial);
3217 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]);
3218 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty());
3219
3220 myHostImpl->drawLayers(frame);
3221 myHostImpl->didDrawAllLayers(frame);
3222 }
3223
3224 transform = surfaceLayerPtr->transform();
3225 transform.Translate(50, 50);
3226 transform.Rotate(-35);
3227 transform.Translate(-50, -50);
3228 surfaceLayerPtr->setTransform(transform);
3229
3230 // The surface is now aligned again, and the clipped parts are exposed.
3231 // Since the layers were clipped, even though the render surface size
3232 // was not changed, the texture should not be saved.
3233 {
3234 LayerTreeHostImpl::FrameData frame;
3235 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3236
3237 // Must receive two render passes, each with one quad
3238 ASSERT_EQ(2U, frame.renderPasses.size());
3239 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3240 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
3241
3242 myHostImpl->drawLayers(frame);
3243 myHostImpl->didDrawAllLayers(frame);
3244 }
3245 }
3246
3247 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) 3150 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
3248 { 3151 {
3249 LayerTreeSettings settings; 3152 LayerTreeSettings settings;
3250 settings.minimumOcclusionTrackingSize = gfx::Size(); 3153 settings.minimumOcclusionTrackingSize = gfx::Size();
3251 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy); 3154 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy);
3252 3155
3253 // Layers are structure as follows: 3156 // Layers are structure as follows:
3254 // 3157 //
3255 // R +-- S1 +- L10 (owning) 3158 // R +-- S1 +- L10 (owning)
3256 // | +- L11 3159 // | +- L11
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4927 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); 4830 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize());
4928 drawFrameAndTestDamage(noDamage); 4831 drawFrameAndTestDamage(noDamage);
4929 } 4832 }
4930 4833
4931 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4834 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4932 LayerTreeHostImplTest, 4835 LayerTreeHostImplTest,
4933 ::testing::Values(false, true)); 4836 ::testing::Values(false, true));
4934 4837
4935 } // namespace 4838 } // namespace
4936 } // namespace cc 4839 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_unittest.cc » ('j') | cc/occlusion_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698