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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 23454014: cc: Drop ContextProvider references on the impl thread before quitting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callbackcontrolcenter: rebase Created 7 years, 3 months 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
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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/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"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/containers/scoped_ptr_hash_map.h" 12 #include "base/containers/scoped_ptr_hash_map.h"
13 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
14 #include "cc/debug/test_web_graphics_context_3d.h" 14 #include "cc/debug/test_web_graphics_context_3d.h"
15 #include "cc/input/top_controls_manager.h" 15 #include "cc/input/top_controls_manager.h"
16 #include "cc/layers/delegated_renderer_layer_impl.h" 16 #include "cc/layers/delegated_renderer_layer_impl.h"
17 #include "cc/layers/heads_up_display_layer_impl.h" 17 #include "cc/layers/heads_up_display_layer_impl.h"
18 #include "cc/layers/io_surface_layer_impl.h" 18 #include "cc/layers/io_surface_layer_impl.h"
19 #include "cc/layers/layer_impl.h" 19 #include "cc/layers/layer_impl.h"
20 #include "cc/layers/painted_scrollbar_layer_impl.h" 20 #include "cc/layers/painted_scrollbar_layer_impl.h"
21 #include "cc/layers/quad_sink.h" 21 #include "cc/layers/quad_sink.h"
22 #include "cc/layers/render_surface_impl.h" 22 #include "cc/layers/render_surface_impl.h"
23 #include "cc/layers/solid_color_layer_impl.h" 23 #include "cc/layers/solid_color_layer_impl.h"
24 #include "cc/layers/texture_layer_impl.h" 24 #include "cc/layers/texture_layer_impl.h"
25 #include "cc/layers/tiled_layer_impl.h" 25 #include "cc/layers/tiled_layer_impl.h"
26 #include "cc/layers/video_layer_impl.h" 26 #include "cc/layers/video_layer_impl.h"
27 #include "cc/output/begin_frame_args.h" 27 #include "cc/output/begin_frame_args.h"
28 #include "cc/output/compositor_frame_ack.h" 28 #include "cc/output/compositor_frame_ack.h"
29 #include "cc/output/compositor_frame_metadata.h" 29 #include "cc/output/compositor_frame_metadata.h"
30 #include "cc/output/copy_output_request.h"
31 #include "cc/output/copy_output_result.h"
30 #include "cc/output/gl_renderer.h" 32 #include "cc/output/gl_renderer.h"
31 #include "cc/quads/render_pass_draw_quad.h" 33 #include "cc/quads/render_pass_draw_quad.h"
32 #include "cc/quads/solid_color_draw_quad.h" 34 #include "cc/quads/solid_color_draw_quad.h"
33 #include "cc/quads/texture_draw_quad.h" 35 #include "cc/quads/texture_draw_quad.h"
34 #include "cc/quads/tile_draw_quad.h" 36 #include "cc/quads/tile_draw_quad.h"
35 #include "cc/resources/layer_tiling_data.h" 37 #include "cc/resources/layer_tiling_data.h"
36 #include "cc/test/animation_test_common.h" 38 #include "cc/test/animation_test_common.h"
37 #include "cc/test/fake_layer_tree_host_impl.h" 39 #include "cc/test/fake_layer_tree_host_impl.h"
38 #include "cc/test/fake_output_surface.h" 40 #include "cc/test/fake_output_surface.h"
39 #include "cc/test/fake_output_surface_client.h" 41 #include "cc/test/fake_output_surface_client.h"
(...skipping 4989 matching lines...) Expand 10 before | Expand all | Expand 10 after
5029 virtual void SetFullRootLayerDamage() OVERRIDE {} 5031 virtual void SetFullRootLayerDamage() OVERRIDE {}
5030 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE { 5032 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE {
5031 return CompositorFrameMetadata(); 5033 return CompositorFrameMetadata();
5032 } 5034 }
5033 5035
5034 protected: 5036 protected:
5035 TestRenderer(const LayerTreeSettings* settings, 5037 TestRenderer(const LayerTreeSettings* settings,
5036 ResourceProvider* resource_provider, 5038 ResourceProvider* resource_provider,
5037 OutputSurface* output_surface, 5039 OutputSurface* output_surface,
5038 Proxy* proxy) 5040 Proxy* proxy)
5039 : GLRenderer(this, settings, output_surface, resource_provider, 0) {} 5041 : GLRenderer(this, settings, output_surface, resource_provider, NULL, 0) {
5042 }
5040 5043
5041 private: 5044 private:
5042 LayerTreeSettings settings_; 5045 LayerTreeSettings settings_;
5043 gfx::Size viewport_size_; 5046 gfx::Size viewport_size_;
5044 base::hash_set<RenderPass::Id> textures_; 5047 base::hash_set<RenderPass::Id> textures_;
5045 }; 5048 };
5046 5049
5047 static void ConfigureRenderPassTestData(const char* test_script, 5050 static void ConfigureRenderPassTestData(const char* test_script,
5048 RenderPassRemovalTestData* test_data, 5051 RenderPassRemovalTestData* test_data,
5049 TestRenderer* renderer) { 5052 TestRenderer* renderer) {
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
6570 6573
6571 host_impl_->DeleteUIResource(ui_resource_id); 6574 host_impl_->DeleteUIResource(ui_resource_id);
6572 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6575 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6573 EXPECT_EQ(0u, context3d->NumTextures()); 6576 EXPECT_EQ(0u, context3d->NumTextures());
6574 6577
6575 // Should not change state for multiple deletion on one UIResourceId 6578 // Should not change state for multiple deletion on one UIResourceId
6576 host_impl_->DeleteUIResource(ui_resource_id); 6579 host_impl_->DeleteUIResource(ui_resource_id);
6577 EXPECT_EQ(0u, context3d->NumTextures()); 6580 EXPECT_EQ(0u, context3d->NumTextures());
6578 } 6581 }
6579 6582
6583 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) {
6584 }
6585
6586 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
6587 scoped_refptr<TestContextProvider> context_provider =
6588 TestContextProvider::Create();
6589
6590 host_impl_ = LayerTreeHostImpl::Create(LayerTreeSettings(),
6591 this,
6592 &proxy_,
6593 &stats_instrumentation_);
6594 host_impl_->InitializeRenderer(
6595 FakeOutputSurface::Create3d(context_provider).PassAs<OutputSurface>());
6596 host_impl_->SetViewportSize(gfx::Size(10, 10));
6597
6598 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
6599
6600 ScopedPtrVector<CopyOutputRequest> requests;
6601 requests.push_back(CopyOutputRequest::CreateRequest(
6602 base::Bind(&ShutdownReleasesContext_Callback)));
6603
6604 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
6605
6606 LayerTreeHostImpl::FrameData frame;
6607 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6608 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
6609 host_impl_->DidDrawAllLayers(frame);
6610
6611 // The CopyOutputResult's callback has a ref on the ContextProvider and a
6612 // texture in a texture mailbox.
6613 EXPECT_FALSE(context_provider->HasOneRef());
6614 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
6615
6616 host_impl_.reset();
6617
6618 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
6619 // released, and the texture deleted.
6620 EXPECT_TRUE(context_provider->HasOneRef());
6621 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
6622 }
6623
6580 } // namespace 6624 } // namespace
6581 } // namespace cc 6625 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | content/browser/browser_plugin/browser_plugin_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698