| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 103 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 104 current_backing_.texture_id, 0); | 104 current_backing_.texture_id, 0); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void MailboxOutputSurface::SendFrameToParentCompositor( | 107 void MailboxOutputSurface::SendFrameToParentCompositor( |
| 108 cc::CompositorFrame* frame) { | 108 cc::CompositorFrame* frame) { |
| 109 frame->gl_frame_data.reset(new GLFrameData()); | 109 frame->gl_frame_data.reset(new GLFrameData()); |
| 110 | 110 |
| 111 DCHECK(!size_.IsEmpty()); | 111 DCHECK(!size_.IsEmpty()); |
| 112 DCHECK(size_ == current_backing_.size); | 112 DCHECK(size_ == current_backing_.size); |
| 113 DCHECK(!current_backing_.mailbox.isZero()); | 113 DCHECK(!current_backing_.mailbox.IsZero()); |
| 114 | 114 |
| 115 context3d_->framebufferTexture2D( | 115 context3d_->framebufferTexture2D( |
| 116 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | 116 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
| 117 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); | 117 context3d_->bindTexture(GL_TEXTURE_2D, current_backing_.texture_id); |
| 118 context3d_->produceTextureCHROMIUM( | 118 context3d_->produceTextureCHROMIUM( |
| 119 GL_TEXTURE_2D, current_backing_.mailbox.name); | 119 GL_TEXTURE_2D, current_backing_.mailbox.name); |
| 120 frame->gl_frame_data->mailbox = current_backing_.mailbox; | 120 frame->gl_frame_data->mailbox = current_backing_.mailbox; |
| 121 frame->gl_frame_data->size = current_backing_.size; | 121 frame->gl_frame_data->size = current_backing_.size; |
| 122 context3d_->flush(); | 122 context3d_->flush(); |
| 123 frame->gl_frame_data->sync_point = context3d_->insertSyncPoint(); | 123 frame->gl_frame_data->sync_point = context3d_->insertSyncPoint(); |
| 124 context3d_->deleteTexture(current_backing_.texture_id); | 124 context3d_->deleteTexture(current_backing_.texture_id); |
| 125 current_backing_ = TransferableFrame(); | 125 current_backing_ = TransferableFrame(); |
| 126 CompositorOutputSurface::SendFrameToParentCompositor(frame); | 126 CompositorOutputSurface::SendFrameToParentCompositor(frame); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void MailboxOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 129 void MailboxOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
| 130 if (!ack.gl_frame_data->mailbox.isZero()) { | 130 if (!ack.gl_frame_data->mailbox.IsZero()) { |
| 131 DCHECK(!ack.gl_frame_data->size.IsEmpty()); | 131 DCHECK(!ack.gl_frame_data->size.IsEmpty()); |
| 132 uint32 texture_id = context3d_->createTexture(); | 132 uint32 texture_id = context3d_->createTexture(); |
| 133 TransferableFrame texture( | 133 TransferableFrame texture( |
| 134 texture_id, ack.gl_frame_data->mailbox, ack.gl_frame_data->size); | 134 texture_id, ack.gl_frame_data->mailbox, ack.gl_frame_data->size); |
| 135 | 135 |
| 136 context3d_->bindTexture(GL_TEXTURE_2D, texture_id); | 136 context3d_->bindTexture(GL_TEXTURE_2D, texture_id); |
| 137 | 137 |
| 138 // If the consumer is bouncing back the same texture (i.e. skipping the | 138 // If the consumer is bouncing back the same texture (i.e. skipping the |
| 139 // frame), we don't have to synchronize here (sync_point == 0). | 139 // frame), we don't have to synchronize here (sync_point == 0). |
| 140 if (ack.gl_frame_data->sync_point) | 140 if (ack.gl_frame_data->sync_point) |
| 141 context3d_->waitSyncPoint(ack.gl_frame_data->sync_point); | 141 context3d_->waitSyncPoint(ack.gl_frame_data->sync_point); |
| 142 | 142 |
| 143 context3d_->consumeTextureCHROMIUM( | 143 context3d_->consumeTextureCHROMIUM( |
| 144 GL_TEXTURE_2D, ack.gl_frame_data->mailbox.name); | 144 GL_TEXTURE_2D, ack.gl_frame_data->mailbox.name); |
| 145 returned_textures_.push(texture); | 145 returned_textures_.push(texture); |
| 146 } | 146 } |
| 147 CompositorOutputSurface::OnSwapAck(ack); | 147 CompositorOutputSurface::OnSwapAck(ack); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void MailboxOutputSurface::SwapBuffers() { | 150 void MailboxOutputSurface::SwapBuffers() { |
| 151 } | 151 } |
| 152 | 152 |
| 153 void MailboxOutputSurface::PostSubBuffer(const gfx::Rect& rect) { | 153 void MailboxOutputSurface::PostSubBuffer(const gfx::Rect& rect) { |
| 154 NOTIMPLEMENTED() | 154 NOTIMPLEMENTED() |
| 155 << "Partial swap not supported with composite-to-mailbox yet."; | 155 << "Partial swap not supported with composite-to-mailbox yet."; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace content | 158 } // namespace content |
| OLD | NEW |