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 #ifndef ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_
6 #define ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_
10 #include "base/memory/weak_ptr.h"
11 #include "base/sequence_checker.h"
12 #include "base/single_thread_task_runner.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_surface.h"
22 namespace android_webview
{
24 class BrowserViewRenderer
;
25 class SharedRendererState
;
29 virtual ~WindowHooks() {}
31 virtual void WillOnDraw() = 0;
32 virtual void DidOnDraw(bool success
) = 0;
34 virtual void WillSyncOnRT(SharedRendererState
* functor
) = 0;
35 virtual void DidSyncOnRT(SharedRendererState
* functor
) = 0;
36 virtual void WillProcessOnRT(SharedRendererState
* functor
) = 0;
37 virtual void DidProcessOnRT(SharedRendererState
* functor
) = 0;
38 virtual void WillDrawOnRT(SharedRendererState
* functor
) = 0;
39 virtual void DidDrawOnRT(SharedRendererState
* functor
) = 0;
44 FakeWindow(BrowserViewRenderer
* view
,
51 // BrowserViewRendererClient methods.
52 void RequestDrawGL(bool wait_for_completion
);
53 void PostInvalidate();
56 class ScopedMakeCurrent
;
58 void OnDrawHardware();
59 void CheckCurrentlyOnUIThread();
60 void CreateRenderThreadIfNeeded();
62 void InitializeOnRT(base::WaitableEvent
* sync
);
63 void DestroyOnRT(base::WaitableEvent
* sync
);
64 void ProcessFunctorOnRT(base::WaitableEvent
* sync
);
65 void DrawFunctorOnRT(base::WaitableEvent
* sync
);
66 void CheckCurrentlyOnRT();
68 // const so can be used on both threads.
69 BrowserViewRenderer
* const view_
;
70 WindowHooks
* const hooks_
;
71 const gfx::Size surface_size_
;
75 bool on_draw_hardware_pending_
;
76 base::SequenceChecker ui_checker_
;
78 // Render thread members.
79 scoped_ptr
<base::Thread
> render_thread_
;
80 base::SequenceChecker rt_checker_
;
81 SharedRendererState
* functor_
;
82 scoped_refptr
<base::SingleThreadTaskRunner
> render_thread_loop_
;
83 scoped_refptr
<gfx::GLSurface
> surface_
;
84 scoped_refptr
<gfx::GLContext
> context_
;
85 bool context_current_
;
87 base::WeakPtrFactory
<FakeWindow
> weak_ptr_factory_
;
89 DISALLOW_COPY_AND_ASSIGN(FakeWindow
);
92 } // namespace android_webview
94 #endif // ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_