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