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

Side by Side Diff: android_webview/browser/render_thread_manager.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: Finished, working Created 4 years, 3 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
OLDNEW
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 "android_webview/browser/render_thread_manager.h" 5 #include "android_webview/browser/render_thread_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/child_frame.h" 9 #include "android_webview/browser/child_frame.h"
10 #include "android_webview/browser/compositor_frame_producer.h" 10 #include "android_webview/browser/compositor_frame_producer.h"
11 #include "android_webview/browser/compositor_id.h" 11 #include "android_webview/browser/compositor_id.h"
12 #include "android_webview/browser/deferred_gpu_command_service.h" 12 #include "android_webview/browser/deferred_gpu_command_service.h"
13 #include "android_webview/browser/hardware_renderer.h" 13 #include "android_webview/browser/hardware_renderer.h"
14 #include "android_webview/browser/render_thread_manager_client.h" 14 #include "android_webview/browser/render_thread_manager_client.h"
15 #include "android_webview/browser/scoped_app_gl_state_restore.h" 15 #include "android_webview/browser/scoped_app_gl_state_restore.h"
16 #include "android_webview/common/aw_switches.h"
16 #include "android_webview/public/browser/draw_gl.h" 17 #include "android_webview/public/browser/draw_gl.h"
17 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h"
18 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
19 #include "base/location.h" 21 #include "base/location.h"
22 #include "base/memory/ptr_util.h"
20 #include "base/time/time.h" 23 #include "base/time/time.h"
21 #include "base/trace_event/trace_event.h" 24 #include "base/trace_event/trace_event.h"
22 #include "base/trace_event/trace_event_argument.h" 25 #include "base/trace_event/trace_event_argument.h"
26 #include "cc/output/compositor_frame.h"
23 27
24 namespace android_webview { 28 namespace android_webview {
25 29
26 namespace internal { 30 namespace internal {
27 31
28 class RequestInvokeGLTracker { 32 class RequestInvokeGLTracker {
29 public: 33 public:
30 RequestInvokeGLTracker(); 34 RequestInvokeGLTracker();
31 bool ShouldRequestOnNonUiThread(RenderThreadManager* state); 35 bool ShouldRequestOnNonUiThread(RenderThreadManager* state);
32 bool ShouldRequestOnUiThread(RenderThreadManager* state); 36 bool ShouldRequestOnUiThread(RenderThreadManager* state);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 94 }
91 95
92 RenderThreadManager::RenderThreadManager( 96 RenderThreadManager::RenderThreadManager(
93 RenderThreadManagerClient* client, 97 RenderThreadManagerClient* client,
94 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop) 98 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop)
95 : ui_loop_(ui_loop), 99 : ui_loop_(ui_loop),
96 client_(client), 100 client_(client),
97 compositor_frame_producer_(nullptr), 101 compositor_frame_producer_(nullptr),
98 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()), 102 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()),
99 hardware_renderer_has_frame_(false), 103 hardware_renderer_has_frame_(false),
104 async_on_draw_hardware_(base::CommandLine::ForCurrentProcess()->HasSwitch(
105 switches::kAsyncOnDrawHardware)),
100 inside_hardware_release_(false), 106 inside_hardware_release_(false),
101 weak_factory_on_ui_thread_(this) { 107 weak_factory_on_ui_thread_(this) {
102 DCHECK(ui_loop_->BelongsToCurrentThread()); 108 DCHECK(ui_loop_->BelongsToCurrentThread());
103 DCHECK(client_); 109 DCHECK(client_);
104 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr(); 110 ui_thread_weak_ptr_ = weak_factory_on_ui_thread_.GetWeakPtr();
105 ResetRequestInvokeGLCallback(); 111 ResetRequestInvokeGLCallback();
106 } 112 }
107 113
108 RenderThreadManager::~RenderThreadManager() { 114 RenderThreadManager::~RenderThreadManager() {
109 DCHECK(ui_loop_->BelongsToCurrentThread()); 115 DCHECK(ui_loop_->BelongsToCurrentThread());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 base::AutoLock lock(lock_); 179 base::AutoLock lock(lock_);
174 return scroll_offset_; 180 return scroll_offset_;
175 } 181 }
176 182
177 void RenderThreadManager::SetFrameOnUI(std::unique_ptr<ChildFrame> frame) { 183 void RenderThreadManager::SetFrameOnUI(std::unique_ptr<ChildFrame> frame) {
178 base::AutoLock lock(lock_); 184 base::AutoLock lock(lock_);
179 DCHECK(!child_frame_.get()); 185 DCHECK(!child_frame_.get());
180 child_frame_ = std::move(frame); 186 child_frame_ = std::move(frame);
181 } 187 }
182 188
189 void RenderThreadManager::SetFrameFutureOnUI(
190 const scoped_refptr<content::SynchronousCompositor::FrameFuture>&
191 frame_future) {
192 frame_future_ = std::move(frame_future);
boliu 2016/09/22 23:05:32 AutoLock
ojars 2016/09/28 00:17:59 Done.
193 }
194
183 std::unique_ptr<ChildFrame> RenderThreadManager::PassFrameOnRT() { 195 std::unique_ptr<ChildFrame> RenderThreadManager::PassFrameOnRT() {
boliu 2016/09/22 23:05:32 you need to repeat all this code for PassUncommitt
ojars 2016/09/28 00:17:58 Done.
184 base::AutoLock lock(lock_); 196 base::AutoLock lock(lock_);
185 hardware_renderer_has_frame_ = 197 hardware_renderer_has_frame_ =
186 hardware_renderer_has_frame_ || child_frame_.get(); 198 hardware_renderer_has_frame_ || child_frame_.get();
199 if (async_on_draw_hardware_ && child_frame_.get() &&
200 !child_frame_->frame.get()) {
boliu 2016/09/22 23:05:31 this third part of this check should be a DCHECK i
ojars 2016/09/28 00:17:58 Done.
201 std::unique_ptr<content::SynchronousCompositor::Frame> frame =
202 frame_future_->getFrame();
203
204 std::unique_ptr<cc::CompositorFrame> compositor_frame =
205 std::move(frame->frame);
206
207 child_frame_ = base::MakeUnique<ChildFrame>(
208 frame->compositor_frame_sink_id, std::move(compositor_frame),
209 child_frame_->compositor_id,
210 child_frame_->viewport_rect_for_tile_priority_empty,
211 child_frame_->transform_for_tile_priority,
212 child_frame_->offscreen_pre_raster, child_frame_->is_layer);
213 }
187 return std::move(child_frame_); 214 return std::move(child_frame_);
188 } 215 }
189 216
190 std::unique_ptr<ChildFrame> RenderThreadManager::PassUncommittedFrameOnUI() { 217 std::unique_ptr<ChildFrame> RenderThreadManager::PassUncommittedFrameOnUI() {
191 base::AutoLock lock(lock_); 218 base::AutoLock lock(lock_);
192 return std::move(child_frame_); 219 return std::move(child_frame_);
193 } 220 }
194 221
195 void RenderThreadManager::PostExternalDrawConstraintsToChildCompositorOnRT( 222 void RenderThreadManager::PostExternalDrawConstraintsToChildCompositorOnRT(
196 const ParentCompositorDrawConstraints& parent_draw_constraints) { 223 const ParentCompositorDrawConstraints& parent_draw_constraints) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 : render_thread_manager_(render_thread_manager) { 426 : render_thread_manager_(render_thread_manager) {
400 DCHECK(!render_thread_manager_->IsInsideHardwareRelease()); 427 DCHECK(!render_thread_manager_->IsInsideHardwareRelease());
401 render_thread_manager_->SetInsideHardwareRelease(true); 428 render_thread_manager_->SetInsideHardwareRelease(true);
402 } 429 }
403 430
404 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() { 431 RenderThreadManager::InsideHardwareReleaseReset::~InsideHardwareReleaseReset() {
405 render_thread_manager_->SetInsideHardwareRelease(false); 432 render_thread_manager_->SetInsideHardwareRelease(false);
406 } 433 }
407 434
408 } // namespace android_webview 435 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698