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 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 #include "GrGLBuffer.h" | 9 #include "GrGLBuffer.h" |
10 #include "GrGLGLSL.h" | 10 #include "GrGLGLSL.h" |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 this->setScratchTextureUnit(); | 913 this->setScratchTextureUnit(); |
914 GL_CALL(BindTexture(glTex->target(), glTex->textureID())); | 914 GL_CALL(BindTexture(glTex->target(), glTex->textureID())); |
915 | 915 |
916 SkASSERT(!transferBuffer->isMapped()); | 916 SkASSERT(!transferBuffer->isMapped()); |
917 SkASSERT(!transferBuffer->isCPUBacked()); | 917 SkASSERT(!transferBuffer->isCPUBacked()); |
918 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(transferBuffer); | 918 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(transferBuffer); |
919 this->bindBuffer(kXferCpuToGpu_GrBufferType, glBuffer); | 919 this->bindBuffer(kXferCpuToGpu_GrBufferType, glBuffer); |
920 | 920 |
921 bool success = false; | 921 bool success = false; |
922 GrMipLevel mipLevel; | 922 GrMipLevel mipLevel; |
923 mipLevel.fPixels = transferBuffer; | 923 mipLevel.fPixels = (void*)offset; |
924 mipLevel.fRowBytes = rowBytes; | 924 mipLevel.fRowBytes = rowBytes; |
925 SkSTArray<1, GrMipLevel> texels; | 925 SkSTArray<1, GrMipLevel> texels; |
926 texels.push_back(mipLevel); | 926 texels.push_back(mipLevel); |
927 success = this->uploadTexData(glTex->desc(), glTex->target(), kTransfer_Uplo
adType, | 927 success = this->uploadTexData(glTex->desc(), glTex->target(), kTransfer_Uplo
adType, |
928 left, top, width, height, config, texels); | 928 left, top, width, height, config, texels); |
| 929 |
929 if (success) { | 930 if (success) { |
930 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); | 931 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); |
931 this->didWriteToSurface(surface, &rect); | 932 this->didWriteToSurface(surface, &rect); |
932 return true; | 933 return true; |
933 } | 934 } |
934 | 935 |
935 return false; | 936 return false; |
936 } | 937 } |
937 | 938 |
938 // For GL_[UN]PACK_ALIGNMENT. | 939 // For GL_[UN]PACK_ALIGNMENT. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 GrGLenum target, | 1190 GrGLenum target, |
1190 UploadType uploadType, | 1191 UploadType uploadType, |
1191 int left, int top, int width, int height, | 1192 int left, int top, int width, int height, |
1192 GrPixelConfig dataConfig, | 1193 GrPixelConfig dataConfig, |
1193 const SkTArray<GrMipLevel>& texels) { | 1194 const SkTArray<GrMipLevel>& texels) { |
1194 // If we're uploading compressed data then we should be using uploadCompress
edTexData | 1195 // If we're uploading compressed data then we should be using uploadCompress
edTexData |
1195 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); | 1196 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); |
1196 | 1197 |
1197 SkASSERT(this->caps()->isConfigTexturable(desc.fConfig)); | 1198 SkASSERT(this->caps()->isConfigTexturable(desc.fConfig)); |
1198 | 1199 |
| 1200 // unbind any previous transfer buffer if not transferring |
| 1201 auto& xferBufferState = fHWBufferState[kXferCpuToGpu_GrBufferType]; |
| 1202 if (kTransfer_UploadType != uploadType && |
| 1203 SK_InvalidUniqueID != xferBufferState.fBoundBufferUniqueID) { |
| 1204 GL_CALL(BindBuffer(xferBufferState.fGLTarget, 0)); |
| 1205 xferBufferState.invalidate(); |
| 1206 } |
| 1207 |
1199 // texels is const. | 1208 // texels is const. |
1200 // But we may need to flip the texture vertically to prepare it. | 1209 // But we may need to flip the texture vertically to prepare it. |
1201 // Rather than flip in place and alter the incoming data, | 1210 // Rather than flip in place and alter the incoming data, |
1202 // we allocate a new buffer to flip into. | 1211 // we allocate a new buffer to flip into. |
1203 // This means we need to make a non-const shallow copy of texels. | 1212 // This means we need to make a non-const shallow copy of texels. |
1204 SkTArray<GrMipLevel> texelsShallowCopy(texels); | 1213 SkTArray<GrMipLevel> texelsShallowCopy(texels); |
1205 | 1214 |
1206 for (int currentMipLevel = texelsShallowCopy.count() - 1; currentMipLevel >=
0; | 1215 for (int currentMipLevel = texelsShallowCopy.count() - 1; currentMipLevel >=
0; |
1207 currentMipLevel--) { | 1216 currentMipLevel--) { |
1208 SkASSERT(texelsShallowCopy[currentMipLevel].fPixels || kTransfer_UploadT
ype == uploadType); | 1217 SkASSERT(texelsShallowCopy[currentMipLevel].fPixels || kTransfer_UploadT
ype == uploadType); |
(...skipping 3070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4279 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4288 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
4280 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4289 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
4281 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4290 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
4282 copyParams->fWidth = texture->width(); | 4291 copyParams->fWidth = texture->width(); |
4283 copyParams->fHeight = texture->height(); | 4292 copyParams->fHeight = texture->height(); |
4284 return true; | 4293 return true; |
4285 } | 4294 } |
4286 } | 4295 } |
4287 return false; | 4296 return false; |
4288 } | 4297 } |
OLD | NEW |