Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: ui/gl/gl_surface_wgl.cc

Issue 2012803003: Fix --use-gl=desktop for Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_surface_wgl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 if (!SetPixelFormat(device_context_, 234 if (!SetPixelFormat(device_context_,
235 g_display->pixel_format(), 235 g_display->pixel_format(),
236 &kPixelFormatDescriptor)) { 236 &kPixelFormatDescriptor)) {
237 LOG(ERROR) << "Unable to set the pixel format for GL context."; 237 LOG(ERROR) << "Unable to set the pixel format for GL context.";
238 Destroy(); 238 Destroy();
239 return false; 239 return false;
240 } 240 }
241 241
242 format_ = format;
243
242 return true; 244 return true;
243 } 245 }
244 246
245 void NativeViewGLSurfaceWGL::Destroy() { 247 void NativeViewGLSurfaceWGL::Destroy() {
246 if (child_window_ && device_context_) 248 if (child_window_ && device_context_)
247 ReleaseDC(child_window_, device_context_); 249 ReleaseDC(child_window_, device_context_);
248 250
249 if (child_window_) 251 if (child_window_)
250 DestroyWindow(child_window_); 252 DestroyWindow(child_window_);
251 253
252 child_window_ = NULL; 254 child_window_ = NULL;
253 device_context_ = NULL; 255 device_context_ = NULL;
254 } 256 }
255 257
258 bool NativeViewGLSurfaceWGL::Resize(const gfx::Size& size,
259 float scale_factor,
260 bool has_alpha) {
261 RECT rect;
262 if (!GetClientRect(window_, &rect)) {
263 LOG(ERROR) << "Failed to get parent window size.";
264 return false;
265 }
266 DCHECK(size.width() == (rect.right - rect.left) &&
267 size.height() == (rect.bottom - rect.top));
268 if (!MoveWindow(child_window_, 0, 0, size.width(), size.height(), FALSE)) {
269 LOG(ERROR) << "Failed to resize child window.";
270 return false;
271 }
272 return true;
273 }
274
275 bool NativeViewGLSurfaceWGL::Recreate() {
276 Destroy();
277 if (!Initialize(format_)) {
278 LOG(ERROR) << "Failed to create surface.";
279 return false;
280 }
281 return true;
282 }
283
256 bool NativeViewGLSurfaceWGL::IsOffscreen() { 284 bool NativeViewGLSurfaceWGL::IsOffscreen() {
257 return false; 285 return false;
258 } 286 }
259 287
260 gfx::SwapResult NativeViewGLSurfaceWGL::SwapBuffers() { 288 gfx::SwapResult NativeViewGLSurfaceWGL::SwapBuffers() {
261 TRACE_EVENT2("gpu", "NativeViewGLSurfaceWGL:RealSwapBuffers", 289 TRACE_EVENT2("gpu", "NativeViewGLSurfaceWGL:RealSwapBuffers",
262 "width", GetSize().width(), 290 "width", GetSize().width(),
263 "height", GetSize().height()); 291 "height", GetSize().height());
264 292
265 // Resize the child window to match the parent before swapping. Do not repaint 293 // Resize the child window to match the parent before swapping. Do not repaint
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 388
361 gfx::Size PbufferGLSurfaceWGL::GetSize() { 389 gfx::Size PbufferGLSurfaceWGL::GetSize() {
362 return size_; 390 return size_;
363 } 391 }
364 392
365 void* PbufferGLSurfaceWGL::GetHandle() { 393 void* PbufferGLSurfaceWGL::GetHandle() {
366 return device_context_; 394 return device_context_;
367 } 395 }
368 396
369 } // namespace gfx 397 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_wgl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698