| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sky/compositor/layer_host.h" | 5 #include "sky/compositor/layer_host.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 10 #include "mojo/gpu/gl_context.h" | 10 #include "mojo/gpu/gl_context.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 TRACE_EVENT0("sky", "LayerHost::BeginFrame"); | 68 TRACE_EVENT0("sky", "LayerHost::BeginFrame"); |
| 69 | 69 |
| 70 DCHECK(frame_requested_); | 70 DCHECK(frame_requested_); |
| 71 frame_requested_ = false; | 71 frame_requested_ = false; |
| 72 | 72 |
| 73 DCHECK_EQ(state_, kReadyForFrame); | 73 DCHECK_EQ(state_, kReadyForFrame); |
| 74 state_ = kWaitingForFrameAcknowldgement; | 74 state_ = kWaitingForFrameAcknowldgement; |
| 75 | 75 |
| 76 client_->BeginFrame(base::TimeTicks::Now()); | 76 client_->BeginFrame(base::TimeTicks::Now()); |
| 77 | 77 |
| 78 // If the root layer is empty, there's no reason to draw into it. (In fact, |
| 79 // Ganesh will get upset if we try.) Instead, we just schedule the ack that |
| 80 // the frame is complete. |
| 81 if (root_layer_->size().IsEmpty()) { |
| 82 base::MessageLoop::current()->PostTask( |
| 83 FROM_HERE, |
| 84 base::Bind(&LayerHost::DidCompleteFrame, weak_factory_.GetWeakPtr())); |
| 85 return; |
| 86 } |
| 87 |
| 78 { | 88 { |
| 79 mojo::GaneshContext::Scope scope(&ganesh_context_); | 89 mojo::GaneshContext::Scope scope(&ganesh_context_); |
| 80 ganesh_context_.gr()->resetContext(); | 90 ganesh_context_.gr()->resetContext(); |
| 81 root_layer_->Display(); | 91 root_layer_->Display(); |
| 82 } | 92 } |
| 83 | 93 |
| 84 Upload(root_layer_.get()); | 94 Upload(root_layer_.get()); |
| 85 } | 95 } |
| 86 | 96 |
| 87 void LayerHost::Upload(Layer* layer) { | 97 void LayerHost::Upload(Layer* layer) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 150 } |
| 141 | 151 |
| 142 void LayerHost::DidCompleteFrame() { | 152 void LayerHost::DidCompleteFrame() { |
| 143 DCHECK_EQ(state_, kWaitingForFrameAcknowldgement); | 153 DCHECK_EQ(state_, kWaitingForFrameAcknowldgement); |
| 144 state_ = kReadyForFrame; | 154 state_ = kReadyForFrame; |
| 145 if (frame_requested_) | 155 if (frame_requested_) |
| 146 BeginFrame(); | 156 BeginFrame(); |
| 147 } | 157 } |
| 148 | 158 |
| 149 } // namespace sky | 159 } // namespace sky |
| OLD | NEW |