| 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/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
| 10 #include "cc/output/gl_frame_data.h" | 10 #include "cc/output/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 gpu::Mailbox; | 17 using gpu::Mailbox; |
| 18 using WebKit::WebGraphicsContext3D; | |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 | 20 |
| 22 MailboxOutputSurface::MailboxOutputSurface( | 21 MailboxOutputSurface::MailboxOutputSurface( |
| 23 int32 routing_id, | 22 int32 routing_id, |
| 24 WebGraphicsContext3D* context3D, | 23 WebGraphicsContext3DCommandBufferImpl* context3D, |
| 25 cc::SoftwareOutputDevice* software_device) | 24 cc::SoftwareOutputDevice* software_device) |
| 26 : CompositorOutputSurface(routing_id, context3D, software_device), | 25 : CompositorOutputSurface(routing_id, context3D, software_device), |
| 27 fbo_(0), | 26 fbo_(0), |
| 28 is_backbuffer_discarded_(false) { | 27 is_backbuffer_discarded_(false) { |
| 29 pending_textures_.push_back(TransferableFrame()); | 28 pending_textures_.push_back(TransferableFrame()); |
| 30 capabilities_.max_frames_pending = 1; | 29 capabilities_.max_frames_pending = 1; |
| 31 } | 30 } |
| 32 | 31 |
| 33 MailboxOutputSurface::~MailboxOutputSurface() { | 32 MailboxOutputSurface::~MailboxOutputSurface() { |
| 34 DiscardBackbuffer(); | 33 DiscardBackbuffer(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // If it does not return a mailbox, it discarded the frontbuffer which is | 176 // If it does not return a mailbox, it discarded the frontbuffer which is |
| 178 // the oldest texture we sent. | 177 // the oldest texture we sent. |
| 179 uint32 texture_id = pending_textures_.front().texture_id; | 178 uint32 texture_id = pending_textures_.front().texture_id; |
| 180 if (texture_id) | 179 if (texture_id) |
| 181 context3d_->deleteTexture(texture_id); | 180 context3d_->deleteTexture(texture_id); |
| 182 pending_textures_.pop_front(); | 181 pending_textures_.pop_front(); |
| 183 } | 182 } |
| 184 CompositorOutputSurface::OnSwapAck(ack); | 183 CompositorOutputSurface::OnSwapAck(ack); |
| 185 } | 184 } |
| 186 | 185 |
| 187 void MailboxOutputSurface::SwapBuffers() { | 186 void MailboxOutputSurface::SwapBuffers(const cc::LatencyInfo&) { |
| 188 } | 187 } |
| 189 | 188 |
| 190 void MailboxOutputSurface::PostSubBuffer(gfx::Rect rect) { | 189 void MailboxOutputSurface::PostSubBuffer(gfx::Rect rect, |
| 190 const cc::LatencyInfo&) { |
| 191 NOTIMPLEMENTED() | 191 NOTIMPLEMENTED() |
| 192 << "Partial swap not supported with composite-to-mailbox yet."; | 192 << "Partial swap not supported with composite-to-mailbox yet."; |
| 193 | 193 |
| 194 // The browser only copies damage correctly for two buffers in use. | 194 // The browser only copies damage correctly for two buffers in use. |
| 195 DCHECK(GetNumAcksPending() < 2); | 195 DCHECK(GetNumAcksPending() < 2); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void MailboxOutputSurface::ConsumeTexture(const TransferableFrame& frame) { | 198 void MailboxOutputSurface::ConsumeTexture(const TransferableFrame& frame) { |
| 199 DCHECK(!frame.mailbox.IsZero()); | 199 DCHECK(!frame.mailbox.IsZero()); |
| 200 if (frame.sync_point) | 200 if (frame.sync_point) |
| 201 context3d_->waitSyncPoint(frame.sync_point); | 201 context3d_->waitSyncPoint(frame.sync_point); |
| 202 | 202 |
| 203 context3d_->bindTexture(GL_TEXTURE_2D, frame.texture_id); | 203 context3d_->bindTexture(GL_TEXTURE_2D, frame.texture_id); |
| 204 context3d_->consumeTextureCHROMIUM(GL_TEXTURE_2D, frame.mailbox.name); | 204 context3d_->consumeTextureCHROMIUM(GL_TEXTURE_2D, frame.mailbox.name); |
| 205 } | 205 } |
| 206 | 206 |
| 207 size_t MailboxOutputSurface::GetNumAcksPending() { | 207 size_t MailboxOutputSurface::GetNumAcksPending() { |
| 208 DCHECK(pending_textures_.size()); | 208 DCHECK(pending_textures_.size()); |
| 209 return pending_textures_.size() - 1; | 209 return pending_textures_.size() - 1; |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace content | 212 } // namespace content |
| OLD | NEW |