Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 303273008: Revert of Initial work to get ETC1 data up to the GPU (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 694
695 if (restoreGLRowLength) { 695 if (restoreGLRowLength) {
696 SkASSERT(this->glCaps().unpackRowLengthSupport()); 696 SkASSERT(this->glCaps().unpackRowLengthSupport());
697 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0)); 697 GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
698 } 698 }
699 if (glFlipY) { 699 if (glFlipY) {
700 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE)); 700 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
701 } 701 }
702 return succeeded; 702 return succeeded;
703 } 703 }
704
705 bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc,
706 const void* data) {
707 SkASSERT(NULL != data);
708
709 // No support for software flip y, yet...
710 SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin);
711
712 // Make sure that the width and height that we pass to OpenGL
713 // is a multiple of the block size.
714 int dataSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fH eight);
715
716 // We only need the internal format for compressed 2D textures.
717 GrGLenum internalFormat = 0;
718 if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, NULL, NUL L)) {
719 return false;
720 }
721
722 bool succeeded = true;
723 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
724 GL_ALLOC_CALL(this->glInterface(),
725 CompressedTexImage2D(GR_GL_TEXTURE_2D,
726 0, // level
727 internalFormat,
728 desc.fWidth, desc.fHeight,
729 0, // border
730 dataSize,
731 data));
732
733 GrGLenum error = check_alloc_error(desc, this->glInterface());
734 if (error != GR_GL_NO_ERROR) {
735 succeeded = false;
736 }
737 return succeeded;
738 }
739 704
740 static bool renderbuffer_storage_msaa(GrGLContext& ctx, 705 static bool renderbuffer_storage_msaa(GrGLContext& ctx,
741 int sampleCount, 706 int sampleCount,
742 GrGLenum format, 707 GrGLenum format,
743 int width, int height) { 708 int width, int height) {
744 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); 709 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
745 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); 710 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType());
746 switch (ctx.caps()->msFBOType()) { 711 switch (ctx.caps()->msFBOType()) {
747 case GrGLCaps::kDesktop_ARB_MSFBOType: 712 case GrGLCaps::kDesktop_ARB_MSFBOType:
748 case GrGLCaps::kDesktop_EXT_MSFBOType: 713 case GrGLCaps::kDesktop_EXT_MSFBOType:
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc)); 974 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc));
1010 } 975 }
1011 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp()); 976 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
1012 #ifdef TRACE_TEXTURE_CREATION 977 #ifdef TRACE_TEXTURE_CREATION
1013 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", 978 GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n",
1014 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); 979 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig);
1015 #endif 980 #endif
1016 return tex; 981 return tex;
1017 } 982 }
1018 983
1019 GrTexture* GrGpuGL::onCreateCompressedTexture(const GrTextureDesc& desc,
1020 const void* srcData) {
1021
1022 if(SkToBool(desc.fFlags & kRenderTarget_GrTextureFlagBit)) {
1023 return return_null_texture();
1024 }
1025
1026 // Make sure that we're not flipping Y.
1027 GrSurfaceOrigin texOrigin = resolve_origin(desc.fOrigin, false);
1028 if (kBottomLeft_GrSurfaceOrigin == texOrigin) {
1029 return return_null_texture();
1030 }
1031
1032 GrGLTexture::Desc glTexDesc;
1033
1034 glTexDesc.fFlags = desc.fFlags;
1035 glTexDesc.fWidth = desc.fWidth;
1036 glTexDesc.fHeight = desc.fHeight;
1037 glTexDesc.fConfig = desc.fConfig;
1038 glTexDesc.fIsWrapped = false;
1039 glTexDesc.fOrigin = texOrigin;
1040
1041 int maxSize = this->caps()->maxTextureSize();
1042 if (glTexDesc.fWidth > maxSize || glTexDesc.fHeight > maxSize) {
1043 return return_null_texture();
1044 }
1045
1046 GL_CALL(GenTextures(1, &glTexDesc.fTextureID));
1047
1048 if (!glTexDesc.fTextureID) {
1049 return return_null_texture();
1050 }
1051
1052 this->setScratchTextureUnit();
1053 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, glTexDesc.fTextureID));
1054
1055 // Some drivers like to know filter/wrap before seeing glTexImage2D. Some
1056 // drivers have a bug where an FBO won't be complete if it includes a
1057 // texture that is not mipmap complete (considering the filter in use).
1058 GrGLTexture::TexParams initialTexParams;
1059 // we only set a subset here so invalidate first
1060 initialTexParams.invalidate();
1061 initialTexParams.fMinFilter = GR_GL_NEAREST;
1062 initialTexParams.fMagFilter = GR_GL_NEAREST;
1063 initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE;
1064 initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE;
1065 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1066 GR_GL_TEXTURE_MAG_FILTER,
1067 initialTexParams.fMagFilter));
1068 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1069 GR_GL_TEXTURE_MIN_FILTER,
1070 initialTexParams.fMinFilter));
1071 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1072 GR_GL_TEXTURE_WRAP_S,
1073 initialTexParams.fWrapS));
1074 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1075 GR_GL_TEXTURE_WRAP_T,
1076 initialTexParams.fWrapT));
1077
1078 if (!this->uploadCompressedTexData(glTexDesc, srcData)) {
1079 GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID));
1080 return return_null_texture();
1081 }
1082
1083 GrGLTexture* tex;
1084 tex = SkNEW_ARGS(GrGLTexture, (this, glTexDesc));
1085 tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
1086 #ifdef TRACE_TEXTURE_CREATION
1087 GrPrintf("--- new compressed texture [%d] size=(%d %d) config=%d\n",
1088 glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig);
1089 #endif
1090 return tex;
1091 }
1092
1093 namespace { 984 namespace {
1094 985
1095 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; 986 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
1096 987
1097 void inline get_stencil_rb_sizes(const GrGLInterface* gl, 988 void inline get_stencil_rb_sizes(const GrGLInterface* gl,
1098 GrGLStencilBuffer::Format* format) { 989 GrGLStencilBuffer::Format* format) {
1099 990
1100 // we shouldn't ever know one size and not the other 991 // we shouldn't ever know one size and not the other
1101 SkASSERT((kUnknownBitCount == format->fStencilBits) == 992 SkASSERT((kUnknownBitCount == format->fStencilBits) ==
1102 (kUnknownBitCount == format->fTotalBits)); 993 (kUnknownBitCount == format->fTotalBits));
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 this->setVertexArrayID(gpu, 0); 2826 this->setVertexArrayID(gpu, 0);
2936 } 2827 }
2937 int attrCount = gpu->glCaps().maxVertexAttributes(); 2828 int attrCount = gpu->glCaps().maxVertexAttributes();
2938 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2829 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2939 fDefaultVertexArrayAttribState.resize(attrCount); 2830 fDefaultVertexArrayAttribState.resize(attrCount);
2940 } 2831 }
2941 attribState = &fDefaultVertexArrayAttribState; 2832 attribState = &fDefaultVertexArrayAttribState;
2942 } 2833 }
2943 return attribState; 2834 return attribState;
2944 } 2835 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698