aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-19 16:18:01 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-19 16:18:01 +0000
commit4744231c149989666d70956527495bddb2e5dd8b (patch)
tree2d24f13e579d1a59aef332ec91be1af1da3748bf
parent8128d8c119382279918b90ad8d80ccb3aaebb8a0 (diff)
Add detection of mip support
R=robertphillips@google.com, jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/102853005 git-svn-id: http://skia.googlecode.com/svn/trunk@12771 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/gpu/GrDrawTarget.cpp3
-rw-r--r--src/gpu/GrDrawTargetCaps.h4
-rw-r--r--src/gpu/gl/GrGLCaps.cpp15
-rw-r--r--src/gpu/gl/GrGpuGL.cpp11
4 files changed, 23 insertions, 10 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 0b4d96af84..38a5a60c6c 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -962,6 +962,7 @@ void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* d
void GrDrawTargetCaps::reset() {
f8BitPaletteSupport = false;
+ fMipMapSupport = false;
fNPOTTextureTileSupport = false;
fTwoSidedStencilSupport = false;
fStencilWrapOpsSupport = false;
@@ -983,6 +984,7 @@ void GrDrawTargetCaps::reset() {
GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
f8BitPaletteSupport = other.f8BitPaletteSupport;
+ fMipMapSupport = other.fMipMapSupport;
fNPOTTextureTileSupport = other.fNPOTTextureTileSupport;
fTwoSidedStencilSupport = other.fTwoSidedStencilSupport;
fStencilWrapOpsSupport = other.fStencilWrapOpsSupport;
@@ -1008,6 +1010,7 @@ SkString GrDrawTargetCaps::dump() const {
SkString r;
static const char* gNY[] = {"NO", "YES"};
r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]);
+ r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h
index e597e099c9..b316e491c1 100644
--- a/src/gpu/GrDrawTargetCaps.h
+++ b/src/gpu/GrDrawTargetCaps.h
@@ -28,6 +28,9 @@ public:
bool eightBitPaletteSupport() const { return f8BitPaletteSupport; }
bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
+ /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
+ only for POT textures) */
+ bool mipMapSupport() const { return fMipMapSupport; }
bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; }
bool hwAALineSupport() const { return fHWAALineSupport; }
@@ -57,6 +60,7 @@ public:
protected:
bool f8BitPaletteSupport : 1;
bool fNPOTTextureTileSupport : 1;
+ bool fMipMapSupport : 1;
bool fTwoSidedStencilSupport : 1;
bool fStencilWrapOpsSupport : 1;
bool fHWAALineSupport : 1;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 8d8c02254a..8833a05aef 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -285,17 +285,20 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
}
if (kDesktop_GrGLBinding == binding) {
- if (ctxInfo.version() >= GR_GL_VER(2,0) ||
- ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")) {
- fNPOTTextureTileSupport = true;
- } else {
- fNPOTTextureTileSupport = false;
- }
+ SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) ||
+ ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two"));
+ fNPOTTextureTileSupport = true;
+ fMipMapSupport = true;
} else {
// Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
// ES3 has no limitations.
fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_OES_texture_npot");
+ // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP
+ // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently,
+ // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to
+ // to alllow arbitrary wrap modes, however.
+ fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot");
}
fHWAALineSupport = (kDesktop_GrGLBinding == binding);
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 4b5221c31b..7ab4bc1fcb 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2028,11 +2028,14 @@ void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
GR_GL_LINEAR,
GR_GL_LINEAR
};
- newTexParams.fMinFilter = glMinFilterModes[params.filterMode()];
- newTexParams.fMagFilter = glMagFilterModes[params.filterMode()];
+ GrTextureParams::FilterMode filterMode = params.filterMode();
+ if (!this->caps()->mipMapSupport() && GrTextureParams::kMipMap_FilterMode == filterMode) {
+ filterMode = GrTextureParams::kBilerp_FilterMode;
+ }
+ newTexParams.fMinFilter = glMinFilterModes[filterMode];
+ newTexParams.fMagFilter = glMagFilterModes[filterMode];
- if (params.filterMode() == GrTextureParams::kMipMap_FilterMode &&
- texture->mipMapsAreDirty()) {
+ if (GrTextureParams::kMipMap_FilterMode == filterMode && texture->mipMapsAreDirty()) {
// GL_CALL(Hint(GR_GL_GENERATE_MIPMAP_HINT,GR_GL_NICEST));
GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D));
texture->dirtyMipMaps(false);