gfx/skia/trunk/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm

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.

     2 /*
     3  * Copyright 2012 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
     9 #include "gl/SkNativeGLContext.h"
    10 #import <OpenGLES/EAGL.h>
    12 #define EAGLCTX ((EAGLContext*)(fEAGLContext))
    14 SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
    15     fEAGLContext = [EAGLContext currentContext];
    16     if (EAGLCTX) {
    17         [EAGLCTX retain];
    18     }
    19 }
    21 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
    22     if (EAGLCTX) {
    23         [EAGLContext setCurrentContext:EAGLCTX];
    24         [EAGLCTX release];
    25     }
    26 }
    28 ///////////////////////////////////////////////////////////////////////////////
    30 SkNativeGLContext::SkNativeGLContext()
    31     : fEAGLContext(NULL) {
    32 }
    34 SkNativeGLContext::~SkNativeGLContext() {
    35     this->destroyGLContext();
    36 }
    38 void SkNativeGLContext::destroyGLContext() {
    39     if ([EAGLContext currentContext] == EAGLCTX) {
    40         [EAGLContext setCurrentContext:nil];
    41     }
    42     [EAGLCTX release];
    43 }
    45 const GrGLInterface* SkNativeGLContext::createGLContext() {
    46     fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    47     [EAGLContext setCurrentContext:EAGLCTX];
    49     const GrGLInterface* interface = GrGLCreateNativeInterface();
    50     if (!interface) {
    51         SkDebugf("Failed to create gl interface");
    52         this->destroyGLContext();
    53         return NULL;
    54     }
    55     return interface;
    56 }
    58 void SkNativeGLContext::makeCurrent() const {
    59     if (![EAGLContext setCurrentContext:EAGLCTX]) {
    60         SkDebugf("Could not set the context.\n");
    61     }
    62 }
    64 void SkNativeGLContext::swapBuffers() const { }

mercurial