• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "RendererContext.h"
17 #include <stdio.h>
18 #include <stdlib.h>
19 
create(EGLDisplay dpy,EGLConfig config,RendererContext * shareCtx,int version)20 RendererContext * RendererContext::create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx, int version)
21 {
22     EGLContext ctx;
23     EGLContext shared = shareCtx == NULL ? EGL_NO_CONTEXT : shareCtx->eglContext();
24 
25     EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
26     context_attributes[1] = version;
27 
28     ctx = eglCreateContext(dpy, config, shared, context_attributes);
29     if (eglGetError() != EGL_SUCCESS) return NULL;
30 
31     return new RendererContext(dpy, ctx, version);
32 }
33 
destroy()34 int RendererContext::destroy()
35 {
36     if (count() <= 0) {
37         eglDestroyContext(m_dpy, m_ctx);
38         return 1;
39     }
40     return 0;
41 }
42 
43 #ifdef PVR_WAR
setActiveTexture(GLenum texture)44 void RendererContext::setActiveTexture(GLenum texture)
45 {
46     m_activeTexture = texture - GL_TEXTURE0;
47 }
48 
setTex2DBind(GLuint texture)49 void RendererContext::setTex2DBind(GLuint texture)
50 {
51     m_tex2DBind[m_activeTexture] = texture;
52 }
53 
getTex2DBind()54 GLuint RendererContext::getTex2DBind()
55 {
56     return m_tex2DBind[m_activeTexture];
57 }
58 
addPendingCropRect(const int * rect)59 void RendererContext::addPendingCropRect(const int *rect)
60 {
61     PendingCropRect *r = new PendingCropRect;
62     r->texture = m_tex2DBind[m_activeTexture];
63     memcpy(r->rect, rect, 4*sizeof(int));
64     m_pendingCropRects.insert(r);
65 }
66 #endif
67