Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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_