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 #include "content/renderer/gpu/mailbox_output_surface.h" | 5 #include "content/renderer/gpu/mailbox_output_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
9 #include "cc/compositor_frame_ack.h" | 9 #include "cc/compositor_frame_ack.h" |
10 #include "cc/gl_frame_data.h" | 10 #include "cc/gl_frame_data.h" |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
12 #include "third_party/khronos/GLES2/gl2.h" | 12 #include "third_party/khronos/GLES2/gl2.h" |
13 #include "third_party/khronos/GLES2/gl2ext.h" | 13 #include "third_party/khronos/GLES2/gl2ext.h" |
14 | 14 |
15 using cc::CompositorFrame; | 15 using cc::CompositorFrame; |
16 using cc::GLFrameData; | 16 using cc::GLFrameData; |
17 using cc::Mailbox; | 17 using gpu::Mailbox; |
18 using WebKit::WebGraphicsContext3D; | 18 using WebKit::WebGraphicsContext3D; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 MailboxOutputSurface::MailboxOutputSurface( | 22 MailboxOutputSurface::MailboxOutputSurface( |
23 int32 routing_id, | 23 int32 routing_id, |
24 WebGraphicsContext3D* context3D, | 24 WebGraphicsContext3D* context3D, |
25 cc::SoftwareOutputDevice* software_device) | 25 cc::SoftwareOutputDevice* software_device) |
26 : CompositorOutputSurface(routing_id, | 26 : CompositorOutputSurface(routing_id, |
27 context3D, | 27 context3D, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 106 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
107 current_backing_.texture_id, 0); | 107 current_backing_.texture_id, 0); |
108 } | 108 } |
109 | 109 |
110 void MailboxOutputSurface::SendFrameToParentCompositor( | 110 void MailboxOutputSurface::SendFrameToParentCompositor( |
111 cc::CompositorFrame* frame) { | 111 cc::CompositorFrame* frame) { |
112 frame->gl_frame_data.reset(new GLFrameData()); | 112 frame->gl_frame_data.reset(new GLFrameData()); |
113 | 113 |
114 DCHECK(!size_.IsEmpty()); | 114 DCHECK(!size_.IsEmpty()); |
115 DCHECK(size_ == current_backing_.size); | 115 DCHECK(size_ == current_backing_.size); |
116 DCHECK(!current_backing_.mailbox.isZero()); | 116 DCHECK(!current_backing_.mailbox.IsZero()); |
117 | 117 |
118 context3d_->framebufferTexture2D( | 118 context3d_->framebufferTexture2D( |
119 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | 119 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
120 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); | 120 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); |
121 context3d_->produceTextureCHROMIUM( | 121 context3d_->produceTextureCHROMIUM( |
122 GL_TEXTURE_2D, current_backing_.mailbox.name); | 122 GL_TEXTURE_2D, current_backing_.mailbox.name); |
123 frame->gl_frame_data->mailbox = current_backing_.mailbox; | 123 frame->gl_frame_data->mailbox = current_backing_.mailbox; |
124 frame->gl_frame_data->size = current_backing_.size; | 124 frame->gl_frame_data->size = current_backing_.size; |
125 context3d_->flush(); | 125 context3d_->flush(); |
126 frame->gl_frame_data->sync_point = context3d_->insertSyncPoint(); | 126 frame->gl_frame_data->sync_point = context3d_->insertSyncPoint(); |
127 CompositorOutputSurface::SendFrameToParentCompositor(frame); | 127 CompositorOutputSurface::SendFrameToParentCompositor(frame); |
128 | 128 |
129 // TODO(sievers): Reuse the texture. | 129 // TODO(sievers): Reuse the texture. |
130 context3d_->deleteTexture(current_backing_.texture_id); | 130 context3d_->deleteTexture(current_backing_.texture_id); |
131 current_backing_ = TransferableFrame(); | 131 current_backing_ = TransferableFrame(); |
132 } | 132 } |
133 | 133 |
134 void MailboxOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 134 void MailboxOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
135 if (!ack.gl_frame_data->mailbox.isZero()) { | 135 if (!ack.gl_frame_data->mailbox.IsZero()) { |
136 DCHECK(!ack.gl_frame_data->size.IsEmpty()); | 136 DCHECK(!ack.gl_frame_data->size.IsEmpty()); |
137 uint32 texture_id = context3d_->createTexture(); | 137 uint32 texture_id = context3d_->createTexture(); |
138 TransferableFrame texture( | 138 TransferableFrame texture( |
139 texture_id, ack.gl_frame_data->mailbox, ack.gl_frame_data->size); | 139 texture_id, ack.gl_frame_data->mailbox, ack.gl_frame_data->size); |
140 | 140 |
141 context3d_->bindTexture(GL_TEXTURE_2D, texture_id); | 141 context3d_->bindTexture(GL_TEXTURE_2D, texture_id); |
142 | 142 |
143 // If the consumer is bouncing back the same texture (i.e. skipping the | 143 // If the consumer is bouncing back the same texture (i.e. skipping the |
144 // frame), we don't have to synchronize here (sync_point == 0). | 144 // frame), we don't have to synchronize here (sync_point == 0). |
145 // TODO: Consider delaying the wait and consume until BindFramebuffer. | 145 // TODO: Consider delaying the wait and consume until BindFramebuffer. |
146 if (ack.gl_frame_data->sync_point) | 146 if (ack.gl_frame_data->sync_point) |
147 context3d_->waitSyncPoint(ack.gl_frame_data->sync_point); | 147 context3d_->waitSyncPoint(ack.gl_frame_data->sync_point); |
148 | 148 |
149 context3d_->consumeTextureCHROMIUM( | 149 context3d_->consumeTextureCHROMIUM( |
150 GL_TEXTURE_2D, ack.gl_frame_data->mailbox.name); | 150 GL_TEXTURE_2D, ack.gl_frame_data->mailbox.name); |
151 returned_textures_.push(texture); | 151 returned_textures_.push(texture); |
152 } | 152 } |
153 CompositorOutputSurface::OnSwapAck(ack); | 153 CompositorOutputSurface::OnSwapAck(ack); |
154 } | 154 } |
155 | 155 |
156 void MailboxOutputSurface::SwapBuffers() { | 156 void MailboxOutputSurface::SwapBuffers() { |
157 } | 157 } |
158 | 158 |
159 void MailboxOutputSurface::PostSubBuffer(gfx::Rect rect) { | 159 void MailboxOutputSurface::PostSubBuffer(gfx::Rect rect) { |
160 NOTIMPLEMENTED() | 160 NOTIMPLEMENTED() |
161 << "Partial swap not supported with composite-to-mailbox yet."; | 161 << "Partial swap not supported with composite-to-mailbox yet."; |
162 } | 162 } |
163 | 163 |
164 } // namespace content | 164 } // namespace content |
OLD | NEW |