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

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

Issue 12662021: cc: Don't draw and swap if the frame will not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add perf test Created 7 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/heads_up_display_layer.h" 9 #include "cc/layers/heads_up_display_layer.h"
10 #include "cc/layers/io_surface_layer.h" 10 #include "cc/layers/io_surface_layer.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::Bind(&LayerTreeHostContextTest::CreateOffscreenContext3d, 148 base::Bind(&LayerTreeHostContextTest::CreateOffscreenContext3d,
149 base::Unretained(this))); 149 base::Unretained(this)));
150 } 150 }
151 return offscreen_contexts_compositor_thread_; 151 return offscreen_contexts_compositor_thread_;
152 } 152 }
153 153
154 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 154 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
155 LayerTreeHostImpl::FrameData* frame, 155 LayerTreeHostImpl::FrameData* frame,
156 bool result) 156 bool result)
157 OVERRIDE { 157 OVERRIDE {
158 EXPECT_TRUE(result); 158 bool expect_success = !frame->has_no_damage;
159 EXPECT_EQ(expect_success, result);
159 if (!times_to_lose_during_draw_) 160 if (!times_to_lose_during_draw_)
160 return result; 161 return result;
161 162
162 --times_to_lose_during_draw_; 163 --times_to_lose_during_draw_;
163 context3d_->set_times_make_current_succeeds(0); 164 context3d_->set_times_make_current_succeeds(0);
164 165
165 times_to_fail_create_ = times_to_fail_recreate_; 166 times_to_fail_create_ = times_to_fail_recreate_;
166 times_to_fail_recreate_ = 0; 167 times_to_fail_recreate_ = 0;
167 times_to_fail_initialize_ = times_to_fail_reinitialize_; 168 times_to_fail_initialize_ = times_to_fail_reinitialize_;
168 times_to_fail_reinitialize_ = 0; 169 times_to_fail_reinitialize_ = 0;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return; 264 return;
264 265
265 recovered_context_ = false; 266 recovered_context_ = false;
266 if (NextTestCase()) 267 if (NextTestCase())
267 InvalidateAndSetNeedsCommit(); 268 InvalidateAndSetNeedsCommit();
268 else 269 else
269 EndTest(); 270 EndTest();
270 } 271 }
271 272
272 virtual void InvalidateAndSetNeedsCommit() { 273 virtual void InvalidateAndSetNeedsCommit() {
273 layer_tree_host()->SetNeedsCommit(); 274 // Cause damage so we try to draw.
275 layer_tree_host()->root_layer()->SetNeedsDisplay();
274 } 276 }
275 277
276 bool NextTestCase() { 278 bool NextTestCase() {
277 static const TestCase kTests[] = { 279 static const TestCase kTests[] = {
278 // Losing the context and failing to recreate it (or losing it again 280 // Losing the context and failing to recreate it (or losing it again
279 // immediately) a small number of times should succeed. 281 // immediately) a small number of times should succeed.
280 { 1, // times_to_lose_during_commit 282 { 1, // times_to_lose_during_commit
281 0, // times_to_lose_during_draw 283 0, // times_to_lose_during_draw
282 3, // times_to_fail_reinitialize 284 3, // times_to_fail_reinitialize
283 0, // times_to_fail_recreate 285 0, // times_to_fail_recreate
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1051
1050 if (host_impl->active_tree()->source_frame_number() == 3) { 1052 if (host_impl->active_tree()->source_frame_number() == 3) {
1051 // On the third commit we're recovering from context loss. Hardware 1053 // On the third commit we're recovering from context loss. Hardware
1052 // video frames should not be reused by the VideoFrameProvider, but 1054 // video frames should not be reused by the VideoFrameProvider, but
1053 // software frames can be. 1055 // software frames can be.
1054 hw_frame_provider_.set_frame(NULL); 1056 hw_frame_provider_.set_frame(NULL);
1055 scaled_hw_frame_provider_.set_frame(NULL); 1057 scaled_hw_frame_provider_.set_frame(NULL);
1056 } 1058 }
1057 } 1059 }
1058 1060
1059 virtual bool PrepareToDrawOnThread( 1061 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
1060 LayerTreeHostImpl* host_impl, 1062 LayerTreeHostImpl::FrameData* frame,
1061 LayerTreeHostImpl::FrameData* frame, 1063 bool result) OVERRIDE {
1062 bool result) OVERRIDE {
1063 if (host_impl->active_tree()->source_frame_number() == 2) { 1064 if (host_impl->active_tree()->source_frame_number() == 2) {
1064 // Lose the context during draw on the second commit. This will cause 1065 // Lose the context during draw on the second commit. This will cause
1065 // a third commit to recover. 1066 // a third commit to recover.
1066 if (context3d_) 1067 if (context3d_)
1067 context3d_->set_times_bind_texture_succeeds(4); 1068 context3d_->set_times_bind_texture_succeeds(4);
1068 } 1069 }
1069 return true; 1070 return true;
1070 } 1071 }
1071 1072
1072 virtual void DidCommitAndDrawFrame() OVERRIDE { 1073 virtual void DidCommitAndDrawFrame() OVERRIDE {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1230
1230 private: 1231 private:
1231 int commits_; 1232 int commits_;
1232 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_; 1233 scoped_refptr<FakeScrollbarLayer> scrollbar_layer_;
1233 }; 1234 };
1234 1235
1235 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext) 1236 SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext)
1236 1237
1237 } // namespace 1238 } // namespace
1238 } // namespace cc 1239 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698