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
3 // found in the LICENSE file.
5 #include "android_webview/browser/shared_renderer_state.h"
7 #include "android_webview/browser/browser_view_renderer_client.h"
9 #include "base/location.h"
11 namespace android_webview
{
13 DrawGLInput::DrawGLInput() : frame_id(0) {}
15 DrawGLResult::DrawGLResult() : frame_id(0), clip_contains_visible_rect(false) {}
17 SharedRendererState::SharedRendererState(
18 scoped_refptr
<base::MessageLoopProxy
> ui_loop
,
19 BrowserViewRendererClient
* client
)
21 client_on_ui_(client
),
22 weak_factory_on_ui_thread_(this),
23 ui_thread_weak_ptr_(weak_factory_on_ui_thread_
.GetWeakPtr()) {
24 DCHECK(ui_loop_
->BelongsToCurrentThread());
25 DCHECK(client_on_ui_
);
28 SharedRendererState::~SharedRendererState() {}
30 void SharedRendererState::ClientRequestDrawGL() {
31 if (ui_loop_
->BelongsToCurrentThread()) {
32 ClientRequestDrawGLOnUIThread();
36 base::Bind(&SharedRendererState::ClientRequestDrawGLOnUIThread
,
37 ui_thread_weak_ptr_
));
41 void SharedRendererState::ClientRequestDrawGLOnUIThread() {
42 DCHECK(ui_loop_
->BelongsToCurrentThread());
43 if (!client_on_ui_
->RequestDrawGL(NULL
)) {
44 LOG(ERROR
) << "Failed to request GL process. Deadlock likely";
48 void SharedRendererState::SetCompositorOnUiThread(
49 content::SynchronousCompositor
* compositor
) {
50 DCHECK(ui_loop_
->BelongsToCurrentThread());
51 compositor_
= compositor
;
54 content::SynchronousCompositor
* SharedRendererState::GetCompositor() {
59 void SharedRendererState::SetDrawGLInput(const DrawGLInput
& input
) {
60 draw_gl_input_
= input
;
63 DrawGLInput
SharedRendererState::GetDrawGLInput() const {
64 return draw_gl_input_
;
67 } // namespace android_webview