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 "content/common/gpu/gpu_command_buffer_stub.h" | 10 #include "content/common/gpu/gpu_command_buffer_stub.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 virtual void Destroy() OVERRIDE; | 28 virtual void Destroy() OVERRIDE; |
29 virtual bool Resize(const gfx::Size& size) OVERRIDE; | 29 virtual bool Resize(const gfx::Size& size) OVERRIDE; |
30 virtual bool IsOffscreen() OVERRIDE; | 30 virtual bool IsOffscreen() OVERRIDE; |
31 virtual bool SwapBuffers() OVERRIDE; | 31 virtual bool SwapBuffers() OVERRIDE; |
32 virtual gfx::Size GetSize() OVERRIDE; | 32 virtual gfx::Size GetSize() OVERRIDE; |
33 virtual void* GetHandle() OVERRIDE; | 33 virtual void* GetHandle() OVERRIDE; |
34 virtual std::string GetExtensions() OVERRIDE; | 34 virtual std::string GetExtensions() OVERRIDE; |
35 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 35 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
36 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 36 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
37 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 37 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
38 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; | 38 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
39 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | |
39 virtual void* GetShareHandle() OVERRIDE; | 40 virtual void* GetShareHandle() OVERRIDE; |
40 virtual void* GetDisplay() OVERRIDE; | 41 virtual void* GetDisplay() OVERRIDE; |
41 virtual void* GetConfig() OVERRIDE; | 42 virtual void* GetConfig() OVERRIDE; |
42 | 43 |
43 protected: | 44 protected: |
44 // ImageTransportSurface implementation. | 45 // ImageTransportSurface implementation. |
45 virtual void OnNewSurfaceACK( | 46 virtual void OnNewSurfaceACK( |
46 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; | 47 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
47 virtual void OnBuffersSwappedACK() OVERRIDE; | 48 virtual void OnBuffersSwappedACK() OVERRIDE; |
48 virtual void OnPostSubBufferACK() OVERRIDE; | 49 virtual void OnPostSubBufferACK() OVERRIDE; |
49 virtual void OnResizeViewACK() OVERRIDE; | 50 virtual void OnResizeViewACK() OVERRIDE; |
51 virtual void OnDiscardSurface(uint64 surface_id) OVERRIDE; | |
50 virtual void OnResize(gfx::Size size) OVERRIDE; | 52 virtual void OnResize(gfx::Size size) OVERRIDE; |
51 | 53 |
52 // GpuCommandBufferStub::DestructionObserver implementation. | 54 // GpuCommandBufferStub::DestructionObserver implementation. |
53 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE; | 55 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE; |
54 | 56 |
55 private: | 57 private: |
56 // A texture backing the front/back buffer in the parent stub. | 58 // A texture backing the front/back buffer in the parent stub. |
57 struct Texture { | 59 struct Texture { |
58 Texture(); | 60 Texture(); |
59 ~Texture(); | 61 ~Texture(); |
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; |
71 bool allocated; | |
72 bool suggested_allocation; | |
piman
2012/05/04 00:03:49
I don't think suggested_allocation belongs here. O
mmocny
2012/05/04 18:55:52
Suggested allocation has evolved with this patch a
| |
69 | 73 |
70 // The texture info in the parent stub. | 74 // The texture info in the parent stub. |
71 gpu::gles2::TextureManager::TextureInfo::Ref info; | 75 gpu::gles2::TextureManager::TextureInfo::Ref info; |
72 }; | 76 }; |
73 | 77 |
74 virtual ~TextureImageTransportSurface(); | 78 virtual ~TextureImageTransportSurface(); |
75 void CreateBackTexture(const gfx::Size& size); | 79 void CreateTexture(int id, const gfx::Size& size); |
76 void ReleaseBackTexture(); | 80 void RequestReleaseTexture(int id); |
77 void AttachBackTextureToFBO(); | 81 void ReleaseTexture(int id); |
82 void AttachTextureToFBO(int id); | |
78 void ReleaseParentStub(); | 83 void ReleaseParentStub(); |
84 int front() const { return front_; } | |
79 int back() const { return 1 - front_; } | 85 int back() const { return 1 - front_; } |
80 | 86 |
81 // The framebuffer that represents this surface (service id). Allocated lazily | 87 // The framebuffer that represents this surface (service id). Allocated lazily |
82 // in OnMakeCurrent. | 88 // in OnMakeCurrent. |
83 uint32 fbo_id_; | 89 uint32 fbo_id_; |
84 | 90 |
85 // The front and back buffers. | 91 // The front and back buffers. |
86 Texture textures_[2]; | 92 Texture textures_[2]; |
87 | 93 |
88 gfx::Rect previous_damage_rect_; | 94 gfx::Rect previous_damage_rect_; |
89 | 95 |
90 // Indicates which of the 2 above is the front buffer. | 96 // Indicates which of the 2 above is the front buffer. |
91 int front_; | 97 int front_; |
92 | 98 |
93 // Whether or not the command buffer stub has been destroyed. | 99 // Whether or not the command buffer stub has been destroyed. |
94 bool stub_destroyed_; | 100 bool stub_destroyed_; |
95 | 101 |
96 scoped_ptr<ImageTransportHelper> helper_; | 102 scoped_ptr<ImageTransportHelper> helper_; |
97 GpuCommandBufferStub* parent_stub_; | 103 GpuCommandBufferStub* parent_stub_; |
98 | 104 |
99 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface); | 105 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface); |
100 }; | 106 }; |
101 | 107 |
102 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ | 108 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ |
OLD | NEW |