| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 9 #include "mojo/gpu/gl_context.h" | 10 #include "mojo/gpu/gl_context.h" |
| 10 #include "mojo/services/public/cpp/surfaces/surfaces_utils.h" | 11 #include "mojo/services/public/cpp/surfaces/surfaces_utils.h" |
| 11 #include "mojo/skia/ganesh_context.h" | 12 #include "mojo/skia/ganesh_context.h" |
| 12 #include "sky/compositor/layer.h" | 13 #include "sky/compositor/layer.h" |
| 13 | 14 |
| 14 namespace sky { | 15 namespace sky { |
| 15 | 16 |
| 16 LayerHost::LayerHost(LayerHostClient* client) | 17 LayerHost::LayerHost(LayerHostClient* client) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 Upload(root_layer_.get()); | 47 Upload(root_layer_.get()); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void LayerHost::ReturnResources( | 50 void LayerHost::ReturnResources( |
| 50 mojo::Array<mojo::ReturnedResourcePtr> resources) { | 51 mojo::Array<mojo::ReturnedResourcePtr> resources) { |
| 51 resource_manager_.ReturnResources(resources.Pass()); | 52 resource_manager_.ReturnResources(resources.Pass()); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void LayerHost::BeginFrame(base::TimeTicks frame_time, | 55 void LayerHost::BeginFrame(base::TimeTicks frame_time, |
| 55 base::TimeTicks deadline) { | 56 base::TimeTicks deadline) { |
| 57 |
| 58 TRACE_EVENT0("sky", "LayerHost::BeginFrame"); |
| 59 |
| 56 DCHECK_EQ(state_, kWaitingForBeginFrame); | 60 DCHECK_EQ(state_, kWaitingForBeginFrame); |
| 57 state_ = kProducingFrame; | 61 state_ = kProducingFrame; |
| 58 client_->BeginFrame(frame_time); | 62 client_->BeginFrame(frame_time); |
| 59 | 63 |
| 60 { | 64 { |
| 61 mojo::GaneshContext::Scope scope(&ganesh_context_); | 65 mojo::GaneshContext::Scope scope(&ganesh_context_); |
| 62 ganesh_context_.gr()->resetContext(); | 66 ganesh_context_.gr()->resetContext(); |
| 63 root_layer_->Display(); | 67 root_layer_->Display(); |
| 64 } | 68 } |
| 65 | 69 |
| 66 Upload(root_layer_.get()); | 70 Upload(root_layer_.get()); |
| 67 | 71 |
| 68 if (state_ == kProducingFrame) | 72 if (state_ == kProducingFrame) |
| 69 state_ = kIdle; | 73 state_ = kIdle; |
| 70 } | 74 } |
| 71 | 75 |
| 72 void LayerHost::Upload(Layer* layer) { | 76 void LayerHost::Upload(Layer* layer) { |
| 77 TRACE_EVENT0("sky", "LayerHost::Upload"); |
| 78 |
| 73 if (!surface_holder_.IsReadyForFrame()) { | 79 if (!surface_holder_.IsReadyForFrame()) { |
| 74 if (state_ == kProducingFrame) { | 80 if (state_ == kProducingFrame) { |
| 75 // Currently we use a timer to drive the BeginFrame cycle, which means we | 81 // Currently we use a timer to drive the BeginFrame cycle, which means we |
| 76 // can produce frames before the surfaces service is ready to receive | 82 // can produce frames before the surfaces service is ready to receive |
| 77 // frames from us. In that situation, we wait for surfaces before | 83 // frames from us. In that situation, we wait for surfaces before |
| 78 // uploading the frame. The upload will actually happen when the surface | 84 // uploading the frame. The upload will actually happen when the surface |
| 79 // id is available (i.e., in OnSurfaceIdAvailable). If SetNeedsAnimate is | 85 // id is available (i.e., in OnSurfaceIdAvailable). If SetNeedsAnimate is |
| 80 // called before then, we'll go back into the kWaitingForBeginFrame state | 86 // called before then, we'll go back into the kWaitingForBeginFrame state |
| 81 // and defer to the timer again. | 87 // and defer to the timer again. |
| 82 // | 88 // |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 138 |
| 133 frame->resources.push_back(resource.Pass()); | 139 frame->resources.push_back(resource.Pass()); |
| 134 quad->texture_quad_state = texture_state.Pass(); | 140 quad->texture_quad_state = texture_state.Pass(); |
| 135 pass->quads.push_back(quad.Pass()); | 141 pass->quads.push_back(quad.Pass()); |
| 136 | 142 |
| 137 frame->passes.push_back(pass.Pass()); | 143 frame->passes.push_back(pass.Pass()); |
| 138 surface_holder_.SubmitFrame(frame.Pass()); | 144 surface_holder_.SubmitFrame(frame.Pass()); |
| 139 } | 145 } |
| 140 | 146 |
| 141 } // namespace sky | 147 } // namespace sky |
| OLD | NEW |