| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_MAILBOX_TO_SURFACE_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 | 9 |
| 10 namespace gl { | 10 namespace gl { |
| 11 class ScopedJavaSurface; |
| 11 class SurfaceTexture; | 12 class SurfaceTexture; |
| 12 } | 13 } |
| 13 | 14 |
| 14 namespace gpu { | 15 namespace gpu { |
| 15 struct MailboxHolder; | 16 struct MailboxHolder; |
| 16 namespace gles2 { | 17 namespace gles2 { |
| 17 class GLES2Interface; | 18 class GLES2Interface; |
| 18 } | 19 } |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 void CreateSurface(gl::SurfaceTexture*); | 33 void CreateSurface(gl::SurfaceTexture*); |
| 33 | 34 |
| 34 void ResizeSurface(int width, int height); | 35 void ResizeSurface(int width, int height); |
| 35 | 36 |
| 36 // Returns true if swapped successfully. This can fail if the GL | 37 // Returns true if swapped successfully. This can fail if the GL |
| 37 // context isn't ready for use yet, in that case the caller | 38 // context isn't ready for use yet, in that case the caller |
| 38 // won't get a new frame on the SurfaceTexture. | 39 // won't get a new frame on the SurfaceTexture. |
| 39 bool CopyMailboxToSurfaceAndSwap(const gpu::MailboxHolder& mailbox); | 40 bool CopyMailboxToSurfaceAndSwap(const gpu::MailboxHolder& mailbox); |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 void OnContextAvailable(scoped_refptr<cc::ContextProvider>); | 43 void OnContextAvailable(std::unique_ptr<gl::ScopedJavaSurface> surface, |
| 44 scoped_refptr<cc::ContextProvider>); |
| 43 void InitializeRenderer(); | 45 void InitializeRenderer(); |
| 44 void DestroyContext(); | 46 void DestroyContext(); |
| 45 void DrawQuad(unsigned int textureHandle); | 47 void DrawQuad(unsigned int textureHandle); |
| 46 | 48 |
| 47 scoped_refptr<cc::ContextProvider> context_provider_; | 49 scoped_refptr<cc::ContextProvider> context_provider_; |
| 48 gpu::gles2::GLES2Interface* gl_ = nullptr; | 50 gpu::gles2::GLES2Interface* gl_ = nullptr; |
| 49 int surface_handle_ = 0; | 51 int surface_handle_ = 0; |
| 50 | 52 |
| 51 // Saved state for a pending resize, the dimensions are only | 53 // Saved state for a pending resize, the dimensions are only |
| 52 // valid if needs_resize_ is true. | 54 // valid if needs_resize_ is true. |
| 53 bool needs_resize_ = false; | 55 bool needs_resize_ = false; |
| 54 int resize_width_; | 56 int resize_width_; |
| 55 int resize_height_; | 57 int resize_height_; |
| 56 | 58 |
| 57 // Must be last. | 59 // Must be last. |
| 58 base::WeakPtrFactory<MailboxToSurfaceBridge> weak_ptr_factory_; | 60 base::WeakPtrFactory<MailboxToSurfaceBridge> weak_ptr_factory_; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace vr_shell | 63 } // namespace vr_shell |
| 62 | 64 |
| 63 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ | 65 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ |
| OLD | NEW |