| 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 "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "ui/gfx/swap_result.h" |
| 15 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
| 16 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
| 17 #include "ui/gl/gl_switches.h" | 18 #include "ui/gl/gl_switches.h" |
| 18 | 19 |
| 19 #if defined(USE_X11) | 20 #if defined(USE_X11) |
| 20 #include <X11/Xlib.h> | 21 #include <X11/Xlib.h> |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 namespace gfx { | 24 namespace gfx { |
| 24 | 25 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 bool GLSurface::SupportsPostSubBuffer() { | 188 bool GLSurface::SupportsPostSubBuffer() { |
| 188 return false; | 189 return false; |
| 189 } | 190 } |
| 190 | 191 |
| 191 unsigned int GLSurface::GetBackingFrameBufferObject() { | 192 unsigned int GLSurface::GetBackingFrameBufferObject() { |
| 192 return 0; | 193 return 0; |
| 193 } | 194 } |
| 194 | 195 |
| 195 bool GLSurface::SwapBuffersAsync(const SwapCompletionCallback& callback) { | 196 bool GLSurface::SwapBuffersAsync(const SwapCompletionCallback& callback) { |
| 196 DCHECK(!IsSurfaceless()); | 197 DCHECK(!IsSurfaceless()); |
| 197 bool success = SwapBuffers(); | 198 gfx::SwapResult result = SwapBuffers(); |
| 198 callback.Run(); | 199 callback.Run(result); |
| 199 return success; | 200 return result == gfx::SWAP_ACK; |
| 200 } | 201 } |
| 201 | 202 |
| 202 bool GLSurface::PostSubBuffer(int x, int y, int width, int height) { | 203 gfx::SwapResult GLSurface::PostSubBuffer(int x, int y, int width, int height) { |
| 203 return false; | 204 return gfx::SWAP_FAILED; |
| 204 } | 205 } |
| 205 | 206 |
| 206 bool GLSurface::PostSubBufferAsync(int x, | 207 bool GLSurface::PostSubBufferAsync(int x, |
| 207 int y, | 208 int y, |
| 208 int width, | 209 int width, |
| 209 int height, | 210 int height, |
| 210 const SwapCompletionCallback& callback) { | 211 const SwapCompletionCallback& callback) { |
| 211 bool success = PostSubBuffer(x, y, width, height); | 212 gfx::SwapResult result = PostSubBuffer(x, y, width, height); |
| 212 callback.Run(); | 213 callback.Run(result); |
| 213 return success; | 214 return result == gfx::SWAP_ACK; |
| 214 } | 215 } |
| 215 | 216 |
| 216 bool GLSurface::OnMakeCurrent(GLContext* context) { | 217 bool GLSurface::OnMakeCurrent(GLContext* context) { |
| 217 return true; | 218 return true; |
| 218 } | 219 } |
| 219 | 220 |
| 220 void GLSurface::NotifyWasBound() { | 221 void GLSurface::NotifyWasBound() { |
| 221 } | 222 } |
| 222 | 223 |
| 223 bool GLSurface::SetBackbufferAllocation(bool allocated) { | 224 bool GLSurface::SetBackbufferAllocation(bool allocated) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 313 } |
| 313 | 314 |
| 314 bool GLSurfaceAdapter::DeferDraws() { | 315 bool GLSurfaceAdapter::DeferDraws() { |
| 315 return surface_->DeferDraws(); | 316 return surface_->DeferDraws(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 bool GLSurfaceAdapter::IsOffscreen() { | 319 bool GLSurfaceAdapter::IsOffscreen() { |
| 319 return surface_->IsOffscreen(); | 320 return surface_->IsOffscreen(); |
| 320 } | 321 } |
| 321 | 322 |
| 322 bool GLSurfaceAdapter::SwapBuffers() { | 323 gfx::SwapResult GLSurfaceAdapter::SwapBuffers() { |
| 323 return surface_->SwapBuffers(); | 324 return surface_->SwapBuffers(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 bool GLSurfaceAdapter::SwapBuffersAsync( | 327 bool GLSurfaceAdapter::SwapBuffersAsync( |
| 327 const SwapCompletionCallback& callback) { | 328 const SwapCompletionCallback& callback) { |
| 328 return surface_->SwapBuffersAsync(callback); | 329 return surface_->SwapBuffersAsync(callback); |
| 329 } | 330 } |
| 330 | 331 |
| 331 bool GLSurfaceAdapter::PostSubBuffer(int x, int y, int width, int height) { | 332 gfx::SwapResult GLSurfaceAdapter::PostSubBuffer(int x, |
| 333 int y, |
| 334 int width, |
| 335 int height) { |
| 332 return surface_->PostSubBuffer(x, y, width, height); | 336 return surface_->PostSubBuffer(x, y, width, height); |
| 333 } | 337 } |
| 334 | 338 |
| 335 bool GLSurfaceAdapter::PostSubBufferAsync( | 339 bool GLSurfaceAdapter::PostSubBufferAsync( |
| 336 int x, int y, int width, int height, | 340 int x, int y, int width, int height, |
| 337 const SwapCompletionCallback& callback) { | 341 const SwapCompletionCallback& callback) { |
| 338 return surface_->PostSubBufferAsync(x, y, width, height, callback); | 342 return surface_->PostSubBufferAsync(x, y, width, height, callback); |
| 339 } | 343 } |
| 340 | 344 |
| 341 bool GLSurfaceAdapter::SupportsPostSubBuffer() { | 345 bool GLSurfaceAdapter::SupportsPostSubBuffer() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 z_order, transform, image, bounds_rect, crop_rect); | 399 z_order, transform, image, bounds_rect, crop_rect); |
| 396 } | 400 } |
| 397 | 401 |
| 398 bool GLSurfaceAdapter::IsSurfaceless() const { | 402 bool GLSurfaceAdapter::IsSurfaceless() const { |
| 399 return surface_->IsSurfaceless(); | 403 return surface_->IsSurfaceless(); |
| 400 } | 404 } |
| 401 | 405 |
| 402 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 406 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
| 403 | 407 |
| 404 } // namespace gfx | 408 } // namespace gfx |
| OLD | NEW |