#ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
#define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
#include "base/message_loop/message_loop_proxy.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
namespace android_webview {
class BrowserViewRendererClient;
struct DrawGLInput {
unsigned int frame_id;
gfx::Rect global_visible_rect;
gfx::Vector2d scroll_offset;
DrawGLInput();
};
struct DrawGLResult {
unsigned int frame_id;
bool clip_contains_visible_rect;
DrawGLResult();
};
class SharedRendererState {
public:
SharedRendererState(scoped_refptr<base::MessageLoopProxy> ui_loop,
BrowserViewRendererClient* client);
~SharedRendererState();
void ClientRequestDrawGL();
void SetCompositorOnUiThread(content::SynchronousCompositor* compositor);
content::SynchronousCompositor* GetCompositor();
void SetDrawGLInput(const DrawGLInput& input);
DrawGLInput GetDrawGLInput() const;
private:
void ClientRequestDrawGLOnUIThread();
scoped_refptr<base::MessageLoopProxy> ui_loop_;
BrowserViewRendererClient* client_on_ui_;
base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
content::SynchronousCompositor* compositor_;
DrawGLInput draw_gl_input_;
};
}
#endif