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

Side by Side Diff: content/common/gpu/texture_image_transport_surface.h

Issue 11194042: Implement TextureImageTransportSurface using texture mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_aura DCHECK() Created 8 years 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 | Annotate | Revision Log
OLDNEW
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 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/gpu/gpu_command_buffer_stub.h" 9 #include "content/common/gpu/gpu_command_buffer_stub.h"
11 #include "content/common/gpu/image_transport_surface.h" 10 #include "content/common/gpu/image_transport_surface.h"
11 #include "gpu/command_buffer/service/mailbox_manager.h"
12 #include "gpu/command_buffer/service/texture_manager.h" 12 #include "gpu/command_buffer/service/texture_manager.h"
13 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface.h"
14 15
15 namespace content { 16 namespace content {
16 class GpuChannelManager; 17 class GpuChannelManager;
17 18
18 class TextureImageTransportSurface : 19 class TextureImageTransportSurface :
19 public ImageTransportSurface, 20 public ImageTransportSurface,
20 public GpuCommandBufferStub::DestructionObserver, 21 public GpuCommandBufferStub::DestructionObserver,
21 public gfx::GLSurface, 22 public gfx::GLSurface {
22 public base::SupportsWeakPtr<TextureImageTransportSurface> {
23 public: 23 public:
24 TextureImageTransportSurface(GpuChannelManager* manager, 24 TextureImageTransportSurface(GpuChannelManager* manager,
25 GpuCommandBufferStub* stub, 25 GpuCommandBufferStub* stub,
26 const gfx::GLSurfaceHandle& handle); 26 const gfx::GLSurfaceHandle& handle);
27 27
28 // gfx::GLSurface implementation. 28 // gfx::GLSurface implementation.
29 virtual bool Initialize() OVERRIDE; 29 virtual bool Initialize() OVERRIDE;
30 virtual void Destroy() OVERRIDE; 30 virtual void Destroy() OVERRIDE;
31 virtual bool DeferDraws() OVERRIDE; 31 virtual bool DeferDraws() OVERRIDE;
32 virtual bool Resize(const gfx::Size& size) OVERRIDE; 32 virtual bool Resize(const gfx::Size& size) OVERRIDE;
33 virtual bool IsOffscreen() OVERRIDE; 33 virtual bool IsOffscreen() OVERRIDE;
34 virtual bool SwapBuffers() OVERRIDE; 34 virtual bool SwapBuffers() OVERRIDE;
35 virtual gfx::Size GetSize() OVERRIDE; 35 virtual gfx::Size GetSize() OVERRIDE;
36 virtual void* GetHandle() OVERRIDE; 36 virtual void* GetHandle() OVERRIDE;
37 virtual unsigned GetFormat() OVERRIDE; 37 virtual unsigned GetFormat() OVERRIDE;
38 virtual std::string GetExtensions() OVERRIDE; 38 virtual std::string GetExtensions() OVERRIDE;
39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
40 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; 40 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
41 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 41 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
42 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; 42 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE;
43 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; 43 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
44 virtual void* GetShareHandle() OVERRIDE; 44 virtual void* GetShareHandle() OVERRIDE;
45 virtual void* GetDisplay() OVERRIDE; 45 virtual void* GetDisplay() OVERRIDE;
46 virtual void* GetConfig() OVERRIDE; 46 virtual void* GetConfig() OVERRIDE;
47 47
48 protected: 48 protected:
49 // ImageTransportSurface implementation. 49 // ImageTransportSurface implementation.
50 virtual void OnBufferPresented( 50 virtual void OnBufferPresented(
51 bool presented, 51 uint64 surface_handle,
52 uint32 sync_point) OVERRIDE; 52 uint32 sync_point) OVERRIDE;
53 virtual void OnResizeViewACK() OVERRIDE; 53 virtual void OnResizeViewACK() OVERRIDE;
54 virtual void OnSetFrontSurfaceIsProtected(
55 bool is_protected,
56 uint32 protection_state_id) OVERRIDE;
57 virtual void OnResize(gfx::Size size) OVERRIDE; 54 virtual void OnResize(gfx::Size size) OVERRIDE;
58 55
59 // GpuCommandBufferStub::DestructionObserver implementation. 56 // GpuCommandBufferStub::DestructionObserver implementation.
60 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE; 57 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) OVERRIDE;
61 58
62 private: 59 private:
63 // A texture backing the front/back buffer in the parent stub. 60 // A texture backing the front/back buffer.
64 struct Texture { 61 struct Texture {
65 Texture(); 62 Texture();
66 ~Texture(); 63 ~Texture();
67 64
68 // The client-side id in the parent stub.
69 uint32 client_id;
70
71 // The currently allocated size. 65 // The currently allocated size.
72 gfx::Size size; 66 gfx::Size size;
73 67
74 // Whether or not that texture has been sent to the client yet. 68 // The actual GL texture id.
75 bool sent_to_client; 69 uint32 service_id;
76 70
77 // The texture info in the parent stub. 71 // The surface handle for this texture (only 1 and 2 are valid).
78 gpu::gles2::TextureManager::TextureInfo::Ref info; 72 uint64 surface_handle;
79 }; 73 };
80 74
81 virtual ~TextureImageTransportSurface(); 75 virtual ~TextureImageTransportSurface();
82 void CreateBackTexture(const gfx::Size& size); 76 void CreateBackTexture();
83 void AttachBackTextureToFBO(); 77 void AttachBackTextureToFBO();
84 void ReleaseTexture(int id); 78 void ReleaseBackTexture();
85 void ReleaseParentStub(); 79 void BufferPresentedImpl(uint64 surface_handle);
86 void AdjustFrontBufferAllocation(); 80 void ProduceTexture(Texture& texture);
87 void BufferPresentedImpl(bool presented); 81 void ConsumeTexture(Texture& texture);
88 int front() const { return front_; } 82
89 int back() const { return 1 - front_; } 83 gpu::gles2::MailboxName& mailbox_name(uint64 surface_handle) {
84 DCHECK(surface_handle == 1 || surface_handle == 2);
85 return mailbox_names_[surface_handle - 1];
86 }
90 87
91 // The framebuffer that represents this surface (service id). Allocated lazily 88 // The framebuffer that represents this surface (service id). Allocated lazily
92 // in OnMakeCurrent. 89 // in OnMakeCurrent.
93 uint32 fbo_id_; 90 uint32 fbo_id_;
94 91
95 // The front and back buffers. 92 // The current backbuffer.
96 Texture textures_[2]; 93 Texture backbuffer_;
97 94
98 gfx::Rect previous_damage_rect_; 95 // The current size of the GLSurface. Used to disambiguate from the current
99 96 // texture size which might be outdated (since we use two buffers).
100 // Indicates which of the 2 above is the front buffer. 97 gfx::Size current_size_;
101 int front_;
102 98
103 // Whether or not the command buffer stub has been destroyed. 99 // Whether or not the command buffer stub has been destroyed.
104 bool stub_destroyed_; 100 bool stub_destroyed_;
105 101
106 bool backbuffer_suggested_allocation_; 102 bool backbuffer_suggested_allocation_;
107 bool frontbuffer_suggested_allocation_; 103 bool frontbuffer_suggested_allocation_;
108 104
109 bool frontbuffer_is_protected_;
110 uint32 protection_state_id_;
111
112 scoped_ptr<ImageTransportHelper> helper_; 105 scoped_ptr<ImageTransportHelper> helper_;
113 gfx::GLSurfaceHandle handle_; 106 gfx::GLSurfaceHandle handle_;
114 GpuCommandBufferStub* parent_stub_;
115 107
116 // The offscreen surface used to make the context current. However note that 108 // The offscreen surface used to make the context current. However note that
117 // the actual rendering is always redirected to an FBO. 109 // the actual rendering is always redirected to an FBO.
118 scoped_refptr<GLSurface> surface_; 110 scoped_refptr<gfx::GLSurface> surface_;
111
112 // Holds a reference to the underlying context for cleanup.
113 scoped_refptr<gfx::GLContext> context_;
119 114
120 // Whether a SwapBuffers is pending. 115 // Whether a SwapBuffers is pending.
121 bool is_swap_buffers_pending_; 116 bool is_swap_buffers_pending_;
122 117
123 // Whether we unscheduled command buffer because of pending SwapBuffers. 118 // Whether we unscheduled command buffer because of pending SwapBuffers.
124 bool did_unschedule_; 119 bool did_unschedule_;
125 120
126 // Whether or not the buffer flip went through browser side on the last 121 // The mailbox names used for texture exchange. Uses surface_handle as key.
127 // swap or post sub buffer. 122 gpu::gles2::MailboxName mailbox_names_[2];
128 bool did_flip_; 123
124 // Holds a reference to the mailbox manager for cleanup.
125 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
129 126
130 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface); 127 DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface);
131 }; 128 };
132 129
133 } // namespace content 130 } // namespace content
134 131
135 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_ 132 #endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_win.cc ('k') | content/common/gpu/texture_image_transport_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698