| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // frame time is in the past, so give the next vsync period as the deadline. | 205 // frame time is in the past, so give the next vsync period as the deadline. |
| 206 base::TimeTicks deadline = frame_time + vsync_period; | 206 base::TimeTicks deadline = frame_time + vsync_period; |
| 207 last_begin_frame_args_ = | 207 last_begin_frame_args_ = |
| 208 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 208 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
| 209 vsync_period, cc::BeginFrameArgs::NORMAL); | 209 vsync_period, cc::BeginFrameArgs::NORMAL); |
| 210 std::unordered_set<cc::BeginFrameObserver*> observers(observers_); | 210 std::unordered_set<cc::BeginFrameObserver*> observers(observers_); |
| 211 for (auto* obs : observers) | 211 for (auto* obs : observers) |
| 212 obs->OnBeginFrame(last_begin_frame_args_); | 212 obs->OnBeginFrame(last_begin_frame_args_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Used to override capabilities_.adjust_deadline_for_parent to false | |
| 216 class AndroidOutputSurface : public cc::OutputSurface { | 215 class AndroidOutputSurface : public cc::OutputSurface { |
| 217 public: | 216 public: |
| 218 AndroidOutputSurface( | 217 AndroidOutputSurface( |
| 219 scoped_refptr<ContextProviderCommandBuffer> context_provider, | 218 scoped_refptr<ContextProviderCommandBuffer> context_provider, |
| 220 const base::Callback<void(gpu::Capabilities)>& | 219 const base::Callback<void(gpu::Capabilities)>& |
| 221 populate_gpu_capabilities_callback) | 220 populate_gpu_capabilities_callback) |
| 222 : cc::OutputSurface(std::move(context_provider), nullptr, nullptr), | 221 : cc::OutputSurface(std::move(context_provider)), |
| 223 populate_gpu_capabilities_callback_(populate_gpu_capabilities_callback), | 222 populate_gpu_capabilities_callback_(populate_gpu_capabilities_callback), |
| 224 swap_buffers_completion_callback_( | 223 swap_buffers_completion_callback_( |
| 225 base::Bind(&AndroidOutputSurface::OnSwapBuffersCompleted, | 224 base::Bind(&AndroidOutputSurface::OnSwapBuffersCompleted, |
| 226 base::Unretained(this))), | 225 base::Unretained(this))), |
| 227 overlay_candidate_validator_( | 226 overlay_candidate_validator_( |
| 228 new display_compositor:: | 227 new display_compositor:: |
| 229 CompositorOverlayCandidateValidatorAndroid()) { | 228 CompositorOverlayCandidateValidatorAndroid()) { |
| 230 capabilities_.adjust_deadline_for_parent = false; | |
| 231 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; | 229 capabilities_.max_frames_pending = kMaxDisplaySwapBuffers; |
| 232 } | 230 } |
| 233 | 231 |
| 234 ~AndroidOutputSurface() override = default; | 232 ~AndroidOutputSurface() override = default; |
| 235 | 233 |
| 236 void SwapBuffers(cc::CompositorFrame frame) override { | 234 void SwapBuffers(cc::CompositorFrame frame) override { |
| 237 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info); | 235 GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info); |
| 238 if (frame.gl_frame_data->sub_buffer_rect.IsEmpty()) { | 236 if (frame.gl_frame_data->sub_buffer_rect.IsEmpty()) { |
| 239 context_provider_->ContextSupport()->CommitOverlayPlanes(); | 237 context_provider_->ContextSupport()->CommitOverlayPlanes(); |
| 240 } else { | 238 } else { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 809 |
| 812 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 810 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 813 host_->SetNeedsAnimate(); | 811 host_->SetNeedsAnimate(); |
| 814 } | 812 } |
| 815 | 813 |
| 816 bool CompositorImpl::HavePendingReadbacks() { | 814 bool CompositorImpl::HavePendingReadbacks() { |
| 817 return !readback_layer_tree_->children().empty(); | 815 return !readback_layer_tree_->children().empty(); |
| 818 } | 816 } |
| 819 | 817 |
| 820 } // namespace content | 818 } // namespace content |
| OLD | NEW |