gfx/gl/ForceDiscreteGPUHelperCGL.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef ForceDiscreteGPUHelperCGL_h_
     7 #define ForceDiscreteGPUHelperCGL_h_
     9 #include <OpenGL/OpenGL.h>
    11 /** This RAII helper guarantees that we're on the discrete GPU during its lifetime.
    12  * 
    13  * As long as any ForceDiscreteGPUHelperCGL object is alive, we're on the discrete GPU.
    14  */
    15 class ForceDiscreteGPUHelperCGL
    16 {
    17     CGLPixelFormatObj mPixelFormatObj;
    19 public:
    20     ForceDiscreteGPUHelperCGL()
    21     {
    22         // the code in this function is taken from Chromium, src/ui/gfx/gl/gl_context_cgl.cc, r122013
    23         // BSD-style license, (c) The Chromium Authors
    24         CGLPixelFormatAttribute attribs[1];
    25         attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
    26         GLint num_pixel_formats = 0;
    27         CGLChoosePixelFormat(attribs, &mPixelFormatObj, &num_pixel_formats);
    28     }
    30     ~ForceDiscreteGPUHelperCGL()
    31     {
    32         CGLReleasePixelFormat(mPixelFormatObj);
    33     }
    34 };
    36 #endif // ForceDiscreteGPUHelperCGL_h_

mercurial