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

Side by Side Diff: chrome/browser/android/vr_shell/vr_gl_thread.h

Issue 2833773005: Pause drawing webvr when the App button is pressed (Closed)
Patch Set: Add unittest + cleanup Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "chrome/browser/android/vr_shell/vr_thread_envoy.h"
14 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 15 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
15 16
16 namespace vr_shell { 17 namespace vr_shell {
17 18
18 class UiScene; 19 class UiScene;
19 class UiSceneManager; 20 class UiSceneManager;
20 class VrShell; 21 class VrShell;
21 class VrShellGl; 22 class VrShellGl;
22 23
23 class VrGLThread : public base::Thread { 24 class VrGLThread : public VrThreadEnvoy, public base::Thread {
24 public: 25 public:
25 VrGLThread( 26 VrGLThread(
26 const base::WeakPtr<VrShell>& weak_vr_shell, 27 const base::WeakPtr<VrShell>& weak_vr_shell,
27 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
28 gvr_context* gvr_api, 29 gvr_context* gvr_api,
29 bool initially_web_vr, 30 bool initially_web_vr,
30 bool reprojected_rendering); 31 bool reprojected_rendering);
31 32
32 ~VrGLThread() override; 33 ~VrGLThread() override;
34 void PostToMainThread(const base::Closure& task);
33 base::WeakPtr<VrShellGl> GetVrShellGl() { return weak_vr_shell_gl_; } 35 base::WeakPtr<VrShellGl> GetVrShellGl() { return weak_vr_shell_gl_; }
34 base::WeakPtr<UiSceneManager> GetSceneManager() { 36 base::WeakPtr<UiSceneManager> GetSceneManager() {
35 return weak_scene_manager_; 37 return weak_scene_manager_;
36 } 38 }
37 39
40 // VrThreadEnvoy implementation.
41 base::WeakPtr<VrShell> GetVrShell() override;
42 scoped_refptr<base::SingleThreadTaskRunner> GetMainThreadTaskRunner()
43 override;
44
38 protected: 45 protected:
39 void Init() override; 46 void Init() override;
40 void CleanUp() override; 47 void CleanUp() override;
41 48
42 private: 49 private:
43 // Created on GL thread. 50 // Created on GL thread.
44 std::unique_ptr<UiScene> scene_; 51 std::unique_ptr<UiScene> scene_;
45 std::unique_ptr<UiSceneManager> scene_manager_; 52 std::unique_ptr<UiSceneManager> scene_manager_;
46 base::WeakPtr<UiSceneManager> weak_scene_manager_; 53 base::WeakPtr<UiSceneManager> weak_scene_manager_;
47 std::unique_ptr<VrShellGl> vr_shell_gl_; 54 std::unique_ptr<VrShellGl> vr_shell_gl_;
48 base::WeakPtr<VrShellGl> weak_vr_shell_gl_; 55 base::WeakPtr<VrShellGl> weak_vr_shell_gl_;
49 56
50 // This state is used for initializing vr_shell_gl_. 57 // This state is used for initializing vr_shell_gl_.
51 base::WeakPtr<VrShell> weak_vr_shell_; 58 base::WeakPtr<VrShell> weak_vr_shell_;
52 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
53 gvr_context* gvr_api_; 60 gvr_context* gvr_api_;
54 bool initially_web_vr_; 61 bool initially_web_vr_;
55 bool reprojected_rendering_; 62 bool reprojected_rendering_;
56 63
64 base::WeakPtrFactory<VrGLThread> weak_ptr_factory_;
65
57 DISALLOW_COPY_AND_ASSIGN(VrGLThread); 66 DISALLOW_COPY_AND_ASSIGN(VrGLThread);
58 }; 67 };
59 68
60 } // namespace vr_shell 69 } // namespace vr_shell
61 70
62 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_ 71 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GL_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698