| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ | |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 | |
| 10 namespace gl { | |
| 11 class SurfaceTexture; | |
| 12 } | |
| 13 | |
| 14 namespace gpu { | |
| 15 struct MailboxHolder; | |
| 16 namespace gles2 { | |
| 17 class GLES2Interface; | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 namespace cc { | |
| 22 class ContextProvider; | |
| 23 } | |
| 24 | |
| 25 namespace vr_shell { | |
| 26 | |
| 27 class MailboxToSurfaceBridge { | |
| 28 public: | |
| 29 MailboxToSurfaceBridge(); | |
| 30 ~MailboxToSurfaceBridge(); | |
| 31 | |
| 32 void CreateSurface(gl::SurfaceTexture*); | |
| 33 | |
| 34 void ResizeSurface(int width, int height); | |
| 35 | |
| 36 // 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 // won't get a new frame on the SurfaceTexture. | |
| 39 bool CopyMailboxToSurfaceAndSwap(const gpu::MailboxHolder& mailbox); | |
| 40 | |
| 41 private: | |
| 42 void OnContextAvailable(scoped_refptr<cc::ContextProvider>); | |
| 43 void InitializeRenderer(); | |
| 44 void DestroyContext(); | |
| 45 void DrawQuad(unsigned int textureHandle); | |
| 46 | |
| 47 scoped_refptr<cc::ContextProvider> context_provider_; | |
| 48 gpu::gles2::GLES2Interface* gl_ = nullptr; | |
| 49 int surface_handle_ = 0; | |
| 50 | |
| 51 // Saved state for a pending resize, the dimensions are only | |
| 52 // valid if needs_resize_ is true. | |
| 53 bool needs_resize_ = false; | |
| 54 int resize_width_; | |
| 55 int resize_height_; | |
| 56 | |
| 57 // Must be last. | |
| 58 base::WeakPtrFactory<MailboxToSurfaceBridge> weak_ptr_factory_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace vr_shell | |
| 62 | |
| 63 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_MAILBOX_TO_SURFACE_BRIDGE_H_ | |
| OLD | NEW |