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 bool NativeViewGLSurfaceWGL::SwapBuffers() { | 253 gfx::SwapResult 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 false; | 262 return gfx::SWAP_FAILED; |
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 false; | 269 return gfx::SWAP_FAILED; |
270 } | 270 } |
271 | 271 |
272 DCHECK(device_context_); | 272 DCHECK(device_context_); |
273 return ::SwapBuffers(device_context_) == TRUE; | 273 return ::SwapBuffers(device_context_) == TRUE ? gfx::SWAP_ACK |
| 274 : gfx::SWAP_FAILED; |
274 } | 275 } |
275 | 276 |
276 gfx::Size NativeViewGLSurfaceWGL::GetSize() { | 277 gfx::Size NativeViewGLSurfaceWGL::GetSize() { |
277 RECT rect; | 278 RECT rect; |
278 BOOL result = GetClientRect(child_window_, &rect); | 279 BOOL result = GetClientRect(child_window_, &rect); |
279 DCHECK(result); | 280 DCHECK(result); |
280 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); | 281 return gfx::Size(rect.right - rect.left, rect.bottom - rect.top); |
281 } | 282 } |
282 | 283 |
283 void* NativeViewGLSurfaceWGL::GetHandle() { | 284 void* NativeViewGLSurfaceWGL::GetHandle() { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (pbuffer_) { | 339 if (pbuffer_) { |
339 wglDestroyPbufferARB(static_cast<HPBUFFERARB>(pbuffer_)); | 340 wglDestroyPbufferARB(static_cast<HPBUFFERARB>(pbuffer_)); |
340 pbuffer_ = NULL; | 341 pbuffer_ = NULL; |
341 } | 342 } |
342 } | 343 } |
343 | 344 |
344 bool PbufferGLSurfaceWGL::IsOffscreen() { | 345 bool PbufferGLSurfaceWGL::IsOffscreen() { |
345 return true; | 346 return true; |
346 } | 347 } |
347 | 348 |
348 bool PbufferGLSurfaceWGL::SwapBuffers() { | 349 gfx::SwapResult PbufferGLSurfaceWGL::SwapBuffers() { |
349 NOTREACHED() << "Attempted to call SwapBuffers on a pbuffer."; | 350 NOTREACHED() << "Attempted to call SwapBuffers on a pbuffer."; |
350 return false; | 351 return gfx::SWAP_FAILED; |
351 } | 352 } |
352 | 353 |
353 gfx::Size PbufferGLSurfaceWGL::GetSize() { | 354 gfx::Size PbufferGLSurfaceWGL::GetSize() { |
354 return size_; | 355 return size_; |
355 } | 356 } |
356 | 357 |
357 void* PbufferGLSurfaceWGL::GetHandle() { | 358 void* PbufferGLSurfaceWGL::GetHandle() { |
358 return device_context_; | 359 return device_context_; |
359 } | 360 } |
360 | 361 |
361 } // namespace gfx | 362 } // namespace gfx |
OLD | NEW |