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

Unified Diff: ui/gfx/gl/gl_context_wgl.cc

Issue 10392068: ui: Move gl/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac_rel Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gl/gl_context_wgl.h ('k') | ui/gfx/gl/gl_context_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gl/gl_context_wgl.cc
diff --git a/ui/gfx/gl/gl_context_wgl.cc b/ui/gfx/gl/gl_context_wgl.cc
deleted file mode 100644
index d97730254d10439843262d731c0c02333384d942..0000000000000000000000000000000000000000
--- a/ui/gfx/gl/gl_context_wgl.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file implements the GLContextWGL and PbufferGLContext classes.
-
-#include "ui/gfx/gl/gl_context_wgl.h"
-
-#include "base/debug/trace_event.h"
-#include "base/logging.h"
-#include "ui/gfx/gl/gl_bindings.h"
-#include "ui/gfx/gl/gl_implementation.h"
-#include "ui/gfx/gl/gl_surface_wgl.h"
-
-namespace gfx {
-
-GLContextWGL::GLContextWGL(GLShareGroup* share_group)
- : GLContext(share_group),
- context_(NULL) {
-}
-
-GLContextWGL::~GLContextWGL() {
- Destroy();
-}
-
-std::string GLContextWGL::GetExtensions() {
- const char* extensions = NULL;
- if (wglGetExtensionsStringARB)
- extensions = wglGetExtensionsStringARB(GLSurfaceWGL::GetDisplayDC());
- else if (wglGetExtensionsStringEXT)
- extensions = wglGetExtensionsStringEXT();
-
- if (extensions)
- return GLContext::GetExtensions() + " " + extensions;
-
- return GLContext::GetExtensions();
-}
-
-bool GLContextWGL::Initialize(
- GLSurface* compatible_surface, GpuPreference gpu_preference) {
- // Get the handle of another initialized context in the share group _before_
- // setting context_. Otherwise this context will be considered initialized
- // and could potentially be returned by GetHandle.
- HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle());
-
- context_ = wglCreateContext(
- static_cast<HDC>(compatible_surface->GetHandle()));
- if (!context_) {
- LOG(ERROR) << "Failed to create GL context.";
- Destroy();
- return false;
- }
-
- if (share_handle) {
- if (!wglShareLists(share_handle, context_)) {
- LOG(ERROR) << "Could not share GL contexts.";
- Destroy();
- return false;
- }
- }
-
- return true;
-}
-
-void GLContextWGL::Destroy() {
- if (context_) {
- wglDeleteContext(context_);
- context_ = NULL;
- }
-}
-
-bool GLContextWGL::MakeCurrent(GLSurface* surface) {
- DCHECK(context_);
- if (IsCurrent(surface))
- return true;
-
- TRACE_EVENT0("gpu", "GLContextWGL::MakeCurrent");
-
- if (!wglMakeCurrent(static_cast<HDC>(surface->GetHandle()), context_)) {
- LOG(ERROR) << "Unable to make gl context current.";
- return false;
- }
-
- SetCurrent(this, surface);
- if (!InitializeExtensionBindings()) {
- ReleaseCurrent(surface);
- return false;
- }
-
- if (!surface->OnMakeCurrent(this)) {
- LOG(ERROR) << "Could not make current.";
- return false;
- }
-
- return true;
-}
-
-void GLContextWGL::ReleaseCurrent(GLSurface* surface) {
- if (!IsCurrent(surface))
- return;
-
- SetCurrent(NULL, NULL);
- wglMakeCurrent(NULL, NULL);
-}
-
-bool GLContextWGL::IsCurrent(GLSurface* surface) {
- bool native_context_is_current =
- wglGetCurrentContext() == context_;
-
- // If our context is current then our notion of which GLContext is
- // current must be correct. On the other hand, third-party code
- // using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
-
- if (!native_context_is_current)
- return false;
-
- if (surface) {
- if (wglGetCurrentDC() != surface->GetHandle())
- return false;
- }
-
- return true;
-}
-
-void* GLContextWGL::GetHandle() {
- return context_;
-}
-
-void GLContextWGL::SetSwapInterval(int interval) {
- DCHECK(IsCurrent(NULL));
- if (gfx::g_WGL_EXT_swap_control) {
- wglSwapIntervalEXT(interval);
- } else {
- LOG(WARNING) <<
- "Could not disable vsync: driver does not "
- "support WGL_EXT_swap_control";
- }
-}
-
-} // namespace gfx
« no previous file with comments | « ui/gfx/gl/gl_context_wgl.h ('k') | ui/gfx/gl/gl_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698