| 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_wgl.h" | 5 #include "ui/gl/gl_surface_wgl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 DestroyWindow(child_window_); | 243 DestroyWindow(child_window_); |
| 244 | 244 |
| 245 child_window_ = NULL; | 245 child_window_ = NULL; |
| 246 device_context_ = NULL; | 246 device_context_ = NULL; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool NativeViewGLSurfaceWGL::IsOffscreen() { | 249 bool NativeViewGLSurfaceWGL::IsOffscreen() { |
| 250 return false; | 250 return false; |
| 251 } | 251 } |
| 252 | 252 |
| 253 gfx::SwapResult NativeViewGLSurfaceWGL::SwapBuffers() { | 253 bool NativeViewGLSurfaceWGL::SwapBuffers() { |
| 254 TRACE_EVENT2("gpu", "NativeViewGLSurfaceWGL:RealSwapBuffers", | 254 TRACE_EVENT2("gpu", "NativeViewGLSurfaceWGL:RealSwapBuffers", |
| 255 "width", GetSize().width(), | 255 "width", GetSize().width(), |
| 256 "height", GetSize().height()); | 256 "height", GetSize().height()); |
| 257 | 257 |
| 258 // Resize the child window to match the parent before swapping. Do not repaint | 258 // Resize the child window to match the parent before swapping. Do not repaint |
| 259 // it as it moves. | 259 // it as it moves. |
| 260 RECT rect; | 260 RECT rect; |
| 261 if (!GetClientRect(window_, &rect)) | 261 if (!GetClientRect(window_, &rect)) |
| 262 return gfx::SwapResult::SWAP_FAILED; | 262 return false; |
| 263 if (!MoveWindow(child_window_, | 263 if (!MoveWindow(child_window_, |
| 264 0, | 264 0, |
| 265 0, | 265 0, |
| 266 rect.right - rect.left, | 266 rect.right - rect.left, |
| 267 rect.bottom - rect.top, | 267 rect.bottom - rect.top, |
| 268 FALSE)) { | 268 FALSE)) { |
| 269 return gfx::SwapResult::SWAP_FAILED; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 DCHECK(device_context_); | 272 DCHECK(device_context_); |
| 273 return ::SwapBuffers(device_context_) == TRUE ? gfx::SwapResult::SWAP_ACK | 273 return ::SwapBuffers(device_context_) == TRUE; |
| 274 : gfx::SwapResult::SWAP_FAILED; | |
| 275 } | 274 } |
| 276 | 275 |
| 277 gfx::Size NativeViewGLSurfaceWGL::GetSize() { | 276 gfx::Size NativeViewGLSurfaceWGL::GetSize() { |
| 278 RECT rect; | 277 RECT rect; |
| 279 BOOL result = GetClientRect(child_window_, &rect); | 278 BOOL result = GetClientRect(child_window_, &rect); |
| 280 DCHECK(result); | 279 DCHECK(result); |
| 281 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); | 280 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); |
| 282 } | 281 } |
| 283 | 282 |
| 284 void* NativeViewGLSurfaceWGL::GetHandle() { | 283 void* NativeViewGLSurfaceWGL::GetHandle() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 if (pbuffer_) { | 338 if (pbuffer_) { |
| 340 wglDestroyPbufferARB(static_cast<HPBUFFERARB>(pbuffer_)); | 339 wglDestroyPbufferARB(static_cast<HPBUFFERARB>(pbuffer_)); |
| 341 pbuffer_ = NULL; | 340 pbuffer_ = NULL; |
| 342 } | 341 } |
| 343 } | 342 } |
| 344 | 343 |
| 345 bool PbufferGLSurfaceWGL::IsOffscreen() { | 344 bool PbufferGLSurfaceWGL::IsOffscreen() { |
| 346 return true; | 345 return true; |
| 347 } | 346 } |
| 348 | 347 |
| 349 gfx::SwapResult PbufferGLSurfaceWGL::SwapBuffers() { | 348 bool PbufferGLSurfaceWGL::SwapBuffers() { |
| 350 NOTREACHED() << "Attempted to call SwapBuffers on a pbuffer."; | 349 NOTREACHED() << "Attempted to call SwapBuffers on a pbuffer."; |
| 351 return gfx::SwapResult::SWAP_FAILED; | 350 return false; |
| 352 } | 351 } |
| 353 | 352 |
| 354 gfx::Size PbufferGLSurfaceWGL::GetSize() { | 353 gfx::Size PbufferGLSurfaceWGL::GetSize() { |
| 355 return size_; | 354 return size_; |
| 356 } | 355 } |
| 357 | 356 |
| 358 void* PbufferGLSurfaceWGL::GetHandle() { | 357 void* PbufferGLSurfaceWGL::GetHandle() { |
| 359 return device_context_; | 358 return device_context_; |
| 360 } | 359 } |
| 361 | 360 |
| 362 } // namespace gfx | 361 } // namespace gfx |
| OLD | NEW |