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