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 "GrGLNameAllocator.h" | 10 #include "GrGLNameAllocator.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 delete fProgramCache; | 163 delete fProgramCache; |
164 | 164 |
165 // This must be called by before the GrDrawTarget destructor | 165 // This must be called by before the GrDrawTarget destructor |
166 this->releaseGeometry(); | 166 this->releaseGeometry(); |
167 // This subclass must do this before the base class destructor runs | 167 // This subclass must do this before the base class destructor runs |
168 // since we will unref the GrGLInterface. | 168 // since we will unref the GrGLInterface. |
169 this->releaseResources(); | 169 this->releaseResources(); |
170 } | 170 } |
171 | 171 |
172 /////////////////////////////////////////////////////////////////////////////// | 172 /////////////////////////////////////////////////////////////////////////////// |
173 | |
174 | |
175 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, | 173 GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig, |
176 GrPixelConfig surfaceConfig) co
nst { | 174 GrPixelConfig surfaceConfig) co
nst { |
177 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { | 175 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig
) { |
178 return kBGRA_8888_GrPixelConfig; | 176 return kBGRA_8888_GrPixelConfig; |
179 } else if (this->glContext().isMesa() && | 177 } else if (this->glContext().isMesa() && |
180 GrBytesPerPixel(readConfig) == 4 && | 178 GrBytesPerPixel(readConfig) == 4 && |
181 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { | 179 GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { |
182 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. | 180 // Mesa 3D takes a slow path on when reading back BGRA from an RGBA sur
face and vice-versa. |
183 // Perhaps this should be guarded by some compiletime or runtime check. | 181 // Perhaps this should be guarded by some compiletime or runtime check. |
184 return surfaceConfig; | 182 return surfaceConfig; |
185 } else if (readConfig == kBGRA_8888_GrPixelConfig && | 183 } else if (readConfig == kBGRA_8888_GrPixelConfig |
186 !this->glCaps().readPixelsSupported(this->glInterface(), | 184 && this->glCaps().readPixelsSupported( |
187 GR_GL_BGRA, GR_GL_UNSIGNED_BY
TE)) { | 185 this->glInterface(), |
| 186 GR_GL_BGRA, |
| 187 GR_GL_UNSIGNED_BYTE, |
| 188 surfaceConfig |
| 189 )) { |
188 return kRGBA_8888_GrPixelConfig; | 190 return kRGBA_8888_GrPixelConfig; |
189 } else { | 191 } else { |
190 return readConfig; | 192 return readConfig; |
191 } | 193 } |
192 } | 194 } |
193 | 195 |
194 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, | 196 GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
195 GrPixelConfig surfaceConfig) c
onst { | 197 GrPixelConfig surfaceConfig) c
onst { |
196 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { | 198 if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfi
g) { |
197 return kBGRA_8888_GrPixelConfig; | 199 return kBGRA_8888_GrPixelConfig; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 SkASSERT(this->glCaps().unpackRowLengthSupport()); | 708 SkASSERT(this->glCaps().unpackRowLengthSupport()); |
707 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); | 709 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); |
708 } | 710 } |
709 if (glFlipY) { | 711 if (glFlipY) { |
710 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); | 712 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); |
711 } | 713 } |
712 return succeeded; | 714 return succeeded; |
713 } | 715 } |
714 | 716 |
715 // TODO: This function is using a lot of wonky semantics like, if width == -1 | 717 // TODO: This function is using a lot of wonky semantics like, if width == -1 |
716 // then set width = desc.fWdith ... blah. A better way to do it might be to | 718 // then set width = desc.fWdith ... blah. A better way to do it might be to |
717 // create a CompressedTexData struct that takes a desc/ptr and figures out | 719 // create a CompressedTexData struct that takes a desc/ptr and figures out |
718 // the proper upload semantics. Then users can construct this function how they | 720 // the proper upload semantics. Then users can construct this function how they |
719 // see fit if they want to go against the "standard" way to do it. | 721 // see fit if they want to go against the "standard" way to do it. |
720 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, | 722 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, |
721 const void* data, | 723 const void* data, |
722 bool isNewTexture, | 724 bool isNewTexture, |
723 int left, int top, int width, int height)
{ | 725 int left, int top, int width, int height)
{ |
724 SkASSERT(NULL != data || isNewTexture); | 726 SkASSERT(NULL != data || isNewTexture); |
725 | 727 |
726 // No support for software flip y, yet... | 728 // No support for software flip y, yet... |
(...skipping 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 this->setVertexArrayID(gpu, 0); | 3020 this->setVertexArrayID(gpu, 0); |
3019 } | 3021 } |
3020 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3022 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3021 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3023 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3022 fDefaultVertexArrayAttribState.resize(attrCount); | 3024 fDefaultVertexArrayAttribState.resize(attrCount); |
3023 } | 3025 } |
3024 attribState = &fDefaultVertexArrayAttribState; | 3026 attribState = &fDefaultVertexArrayAttribState; |
3025 } | 3027 } |
3026 return attribState; | 3028 return attribState; |
3027 } | 3029 } |
OLD | NEW |