diff options
-rw-r--r-- | include/gpu/GrTexture.h | 13 | ||||
-rw-r--r-- | include/gpu/gl/GrGLFunctions.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/GrGLInterface.h | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCreateNullInterface.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLInterface.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 32 | ||||
-rw-r--r-- | src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp | 1 |
14 files changed, 59 insertions, 5 deletions
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index a87081820f..acb7ade0a8 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -43,6 +43,14 @@ public: bool isSetFlag(GrTextureFlags flags) const { return 0 != (fDesc.fFlags & flags); } + + void dirtyMipMaps(bool mipMapsDirty) { + fMipMapsDirty = mipMapsDirty; + } + + bool mipMapsAreDirty() const { + return fMipMapsDirty; + } /** * Approximate number of bytes used by the texture @@ -136,7 +144,8 @@ protected: GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) : INHERITED(gpu, isWrapped, desc) - , fRenderTarget(NULL) { + , fRenderTarget(NULL) + , fMipMapsDirty(true) { // only make sense if alloc size is pow2 fShiftFixedX = 31 - SkCLZ(fDesc.fWidth); @@ -155,6 +164,8 @@ private: // for this texture if the texture is power of two sized. int fShiftFixedX; int fShiftFixedY; + + bool fMipMapsDirty; virtual void internal_dispose() const SK_OVERRIDE; diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h index c29c14f161..b30ef3ad4d 100644 --- a/include/gpu/gl/GrGLFunctions.h +++ b/include/gpu/gl/GrGLFunctions.h @@ -94,6 +94,7 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLFrontFaceProc)(GrGLenum mode); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers); + typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenerateMipmapProc)(GrGLenum target); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures); diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index 6cc8e17f41..6a51adceea 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -189,6 +189,7 @@ public: GLPtr<GrGLFrontFaceProc> fFrontFace; GLPtr<GrGLGenBuffersProc> fGenBuffers; GLPtr<GrGLGenFramebuffersProc> fGenFramebuffers; + GLPtr<GrGLGenerateMipmapProc> fGenerateMipmap; GLPtr<GrGLGenQueriesProc> fGenQueries; GLPtr<GrGLGenRenderbuffersProc> fGenRenderbuffers; GLPtr<GrGLGenTexturesProc> fGenTextures; diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index aa9b93c813..0d539c9593 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -109,6 +109,8 @@ GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenBuffers(GrGLsizei n, GrGLuint* ids) { } } +GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenerateMipmap(GrGLenum target) {} + GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, @@ -306,6 +308,7 @@ const GrGLInterface* GrGLCreateNullInterface() { interface->fFlush = noOpGLFlush; interface->fFrontFace = noOpGLFrontFace; interface->fGenBuffers = nullGLGenBuffers; + interface->fGenerateMipmap = nullGLGenerateMipmap; interface->fGenQueries = noOpGLGenIds; interface->fGenTextures = noOpGLGenIds; interface->fGenVertexArrays = noOpGLGenIds; diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index f5cef11b81..72d7934cbd 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -78,6 +78,9 @@ bool GrGLInterface::validate(GrGLBinding binding) const { NULL == fGenBuffers || NULL == fGenTextures || NULL == fGetBufferParameteriv || +#ifndef SKIA_IGNORE_GPU_MIPMAPS + NULL == fGenerateMipmap || +#endif NULL == fGetError || NULL == fGetIntegerv || NULL == fGetProgramInfoLog || diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 5b9609bc88..149025aa0d 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -526,9 +526,14 @@ bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, desc.fTextureID = glTex->textureID(); desc.fOrigin = glTex->origin(); - return this->uploadTexData(desc, false, - left, top, width, height, - config, buffer, rowBytes); + if (this->uploadTexData(desc, false, + left, top, width, height, + config, buffer, rowBytes)) { + texture->dirtyMipMaps(true); + return true; + } else { + return false; + } } namespace { @@ -1547,6 +1552,11 @@ void GrGpuGL::flushRenderTarget(const SkIRect* bound) { if (NULL == bound || !bound->isEmpty()) { rt->flagAsNeedingResolve(bound); } + + GrTexture *texture = rt->asTexture(); + if (texture) { + texture->dirtyMipMaps(true); + } } GrGLenum gPrimitiveType2GLMode[] = { @@ -2006,7 +2016,21 @@ void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur bool setAll = timestamp < this->getResetTimestamp(); GrGLTexture::TexParams newTexParams; - newTexParams.fFilter = (params.filterMode() == GrTextureParams::kNone_FilterMode) ? GR_GL_NEAREST : GR_GL_LINEAR; + static GrGLenum glFilterModes[] = { + GR_GL_NEAREST, + GR_GL_LINEAR, + GR_GL_LINEAR_MIPMAP_LINEAR + }; + newTexParams.fFilter = glFilterModes[params.filterMode()]; + +#ifndef SKIA_IGNORE_GPU_MIPMAPS + if (params.filterMode() == GrTextureParams::kMipMap_FilterMode && + texture->mipMapsAreDirty()) { +// GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST)); + GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D)); + texture->dirtyMipMaps(false); + } +#endif newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX()); newTexParams.fWrapT = tile_to_gl_wrap(params.getTileModeY()); diff --git a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp index 77248a0661..cfd181a6ef 100644 --- a/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp +++ b/src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp @@ -62,6 +62,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fFlush = glFlush; interface->fFrontFace = glFrontFace; interface->fGenBuffers = glGenBuffers; + interface->fGenerateMipmap = glGenerateMipmap; interface->fGenTextures = glGenTextures; interface->fGenVertexArrays = glGenVertexArraysOES; interface->fGetBufferParameteriv = glGetBufferParameteriv; diff --git a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp index 1b9f5c201c..d74e395fd6 100644 --- a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp +++ b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp @@ -77,6 +77,7 @@ const GrGLInterface* GrGLCreateANGLEInterface() { GET_PROC(Flush); GET_PROC(FrontFace); GET_PROC(GenBuffers); + GET_PROC(GenerateMipmap); GET_PROC(GenTextures); interface->fGenVertexArrays = (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index 0666fddc49..d517aa86c0 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -523,6 +523,9 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) { debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids); } +GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenerateMipmap(GrGLenum level) { +} + GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n, GrGLuint* ids) { debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids); @@ -824,6 +827,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fFinish = noOpGLFinish; interface->fFlush = noOpGLFlush; interface->fFrontFace = noOpGLFrontFace; + interface->fGenerateMipmap = debugGLGenerateMipmap; interface->fGenBuffers = debugGLGenBuffers; interface->fGenQueries = noOpGLGenIds; interface->fGenTextures = debugGLGenTextures; diff --git a/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp b/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp index e83ccddeaf..62a39e383a 100644 --- a/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp +++ b/src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp @@ -54,6 +54,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fFlush = glFlush; interface->fFrontFace = glFrontFace; interface->fGenBuffers = glGenBuffers; + interface->fGenerateMipmap = glGenerateMipmap; interface->fGetBufferParameteriv = glGetBufferParameteriv; interface->fGetError = glGetError; interface->fGetIntegerv = glGetIntegerv; diff --git a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp index 1455d1fcfb..eb0e87e180 100644 --- a/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp +++ b/src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp @@ -110,6 +110,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { GET_PROC(Flush); GET_PROC(FrontFace); GET_PROC(GenBuffers); + GET_PROC(GenerateMipmap); GET_PROC(GenQueries); GET_PROC(GetBufferParameteriv); GET_PROC(GetError); diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp index 55f4409621..1ffcbcdecd 100644 --- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp +++ b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp @@ -89,6 +89,7 @@ const GrGLInterface* GrGLCreateMesaInterface() { GR_GL_GET_PROC(Flush); GR_GL_GET_PROC(FrontFace); GR_GL_GET_PROC(GenBuffers); + GR_GL_GET_PROC(GenerateMipmap); GR_GL_GET_PROC(GenQueries); GR_GL_GET_PROC(GetBufferParameteriv); GR_GL_GET_PROC(GetError); diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp index 00bff3f870..3d35006481 100644 --- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp +++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp @@ -89,6 +89,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fFlush = glFlush; interface->fFrontFace = glFrontFace; GR_GL_GET_PROC(GenBuffers); + GR_GL_GET_PROC(GenerateMipmap); GR_GL_GET_PROC(GetBufferParameteriv); interface->fGetError = glGetError; interface->fGetIntegerv = glGetIntegerv; diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp index 28ef2effc2..53b1eddd02 100644 --- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp +++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp @@ -152,6 +152,7 @@ const GrGLInterface* GrGLCreateNativeInterface() { WGL_SET_PROC(EnableVertexAttribArray); WGL_SET_PROC(EndQuery); WGL_SET_PROC(GenBuffers); + WGL_SET_PROC(GenerateMipmap); WGL_SET_PROC(GenQueries); WGL_SET_PROC(GetBufferParameteriv); WGL_SET_PROC(GetQueryiv); |