OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gl/SkGLContextHelper.h" | 8 #include "gl/SkGLContextHelper.h" |
9 #include "GrGLUtil.h" | 9 #include "GrGLUtil.h" |
10 | 10 |
11 SkGLContextHelper::SkGLContextHelper() | 11 SkGLContextHelper::SkGLContextHelper() |
12 : fFBO(0) | 12 : fFBO(0) |
13 , fColorBufferID(0) | 13 , fColorBufferID(0) |
14 , fDepthStencilBufferID(0) | 14 , fDepthStencilBufferID(0) |
15 , fGL(NULL) { | 15 , fGL(NULL) { |
16 } | 16 } |
17 | 17 |
18 SkGLContextHelper::~SkGLContextHelper() { | 18 SkGLContextHelper::~SkGLContextHelper() { |
19 | 19 |
20 if (fGL) { | 20 if (fGL) { |
21 // TODO: determine why DeleteFramebuffers is generating a GL error in te
sts | 21 // TODO: determine why DeleteFramebuffers is generating a GL error in te
sts |
22 SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO)); | 22 SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO)); |
23 SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID)); | 23 SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID)); |
24 SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID)); | 24 SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID)); |
25 } | 25 } |
26 | 26 |
27 SkSafeUnref(fGL); | 27 SkSafeUnref(fGL); |
28 } | 28 } |
29 | 29 |
30 bool SkGLContextHelper::init(GrGLStandard forcedGpuAPI, int width, | 30 bool SkGLContextHelper::init(int width, int height) { |
31 int height) { | |
32 if (fGL) { | 31 if (fGL) { |
33 fGL->unref(); | 32 fGL->unref(); |
34 this->destroyGLContext(); | 33 this->destroyGLContext(); |
35 } | 34 } |
36 | 35 |
37 fGL = this->createGLContext(forcedGpuAPI); | 36 fGL = this->createGLContext(); |
38 if (fGL) { | 37 if (fGL) { |
39 const GrGLubyte* temp; | 38 const GrGLubyte* temp; |
40 | 39 |
41 if (!fGL->validate()) { | 40 if (!fGL->validate()) { |
42 fGL = NULL; | 41 fGL = NULL; |
43 this->destroyGLContext(); | 42 this->destroyGLContext(); |
44 return false; | 43 return false; |
45 } | 44 } |
46 | 45 |
47 SK_GL_RET(*this, temp, GetString(GR_GL_VERSION)); | 46 SK_GL_RET(*this, temp, GetString(GR_GL_VERSION)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 fGL->unref(); | 126 fGL->unref(); |
128 fGL = NULL; | 127 fGL = NULL; |
129 this->destroyGLContext(); | 128 this->destroyGLContext(); |
130 return false; | 129 return false; |
131 } else { | 130 } else { |
132 return true; | 131 return true; |
133 } | 132 } |
134 } | 133 } |
135 return false; | 134 return false; |
136 } | 135 } |
OLD | NEW |