| 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/common/gpu/texture_image_transport_surface.h" | 5 #include "content/common/gpu/texture_image_transport_surface.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // resources we allocated in the stub's context. | 195 // resources we allocated in the stub's context. |
| 196 if (fbo_id_) { | 196 if (fbo_id_) { |
| 197 glDeleteFramebuffersEXT(1, &fbo_id_); | 197 glDeleteFramebuffersEXT(1, &fbo_id_); |
| 198 CHECK_GL_ERROR(); | 198 CHECK_GL_ERROR(); |
| 199 fbo_id_ = 0; | 199 fbo_id_ = 0; |
| 200 } | 200 } |
| 201 | 201 |
| 202 stub_destroyed_ = true; | 202 stub_destroyed_ = true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void TextureImageTransportSurface::SetLatencyInfo( |
| 206 const cc::LatencyInfo& latency_info) { |
| 207 if (latency_info_.rendererImplFrameNumber != |
| 208 latency_info.rendererImplFrameNumber) { |
| 209 TRACE_EVENT_ASYNC_BEGIN2("frame", "Renderer Frame", this, |
| 210 "frame_number", |
| 211 latency_info.rendererImplFrameNumber, |
| 212 "input_number", latency_info.inputNumber); |
| 213 } |
| 214 |
| 215 latency_info_ = latency_info; |
| 216 } |
| 217 |
| 205 bool TextureImageTransportSurface::SwapBuffers() { | 218 bool TextureImageTransportSurface::SwapBuffers() { |
| 206 DCHECK(backbuffer_suggested_allocation_); | 219 DCHECK(backbuffer_suggested_allocation_); |
| 220 TRACE_EVENT_ASYNC_END2("frame", "Renderer Frame", this, |
| 221 "frame_number", latency_info_.rendererImplFrameNumber, |
| 222 "input_number", latency_info_.inputNumber); |
| 223 |
| 207 if (!frontbuffer_suggested_allocation_) | 224 if (!frontbuffer_suggested_allocation_) |
| 208 return true; | 225 return true; |
| 209 | 226 |
| 210 DCHECK(backbuffer_.size == current_size_); | 227 DCHECK(backbuffer_.size == current_size_); |
| 211 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 228 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 212 params.size = backbuffer_.size; | 229 params.size = backbuffer_.size; |
| 213 const MailboxName& name = backbuffer_.mailbox_name; | 230 const MailboxName& name = backbuffer_.mailbox_name; |
| 214 params.mailbox_name.assign( | 231 params.mailbox_name.assign( |
| 215 reinterpret_cast<const char*>(&name), sizeof(name)); | 232 reinterpret_cast<const char*>(&name), sizeof(name)); |
| 216 | 233 |
| 217 glFlush(); | 234 glFlush(); |
| 218 ProduceTexture(backbuffer_); | 235 ProduceTexture(backbuffer_); |
| 219 | 236 |
| 220 // Do not allow destruction while we are still waiting for a swap ACK, | 237 // Do not allow destruction while we are still waiting for a swap ACK, |
| 221 // so we do not leak a texture in the mailbox. | 238 // so we do not leak a texture in the mailbox. |
| 222 AddRef(); | 239 AddRef(); |
| 223 | 240 |
| 241 params.latency_info = latency_info_; |
| 224 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 242 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 225 | 243 |
| 226 DCHECK(!is_swap_buffers_pending_); | 244 DCHECK(!is_swap_buffers_pending_); |
| 227 is_swap_buffers_pending_ = true; | 245 is_swap_buffers_pending_ = true; |
| 228 return true; | 246 return true; |
| 229 } | 247 } |
| 230 | 248 |
| 231 bool TextureImageTransportSurface::PostSubBuffer( | 249 bool TextureImageTransportSurface::PostSubBuffer( |
| 232 int x, int y, int width, int height) { | 250 int x, int y, int width, int height) { |
| 233 DCHECK(backbuffer_suggested_allocation_); | 251 DCHECK(backbuffer_suggested_allocation_); |
| 252 TRACE_EVENT_ASYNC_END2("frame", "Renderer Frame", this, |
| 253 "frame_number", latency_info_.rendererImplFrameNumber, |
| 254 "input_number", latency_info_.inputNumber); |
| 234 if (!frontbuffer_suggested_allocation_) | 255 if (!frontbuffer_suggested_allocation_) |
| 235 return true; | 256 return true; |
| 236 const gfx::Rect new_damage_rect(x, y, width, height); | 257 const gfx::Rect new_damage_rect(x, y, width, height); |
| 237 DCHECK(gfx::Rect(gfx::Point(), current_size_).Contains(new_damage_rect)); | 258 DCHECK(gfx::Rect(gfx::Point(), current_size_).Contains(new_damage_rect)); |
| 238 | 259 |
| 239 // An empty damage rect is a successful no-op. | 260 // An empty damage rect is a successful no-op. |
| 240 if (new_damage_rect.IsEmpty()) | 261 if (new_damage_rect.IsEmpty()) |
| 241 return true; | 262 return true; |
| 242 | 263 |
| 243 DCHECK(current_size_ == backbuffer_.size); | 264 DCHECK(current_size_ == backbuffer_.size); |
| 244 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 265 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
| 245 params.surface_size = backbuffer_.size; | 266 params.surface_size = backbuffer_.size; |
| 246 params.x = x; | 267 params.x = x; |
| 247 params.y = y; | 268 params.y = y; |
| 248 params.width = width; | 269 params.width = width; |
| 249 params.height = height; | 270 params.height = height; |
| 250 const MailboxName& name = backbuffer_.mailbox_name; | 271 const MailboxName& name = backbuffer_.mailbox_name; |
| 251 params.mailbox_name.assign( | 272 params.mailbox_name.assign( |
| 252 reinterpret_cast<const char*>(&name), sizeof(name)); | 273 reinterpret_cast<const char*>(&name), sizeof(name)); |
| 253 | 274 |
| 254 glFlush(); | 275 glFlush(); |
| 255 ProduceTexture(backbuffer_); | 276 ProduceTexture(backbuffer_); |
| 256 | 277 |
| 257 // Do not allow destruction while we are still waiting for a swap ACK, | 278 // Do not allow destruction while we are still waiting for a swap ACK, |
| 258 // so we do not leak a texture in the mailbox. | 279 // so we do not leak a texture in the mailbox. |
| 259 AddRef(); | 280 AddRef(); |
| 260 | 281 |
| 282 params.latency_info = latency_info_; |
| 261 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 283 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
| 262 | 284 |
| 263 DCHECK(!is_swap_buffers_pending_); | 285 DCHECK(!is_swap_buffers_pending_); |
| 264 is_swap_buffers_pending_ = true; | 286 is_swap_buffers_pending_ = true; |
| 265 return true; | 287 return true; |
| 266 } | 288 } |
| 267 | 289 |
| 268 std::string TextureImageTransportSurface::GetExtensions() { | 290 std::string TextureImageTransportSurface::GetExtensions() { |
| 269 std::string extensions = gfx::GLSurface::GetExtensions(); | 291 std::string extensions = gfx::GLSurface::GetExtensions(); |
| 270 extensions += extensions.empty() ? "" : " "; | 292 extensions += extensions.empty() ? "" : " "; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 GL_TEXTURE_2D, | 490 GL_TEXTURE_2D, |
| 469 texture.mailbox_name, | 491 texture.mailbox_name, |
| 470 definition.release(), | 492 definition.release(), |
| 471 NULL); | 493 NULL); |
| 472 DCHECK(success); | 494 DCHECK(success); |
| 473 texture.service_id = 0; | 495 texture.service_id = 0; |
| 474 texture.mailbox_name = MailboxName(); | 496 texture.mailbox_name = MailboxName(); |
| 475 } | 497 } |
| 476 | 498 |
| 477 } // namespace content | 499 } // namespace content |
| OLD | NEW |