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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // clear any existing GL erorrs | 54 // clear any existing GL erorrs |
55 GrGLenum error; | 55 GrGLenum error; |
56 do { | 56 do { |
57 SK_GL_RET(*this, error, GetError()); | 57 SK_GL_RET(*this, error, GetError()); |
58 } while (GR_GL_NO_ERROR != error); | 58 } while (GR_GL_NO_ERROR != error); |
59 | 59 |
60 SK_GL(*this, GenFramebuffers(1, &fFBO)); | 60 SK_GL(*this, GenFramebuffers(1, &fFBO)); |
61 SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO)); | 61 SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO)); |
62 SK_GL(*this, GenRenderbuffers(1, &fColorBufferID)); | 62 SK_GL(*this, GenRenderbuffers(1, &fColorBufferID)); |
63 SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID)); | 63 SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID)); |
64 if (kES2_GrGLBinding == bindingInUse) { | 64 if (kES_GrGLBinding == bindingInUse) { |
65 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, | 65 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
66 GR_GL_RGBA8, | 66 GR_GL_RGBA8, |
67 width, height)); | 67 width, height)); |
68 } else { | 68 } else { |
69 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, | 69 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
70 GR_GL_RGBA, | 70 GR_GL_RGBA, |
71 width, height)); | 71 width, height)); |
72 } | 72 } |
73 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 73 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
74 GR_GL_COLOR_ATTACHMENT0, | 74 GR_GL_COLOR_ATTACHMENT0, |
75 GR_GL_RENDERBUFFER, | 75 GR_GL_RENDERBUFFER, |
76 fColorBufferID)); | 76 fColorBufferID)); |
77 SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID)); | 77 SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID)); |
78 SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID)
); | 78 SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID)
); |
79 | 79 |
80 // Some drivers that support packed depth stencil will only succeed | 80 // Some drivers that support packed depth stencil will only succeed |
81 // in binding a packed format an FBO. However, we can't rely on packed | 81 // in binding a packed format an FBO. However, we can't rely on packed |
82 // depth stencil being available. | 82 // depth stencil being available. |
83 bool supportsPackedDepthStencil; | 83 bool supportsPackedDepthStencil; |
84 if (kES2_GrGLBinding == bindingInUse) { | 84 if (kES_GrGLBinding == bindingInUse) { |
85 supportsPackedDepthStencil = this->hasExtension("GL_OES_packed_depth
_stencil"); | 85 supportsPackedDepthStencil = this->hasExtension("GL_OES_packed_depth
_stencil"); |
86 } else { | 86 } else { |
87 supportsPackedDepthStencil = version >= GR_GL_VER(3,0) || | 87 supportsPackedDepthStencil = version >= GR_GL_VER(3,0) || |
88 this->hasExtension("GL_EXT_packed_depth
_stencil") || | 88 this->hasExtension("GL_EXT_packed_depth
_stencil") || |
89 this->hasExtension("GL_ARB_framebuffer_
object"); | 89 this->hasExtension("GL_ARB_framebuffer_
object"); |
90 } | 90 } |
91 | 91 |
92 if (supportsPackedDepthStencil) { | 92 if (supportsPackedDepthStencil) { |
93 // ES2 requires sized internal formats for RenderbufferStorage | 93 // ES2 requires sized internal formats for RenderbufferStorage |
94 // On Desktop we let the driver decide. | 94 // On Desktop we let the driver decide. |
95 GrGLenum format = kES2_GrGLBinding == bindingInUse ? | 95 GrGLenum format = kES_GrGLBinding == bindingInUse ? |
96 GR_GL_DEPTH24_STENCIL8 : | 96 GR_GL_DEPTH24_STENCIL8 : |
97 GR_GL_DEPTH_STENCIL; | 97 GR_GL_DEPTH_STENCIL; |
98 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, | 98 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
99 format, | 99 format, |
100 width, height)); | 100 width, height)); |
101 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 101 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
102 GR_GL_DEPTH_ATTACHMENT, | 102 GR_GL_DEPTH_ATTACHMENT, |
103 GR_GL_RENDERBUFFER, | 103 GR_GL_RENDERBUFFER, |
104 fDepthStencilBufferID)); | 104 fDepthStencilBufferID)); |
105 } else { | 105 } else { |
106 GrGLenum format = kES2_GrGLBinding == bindingInUse ? | 106 GrGLenum format = kES_GrGLBinding == bindingInUse ? |
107 GR_GL_STENCIL_INDEX8 : | 107 GR_GL_STENCIL_INDEX8 : |
108 GR_GL_STENCIL_INDEX; | 108 GR_GL_STENCIL_INDEX; |
109 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, | 109 SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
110 format, | 110 format, |
111 width, height)); | 111 width, height)); |
112 } | 112 } |
113 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 113 SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
114 GR_GL_STENCIL_ATTACHMENT, | 114 GR_GL_STENCIL_ATTACHMENT, |
115 GR_GL_RENDERBUFFER, | 115 GR_GL_RENDERBUFFER, |
116 fDepthStencilBufferID)); | 116 fDepthStencilBufferID)); |
(...skipping 13 matching lines...) Expand all Loading... |
130 fGL->unref(); | 130 fGL->unref(); |
131 fGL = NULL; | 131 fGL = NULL; |
132 this->destroyGLContext(); | 132 this->destroyGLContext(); |
133 return false; | 133 return false; |
134 } else { | 134 } else { |
135 return true; | 135 return true; |
136 } | 136 } |
137 } | 137 } |
138 return false; | 138 return false; |
139 } | 139 } |
OLD | NEW |