OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void GrGpuGL::contextAbandoned() { | 171 void GrGpuGL::contextAbandoned() { |
172 INHERITED::contextAbandoned(); | 172 INHERITED::contextAbandoned(); |
173 fProgramCache->abandon(); | 173 fProgramCache->abandon(); |
174 fHWProgramID = 0; | 174 fHWProgramID = 0; |
175 if (this->glCaps().pathRenderingSupport()) { | 175 if (this->glCaps().pathRenderingSupport()) { |
176 this->glPathRendering()->abandonGpuResources(); | 176 this->glPathRendering()->abandonGpuResources(); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 /////////////////////////////////////////////////////////////////////////////// | 180 /////////////////////////////////////////////////////////////////////////////// |
181 | |
182 | |
183 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, | 181 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, |
184 GrPixelConfig surfaceConfig) co
nst { | 182 GrPixelConfig surfaceConfig) co
nst { |
185 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { | 183 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { |
186 return kBGRA_8888_GrPixelConfig; | 184 return kBGRA_8888_GrPixelConfig; |
187 } else if (this->glContext().isMesa() && | 185 } else if (this->glContext().isMesa() && |
188 GrBytesPerPixel(readConfig) == 4 && | 186 GrBytesPerPixel(readConfig) == 4 && |
189 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { | 187 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { |
190 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. | 188 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. |
191 // Perhaps this should be guarded by some compiletime or runtime check. | 189 // Perhaps this should be guarded by some compiletime or runtime check. |
192 return surfaceConfig; | 190 return surfaceConfig; |
193 } else if (readConfig == kBGRA_8888_GrPixelConfig && | 191 } else if (readConfig == kBGRA_8888_GrPixelConfig |
194 !this->glCaps().readPixelsSupported(this->glInterface(), | 192 && !this->glCaps().readPixelsSupported( |
195 GR_GL_BGRA, GR_GL_UNSIGNED_BY
TE)) { | 193 this->glInterface(), |
| 194 GR_GL_BGRA, |
| 195 GR_GL_UNSIGNED_BYTE, |
| 196 surfaceConfig |
| 197 )) { |
196 return kRGBA_8888_GrPixelConfig; | 198 return kRGBA_8888_GrPixelConfig; |
197 } else { | 199 } else { |
198 return readConfig; | 200 return readConfig; |
199 } | 201 } |
200 } | 202 } |
201 | 203 |
202 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, | 204 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
203 GrPixelConfig surfaceConfig) c
onst { | 205 GrPixelConfig surfaceConfig) c
onst { |
204 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { | 206 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { |
205 return kBGRA_8888_GrPixelConfig; | 207 return kBGRA_8888_GrPixelConfig; |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 SkASSERT(this->glCaps().unpackRowLengthSupport()); | 702 SkASSERT(this->glCaps().unpackRowLengthSupport()); |
701 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); | 703 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); |
702 } | 704 } |
703 if (glFlipY) { | 705 if (glFlipY) { |
704 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); | 706 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); |
705 } | 707 } |
706 return succeeded; | 708 return succeeded; |
707 } | 709 } |
708 | 710 |
709 // TODO: This function is using a lot of wonky semantics like, if width == -1 | 711 // TODO: This function is using a lot of wonky semantics like, if width == -1 |
710 // then set width = desc.fWdith ... blah. A better way to do it might be to | 712 // then set width = desc.fWdith ... blah. A better way to do it might be to |
711 // create a CompressedTexData struct that takes a desc/ptr and figures out | 713 // create a CompressedTexData struct that takes a desc/ptr and figures out |
712 // the proper upload semantics. Then users can construct this function how they | 714 // the proper upload semantics. Then users can construct this function how they |
713 // see fit if they want to go against the "standard" way to do it. | 715 // see fit if they want to go against the "standard" way to do it. |
714 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, | 716 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, |
715 const void* data, | 717 const void* data, |
716 bool isNewTexture, | 718 bool isNewTexture, |
717 int left, int top, int width, int height)
{ | 719 int left, int top, int width, int height)
{ |
718 SkASSERT(data || isNewTexture); | 720 SkASSERT(data || isNewTexture); |
719 | 721 |
720 // No support for software flip y, yet... | 722 // No support for software flip y, yet... |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 this->setVertexArrayID(gpu, 0); | 2603 this->setVertexArrayID(gpu, 0); |
2602 } | 2604 } |
2603 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2605 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2604 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2606 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2605 fDefaultVertexArrayAttribState.resize(attrCount); | 2607 fDefaultVertexArrayAttribState.resize(attrCount); |
2606 } | 2608 } |
2607 attribState = &fDefaultVertexArrayAttribState; | 2609 attribState = &fDefaultVertexArrayAttribState; |
2608 } | 2610 } |
2609 return attribState; | 2611 return attribState; |
2610 } | 2612 } |
OLD | NEW |