| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ | 5 #ifndef CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ |
| 6 #define CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ | 6 #define CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 virtual void Destroy() OVERRIDE; | 29 virtual void Destroy() OVERRIDE; |
| 30 virtual bool Resize(const gfx::Size& size) OVERRIDE; | 30 virtual bool Resize(const gfx::Size& size) OVERRIDE; |
| 31 virtual bool IsOffscreen() OVERRIDE; | 31 virtual bool IsOffscreen() OVERRIDE; |
| 32 virtual bool SwapBuffers() OVERRIDE; | 32 virtual bool SwapBuffers() OVERRIDE; |
| 33 virtual gfx::Size GetSize() OVERRIDE; | 33 virtual gfx::Size GetSize() OVERRIDE; |
| 34 virtual void* GetHandle() OVERRIDE; | 34 virtual void* GetHandle() OVERRIDE; |
| 35 virtual std::string GetExtensions() OVERRIDE; | 35 virtual std::string GetExtensions() OVERRIDE; |
| 36 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 36 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
| 37 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 37 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
| 39 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; | 39 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
| 40 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
| 40 virtual void* GetShareHandle() OVERRIDE; | 41 virtual void* GetShareHandle() OVERRIDE; |
| 41 virtual void* GetDisplay() OVERRIDE; | 42 virtual void* GetDisplay() OVERRIDE; |
| 42 virtual void* GetConfig() OVERRIDE; | 43 virtual void* GetConfig() OVERRIDE; |
| 43 | 44 |
| 44 protected: | 45 protected: |
| 45 // ImageTransportSurface implementation. | 46 // ImageTransportSurface implementation. |
| 46 virtual void OnNewSurfaceACK( | 47 virtual void OnNewSurfaceACK( |
| 47 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; | 48 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
| 49 virtual void OnReleaseSurfaceACK(uint64 surface_id, bool success) OVERRIDE; |
| 48 virtual void OnBuffersSwappedACK() OVERRIDE; | 50 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 49 virtual void OnPostSubBufferACK() OVERRIDE; | 51 virtual void OnPostSubBufferACK() OVERRIDE; |
| 50 virtual void OnResizeViewACK() OVERRIDE; | 52 virtual void OnResizeViewACK() OVERRIDE; |
| 51 virtual void OnResize(gfx::Size size) OVERRIDE; | 53 virtual void OnResize(gfx::Size size) OVERRIDE; |
| 52 | 54 |
| 53 // GpuCommandBufferStub::DestructionObserver implementation. | 55 // GpuCommandBufferStub::DestructionObserver implementation. |
| 54 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE; | 56 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE; |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 // A texture backing the front/back buffer in the parent stub. | 59 // A texture backing the front/back buffer in the parent stub. |
| 58 struct Texture { | 60 struct Texture { |
| 59 Texture() : client_id(0), sent_to_client(false) {} | 61 Texture() : client_id(0), sent_to_client(false) {} |
| 60 | 62 |
| 61 // The client-side id in the parent stub. | 63 // The client-side id in the parent stub. |
| 62 uint32 client_id; | 64 uint32 client_id; |
| 63 | 65 |
| 64 // The currently allocated size. | 66 // The currently allocated size. |
| 65 gfx::Size size; | 67 gfx::Size size; |
| 66 | 68 |
| 67 // Whether or not that texture has been sent to the client yet. | 69 // Whether or not that texture has been sent to the client yet. |
| 68 bool sent_to_client; | 70 bool sent_to_client; |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 virtual ~TextureImageTransportSurface(); | 73 virtual ~TextureImageTransportSurface(); |
| 72 void CreateBackTexture(const gfx::Size& size); | 74 void CreateTexture(int id, const gfx::Size& size); |
| 73 void ReleaseBackTexture(); | 75 void RequestReleaseTexture(int id); |
| 74 void AttachBackTextureToFBO(); | 76 void ReleaseTexture(int id); |
| 77 void AttachTextureToFBO(int id); |
| 75 gpu::gles2::TextureManager::TextureInfo* GetParentInfo(uint32 client_id); | 78 gpu::gles2::TextureManager::TextureInfo* GetParentInfo(uint32 client_id); |
| 79 int front() const { return front_; } |
| 76 int back() const { return 1 - front_; } | 80 int back() const { return 1 - front_; } |
| 77 | 81 |
| 78 // The framebuffer that represents this surface (service id). Allocated lazily | 82 // The framebuffer that represents this surface (service id). Allocated lazily |
| 79 // in OnMakeCurrent. | 83 // in OnMakeCurrent. |
| 80 uint32 fbo_id_; | 84 uint32 fbo_id_; |
| 81 | 85 |
| 82 // The front and back buffers. | 86 // The front and back buffers. |
| 83 Texture textures_[2]; | 87 Texture textures_[2]; |
| 84 | 88 |
| 85 gfx::Rect previous_damage_rect_; | 89 gfx::Rect previous_damage_rect_; |
| 86 | 90 |
| 87 // Indicates which of the 2 above is the front buffer. | 91 // Indicates which of the 2 above is the front buffer. |
| 88 int front_; | 92 int front_; |
| 89 | 93 |
| 90 // Whether or not the command buffer stub has been destroyed. | 94 // Whether or not the command buffer stub has been destroyed. |
| 91 bool stub_destroyed_; | 95 bool stub_destroyed_; |
| 92 | 96 |
| 97 bool backbuffer_allocated_; |
| 98 bool frontbuffer_allocated_; |
| 99 |
| 93 scoped_ptr<ImageTransportHelper> helper_; | 100 scoped_ptr<ImageTransportHelper> helper_; |
| 94 base::WeakPtr<GpuCommandBufferStub> parent_stub_; | 101 base::WeakPtr<GpuCommandBufferStub> parent_stub_; |
| 95 | 102 |
| 96 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface); | 103 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface); |
| 97 }; | 104 }; |
| 98 | 105 |
| 99 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ | 106 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ |
| OLD | NEW |