| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "cc/output/compositor_frame.h" | 19 #include "cc/output/compositor_frame.h" |
| 20 #include "cc/output/compositor_frame_ack.h" | 20 #include "cc/output/compositor_frame_ack.h" |
| 21 #include "cc/output/managed_memory_policy.h" | 21 #include "cc/output/managed_memory_policy.h" |
| 22 #include "cc/output/output_surface_client.h" | 22 #include "cc/output/output_surface_client.h" |
| 23 #include "cc/scheduler/delay_based_time_source.h" | 23 #include "cc/scheduler/delay_based_time_source.h" |
| 24 #include "gpu/GLES2/gl2extchromium.h" | 24 #include "gpu/GLES2/gl2extchromium.h" |
| 25 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 25 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 26 #include "third_party/khronos/GLES2/gl2.h" | 26 #include "third_party/khronos/GLES2/gl2.h" |
| 27 #include "third_party/khronos/GLES2/gl2ext.h" | 27 #include "third_party/khronos/GLES2/gl2ext.h" |
| 28 #include "ui/gfx/frame_time.h" |
| 28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
| 29 #include "ui/gfx/size.h" | 30 #include "ui/gfx/size.h" |
| 30 | 31 |
| 31 using std::set; | 32 using std::set; |
| 32 using std::string; | 33 using std::string; |
| 33 using std::vector; | 34 using std::vector; |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 const size_t kGpuLatencyHistorySize = 60; | 38 const size_t kGpuLatencyHistorySize = 60; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 check_for_retroactive_begin_impl_frame_pending_(false), | 89 check_for_retroactive_begin_impl_frame_pending_(false), |
| 89 external_stencil_test_enabled_(false), | 90 external_stencil_test_enabled_(false), |
| 90 weak_ptr_factory_(this), | 91 weak_ptr_factory_(this), |
| 91 gpu_latency_history_(kGpuLatencyHistorySize) {} | 92 gpu_latency_history_(kGpuLatencyHistorySize) {} |
| 92 | 93 |
| 93 void OutputSurface::InitializeBeginImplFrameEmulation( | 94 void OutputSurface::InitializeBeginImplFrameEmulation( |
| 94 base::SingleThreadTaskRunner* task_runner, | 95 base::SingleThreadTaskRunner* task_runner, |
| 95 bool throttle_frame_production, | 96 bool throttle_frame_production, |
| 96 base::TimeDelta interval) { | 97 base::TimeDelta interval) { |
| 97 if (throttle_frame_production) { | 98 if (throttle_frame_production) { |
| 98 frame_rate_controller_.reset( | 99 scoped_refptr<DelayBasedTimeSource> time_source; |
| 99 new FrameRateController( | 100 if (gfx::FrameTime::TimestampsAreHighRes()) |
| 100 DelayBasedTimeSource::Create(interval, task_runner))); | 101 time_source = DelayBasedTimeSourceHighRes::Create(interval, task_runner); |
| 102 else |
| 103 time_source = DelayBasedTimeSource::Create(interval, task_runner); |
| 104 frame_rate_controller_.reset(new FrameRateController(time_source)); |
| 101 } else { | 105 } else { |
| 102 frame_rate_controller_.reset(new FrameRateController(task_runner)); | 106 frame_rate_controller_.reset(new FrameRateController(task_runner)); |
| 103 } | 107 } |
| 104 | 108 |
| 105 frame_rate_controller_->SetClient(this); | 109 frame_rate_controller_->SetClient(this); |
| 106 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending_); | 110 frame_rate_controller_->SetMaxSwapsPending(max_frames_pending_); |
| 107 frame_rate_controller_->SetDeadlineAdjustment( | 111 frame_rate_controller_->SetDeadlineAdjustment( |
| 108 capabilities_.adjust_deadline_for_parent ? | 112 capabilities_.adjust_deadline_for_parent ? |
| 109 BeginFrameArgs::DefaultDeadlineAdjustment() : base::TimeDelta()); | 113 BeginFrameArgs::DefaultDeadlineAdjustment() : base::TimeDelta()); |
| 110 | 114 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 base::MessageLoop::current()->PostTask( | 197 base::MessageLoop::current()->PostTask( |
| 194 FROM_HERE, | 198 FROM_HERE, |
| 195 base::Bind(&OutputSurface::CheckForRetroactiveBeginImplFrame, | 199 base::Bind(&OutputSurface::CheckForRetroactiveBeginImplFrame, |
| 196 weak_ptr_factory_.GetWeakPtr())); | 200 weak_ptr_factory_.GetWeakPtr())); |
| 197 check_for_retroactive_begin_impl_frame_pending_ = true; | 201 check_for_retroactive_begin_impl_frame_pending_ = true; |
| 198 } | 202 } |
| 199 | 203 |
| 200 void OutputSurface::CheckForRetroactiveBeginImplFrame() { | 204 void OutputSurface::CheckForRetroactiveBeginImplFrame() { |
| 201 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginImplFrame"); | 205 TRACE_EVENT0("cc", "OutputSurface::CheckForRetroactiveBeginImplFrame"); |
| 202 check_for_retroactive_begin_impl_frame_pending_ = false; | 206 check_for_retroactive_begin_impl_frame_pending_ = false; |
| 203 if (base::TimeTicks::Now() < RetroactiveBeginImplFrameDeadline()) | 207 if (gfx::FrameTime::Now() < RetroactiveBeginImplFrameDeadline()) |
| 204 BeginImplFrame(skipped_begin_impl_frame_args_); | 208 BeginImplFrame(skipped_begin_impl_frame_args_); |
| 205 } | 209 } |
| 206 | 210 |
| 207 void OutputSurface::DidSwapBuffers() { | 211 void OutputSurface::DidSwapBuffers() { |
| 208 pending_swap_buffers_++; | 212 pending_swap_buffers_++; |
| 209 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", | 213 TRACE_EVENT1("cc", "OutputSurface::DidSwapBuffers", |
| 210 "pending_swap_buffers_", pending_swap_buffers_); | 214 "pending_swap_buffers_", pending_swap_buffers_); |
| 211 if (frame_rate_controller_) | 215 if (frame_rate_controller_) |
| 212 frame_rate_controller_->DidSwapBuffers(); | 216 frame_rate_controller_->DidSwapBuffers(); |
| 213 PostCheckForRetroactiveBeginImplFrame(); | 217 PostCheckForRetroactiveBeginImplFrame(); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 "discard_backbuffer", discard_backbuffer); | 496 "discard_backbuffer", discard_backbuffer); |
| 493 // Just ignore the memory manager when it says to set the limit to zero | 497 // Just ignore the memory manager when it says to set the limit to zero |
| 494 // bytes. This will happen when the memory manager thinks that the renderer | 498 // bytes. This will happen when the memory manager thinks that the renderer |
| 495 // is not visible (which the renderer knows better). | 499 // is not visible (which the renderer knows better). |
| 496 if (policy.bytes_limit_when_visible) | 500 if (policy.bytes_limit_when_visible) |
| 497 client_->SetMemoryPolicy(policy); | 501 client_->SetMemoryPolicy(policy); |
| 498 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); | 502 client_->SetDiscardBackBufferWhenNotVisible(discard_backbuffer); |
| 499 } | 503 } |
| 500 | 504 |
| 501 } // namespace cc | 505 } // namespace cc |
| OLD | NEW |