aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-15 16:47:16 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-15 16:47:16 +0000
commit9962108c400dadcae913614e8a5ab781780981d8 (patch)
tree476244a17c316b527077384c2ae471c87d110b2b
parentcc586511839400941420160b1ef2bf19a7f7f2de (diff)
Remove allocated size vs content size in textures
Review URL: http://codereview.appspot.com/5373100/ git-svn-id: http://skia.googlecode.com/svn/trunk@2687 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/gpu/GrGLInterface.h10
-rw-r--r--include/gpu/GrRenderTarget.h20
-rw-r--r--include/gpu/GrTexture.h24
-rw-r--r--src/gpu/GrContext.cpp16
-rw-r--r--src/gpu/GrDrawTarget.cpp4
-rw-r--r--src/gpu/GrDrawTarget.h4
-rw-r--r--src/gpu/GrGLInterface.cpp3
-rw-r--r--src/gpu/GrGLRenderTarget.cpp9
-rw-r--r--src/gpu/GrGLTexture.cpp22
-rw-r--r--src/gpu/GrGLTexture.h19
-rw-r--r--src/gpu/GrGpu.cpp8
-rw-r--r--src/gpu/GrGpuGL.cpp254
-rw-r--r--src/gpu/GrGpuGL.h2
-rw-r--r--src/gpu/GrGpuGLShaders.cpp15
-rw-r--r--src/gpu/GrRenderTarget.cpp4
-rw-r--r--src/gpu/ios/GrGLDefaultInterface_iOS.cpp3
-rw-r--r--src/gpu/mesa/GrGLCreateMesaInterface.cpp3
-rw-r--r--src/gpu/unix/GrGLCreateNativeInterface_unix.cpp4
-rw-r--r--src/gpu/win/GrGLCreateNativeInterface_win.cpp4
19 files changed, 57 insertions, 371 deletions
diff --git a/include/gpu/GrGLInterface.h b/include/gpu/GrGLInterface.h
index f37f49c8e5..e0925bddb9 100644
--- a/include/gpu/GrGLInterface.h
+++ b/include/gpu/GrGLInterface.h
@@ -278,16 +278,6 @@ struct GR_API GrGLInterface : public GrRefCnt {
// exported: GLES{1|2} or Desktop.
GrGLBinding fBindingsExported;
- /// Does this GL support NPOT textures on FBOs?
- /// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
- int fNPOTRenderTargetSupport;
-
- /// Some GL implementations (PowerVR SGX devices like the iPhone 4)
- /// have restrictions on the size of small render targets.
- /// kProbe_GrGLCapability to probe (slowly) at context creation.
- int fMinRenderTargetHeight;
- int fMinRenderTargetWidth;
-
GrGLActiveTextureProc fActiveTexture;
GrGLAttachShaderProc fAttachShader;
GrGLBeginQueryProc fBeginQuery;
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index dd7a371dcb..1b11aeefac 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -44,20 +44,6 @@ public:
int height() const { return fHeight; }
/**
- * Retrieves the allocated width. It may differ from width for
- * NPOT or min-RT size reasons.
- * @return allocated width in pixels
- */
- int allocatedWidth() const { return fAllocatedWidth; }
-
- /**
- * Retrieves the allocated height. It may differ from height for
- * NPOT or min-RT size reasons.
- * @return allocated height in pixels
- */
- int allocatedHeight() const { return fAllocatedHeight; }
-
- /**
* @return the pixel config. Can be kUnknown_GrPixelConfig
* if client asked us to render to a target that has a pixel
* config that isn't equivalent with one of our configs.
@@ -165,8 +151,6 @@ protected:
GrTexture* texture,
int width,
int height,
- int allocatedWidth,
- int allocatedHeight,
GrPixelConfig config,
int sampleCnt)
: INHERITED(gpu)
@@ -174,8 +158,6 @@ protected:
, fTexture(texture)
, fWidth(width)
, fHeight(height)
- , fAllocatedWidth(allocatedWidth)
- , fAllocatedHeight(allocatedHeight)
, fConfig(config)
, fSampleCnt(sampleCnt) {
fResolveRect.setLargestInverted();
@@ -197,8 +179,6 @@ private:
GrTexture* fTexture; // not ref'ed
int fWidth;
int fHeight;
- int fAllocatedWidth;
- int fAllocatedHeight;
GrPixelConfig fConfig;
int fSampleCnt;
GrIRect fResolveRect;
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 5a86b0881b..019268827a 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -33,20 +33,6 @@ public:
int height() const { return fHeight; }
/**
- * Retrieves the allocated width. It may differ from width for
- * NPOT or min-RT size reasons.
- * @return allocated width in texels
- */
- int allocatedWidth() const { return fAllocatedWidth; }
-
- /**
- * Retrieves the allocated height. It may differ from height for
- * NPOT or min-RT size reasons.
- * @return allocated height in texels
- */
- int allocatedHeight() const { return fAllocatedHeight; }
-
- /**
* Convert from texels to normalized texture coords for POT textures
* only.
*/
@@ -64,9 +50,7 @@ public:
* Approximate number of bytes used by the texture
*/
virtual size_t sizeInBytes() const {
- return (size_t) fAllocatedWidth *
- fAllocatedHeight *
- GrBytesPerPixel(fConfig);
+ return (size_t) fWidth * fHeight * GrBytesPerPixel(fConfig);
}
/**
@@ -141,15 +125,11 @@ protected:
GrTexture(GrGpu* gpu,
int width,
int height,
- int allocatedWidth,
- int allocatedHeight,
GrPixelConfig config)
: INHERITED(gpu)
, fRenderTarget(NULL)
, fWidth(width)
, fHeight(height)
- , fAllocatedWidth(allocatedWidth)
- , fAllocatedHeight(allocatedHeight)
, fConfig(config) {
// only make sense if alloc size is pow2
fShiftFixedX = 31 - Gr_clz(fWidth);
@@ -166,8 +146,6 @@ protected:
private:
int fWidth;
int fHeight;
- int fAllocatedWidth;
- int fAllocatedHeight;
// these two shift a fixed-point value into normalized coordinates
// for this texture if the texture is power of two sized.
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index ca01192b77..47a2a6b260 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -331,12 +331,8 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(TextureKey key,
rtDesc.fFlags = rtDesc.fFlags |
kRenderTarget_GrTextureFlagBit |
kNoStencil_GrTextureFlagBit;
- rtDesc.fWidth =
- GrNextPow2(GrMax<int>(desc.fWidth,
- fGpu->getCaps().fMinRenderTargetWidth));
- rtDesc.fHeight =
- GrNextPow2(GrMax<int>(desc.fHeight,
- fGpu->getCaps().fMinRenderTargetHeight));
+ rtDesc.fWidth = GrNextPow2(GrMax(desc.fWidth, 64));
+ rtDesc.fHeight = GrNextPow2(GrMax(desc.fHeight, 64));
GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0);
@@ -576,10 +572,6 @@ bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler,
bool isPow2 = GrIsPow2(width) && GrIsPow2(height);
if (!isPow2) {
- if (!caps.fNPOTTextureSupport) {
- return false;
- }
-
bool tiled = sampler.getWrapX() != GrSamplerState::kClamp_WrapMode ||
sampler.getWrapY() != GrSamplerState::kClamp_WrapMode;
if (tiled && !caps.fNPOTTextureTileSupport) {
@@ -2005,7 +1997,7 @@ void GrContext::convolveInX(GrTexture* texture,
const SkRect& rect,
const float* kernel,
int kernelWidth) {
- float imageIncrement[2] = {1.0f / texture->allocatedWidth(), 0.0f};
+ float imageIncrement[2] = {1.0f / texture->width(), 0.0f};
convolve(texture, rect, imageIncrement, kernel, kernelWidth);
}
@@ -2013,7 +2005,7 @@ void GrContext::convolveInY(GrTexture* texture,
const SkRect& rect,
const float* kernel,
int kernelWidth) {
- float imageIncrement[2] = {0.0f, 1.0f / texture->allocatedHeight()};
+ float imageIncrement[2] = {0.0f, 1.0f / texture->height()};
convolve(texture, rect, imageIncrement, kernel, kernelWidth);
}
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 3d9195c1b7..20098fcada 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -1267,9 +1267,7 @@ void GrDrawTarget::AutoReleaseGeometry::reset() {
void GrDrawTarget::Caps::print() const {
static const char* gNY[] = {"NO", "YES"};
GrPrintf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]);
- GrPrintf("NPOT Texture Support : %s\n", gNY[fNPOTTextureSupport]);
GrPrintf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
- GrPrintf("NPOT Render Target Support : %s\n", gNY[fNPOTRenderTargetSupport]);
GrPrintf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
GrPrintf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]);
@@ -1279,8 +1277,6 @@ void GrDrawTarget::Caps::print() const {
GrPrintf("FSAA Support : %s\n", gNY[fFSAASupport]);
GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSupport]);
GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]);
- GrPrintf("Min Render Target Width : %d\n", fMinRenderTargetWidth);
- GrPrintf("Min Render Target Height : %d\n", fMinRenderTargetHeight);
GrPrintf("Max Texture Size : %d\n", fMaxTextureSize);
GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
}
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 339399ae09..22cbbdb130 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -42,9 +42,7 @@ public:
}
void print() const;
bool f8BitPaletteSupport : 1;
- bool fNPOTTextureSupport : 1;
bool fNPOTTextureTileSupport : 1;
- bool fNPOTRenderTargetSupport : 1;
bool fTwoSidedStencilSupport : 1;
bool fStencilWrapOpsSupport : 1;
bool fHWAALineSupport : 1;
@@ -55,8 +53,6 @@ public:
bool fDualSourceBlendingSupport : 1;
bool fBufferLockSupport : 1;
bool fSupportPerVertexCoverage : 1;
- int fMinRenderTargetWidth;
- int fMinRenderTargetHeight;
int fMaxRenderTargetSize;
int fMaxTextureSize;
};
diff --git a/src/gpu/GrGLInterface.cpp b/src/gpu/GrGLInterface.cpp
index f2756a6e8d..d46aaa755f 100644
--- a/src/gpu/GrGLInterface.cpp
+++ b/src/gpu/GrGLInterface.cpp
@@ -104,9 +104,6 @@ GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface* gl) {
GrGLInterface::GrGLInterface() {
fBindingsExported = (GrGLBinding)0;
- fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- fMinRenderTargetHeight = kProbe_GrGLCapability;
- fMinRenderTargetWidth = kProbe_GrGLCapability;
fActiveTexture = NULL;
fAttachShader = NULL;
diff --git a/src/gpu/GrGLRenderTarget.cpp b/src/gpu/GrGLRenderTarget.cpp
index 290ae2e47d..c98914a3b8 100644
--- a/src/gpu/GrGLRenderTarget.cpp
+++ b/src/gpu/GrGLRenderTarget.cpp
@@ -36,8 +36,6 @@ GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
texture,
viewport.fWidth,
viewport.fHeight,
- texture->allocatedWidth(),
- texture->allocatedHeight(),
desc.fConfig,
desc.fSampleCnt) {
GrAssert(NULL != texID);
@@ -45,6 +43,11 @@ GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
// FBO 0 can't also be a texture, right?
GrAssert(0 != desc.fRTFBOID);
GrAssert(0 != desc.fTexFBOID);
+
+ // we assume this is true, TODO: get rid of viewport as a param.
+ GrAssert(viewport.fWidth == texture->width());
+ GrAssert(viewport.fHeight == texture->height());
+
this->init(desc, viewport, texID);
}
@@ -55,8 +58,6 @@ GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
NULL,
viewport.fWidth,
viewport.fHeight,
- viewport.fWidth, // don't really need separate alloc w/h for
- viewport.fHeight, // non-texture RTs, repeat viewport values
desc.fConfig,
desc.fSampleCnt) {
this->init(desc, viewport, NULL);
diff --git a/src/gpu/GrGLTexture.cpp b/src/gpu/GrGLTexture.cpp
index 06efb8a36b..6e93b6c361 100644
--- a/src/gpu/GrGLTexture.cpp
+++ b/src/gpu/GrGLTexture.cpp
@@ -38,18 +38,14 @@ void GrGLTexture::init(GrGpuGL* gpu,
fUploadFormat = textureDesc.fUploadFormat;
fUploadType = textureDesc.fUploadType;
fOrientation = textureDesc.fOrientation;
- fScaleX = GrIntToScalar(textureDesc.fContentWidth) /
- textureDesc.fAllocWidth;
- fScaleY = GrIntToScalar(textureDesc.fContentHeight) /
- textureDesc.fAllocHeight;
if (NULL != rtDesc) {
// we render to the top left
GrGLIRect vp;
vp.fLeft = 0;
- vp.fWidth = textureDesc.fContentWidth;
- vp.fHeight = textureDesc.fContentHeight;
- vp.fBottom = textureDesc.fAllocHeight - textureDesc.fContentHeight;
+ vp.fWidth = textureDesc.fWidth;
+ vp.fBottom = 0;
+ vp.fHeight = textureDesc.fHeight;
fRenderTarget = new GrGLRenderTarget(gpu, *rtDesc, vp, fTexIDObj, this);
}
@@ -58,10 +54,8 @@ void GrGLTexture::init(GrGpuGL* gpu,
GrGLTexture::GrGLTexture(GrGpuGL* gpu,
const Desc& textureDesc)
: INHERITED(gpu,
- textureDesc.fContentWidth,
- textureDesc.fContentHeight,
- textureDesc.fAllocWidth,
- textureDesc.fAllocHeight,
+ textureDesc.fWidth,
+ textureDesc.fHeight,
textureDesc.fConfig) {
this->init(gpu, textureDesc, NULL);
}
@@ -70,10 +64,8 @@ GrGLTexture::GrGLTexture(GrGpuGL* gpu,
const Desc& textureDesc,
const GrGLRenderTarget::Desc& rtDesc)
: INHERITED(gpu,
- textureDesc.fContentWidth,
- textureDesc.fContentHeight,
- textureDesc.fAllocWidth,
- textureDesc.fAllocHeight,
+ textureDesc.fWidth,
+ textureDesc.fHeight,
textureDesc.fConfig) {
this->init(gpu, textureDesc, &rtDesc);
}
diff --git a/src/gpu/GrGLTexture.h b/src/gpu/GrGLTexture.h
index ce30e11741..cedac5a63b 100644
--- a/src/gpu/GrGLTexture.h
+++ b/src/gpu/GrGLTexture.h
@@ -60,10 +60,8 @@ public:
};
struct Desc {
- int fContentWidth;
- int fContentHeight;
- int fAllocWidth;
- int fAllocHeight;
+ int fWidth;
+ int fHeight;
GrPixelConfig fConfig;
GrGLuint fTextureID;
bool fOwnsID;
@@ -108,16 +106,6 @@ public:
GrGLenum uploadFormat() const { return fUploadFormat; }
GrGLenum uploadType() const { return fUploadType; }
- /**
- * @return width() / allocWidth()
- */
- GrScalar contentScaleX() const { return fScaleX; }
-
- /**
- * @return height() / allocHeight()
- */
- GrScalar contentScaleY() const { return fScaleY; }
-
// Ganesh assumes texture coordinates have their origin
// in the top-left corner of the image. OpenGL, however,
// has the origin in the lower-left corner. For content that
@@ -142,9 +130,6 @@ private:
GrGLTexID* fTexIDObj;
GrGLenum fUploadFormat;
GrGLenum fUploadType;
- // precomputed content / alloc ratios
- GrScalar fScaleX;
- GrScalar fScaleY;
Orientation fOrientation;
void init(GrGpuGL* gpu,
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 1baf42e34e..1e6b420a8b 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -161,8 +161,8 @@ GrTexture* GrGpu::createTexture(const GrTextureDesc& desc,
bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
GrAssert(NULL == rt->getStencilBuffer());
GrStencilBuffer* sb =
- this->getContext()->findStencilBuffer(rt->allocatedWidth(),
- rt->allocatedHeight(),
+ this->getContext()->findStencilBuffer(rt->width(),
+ rt->height(),
rt->numSamples());
if (NULL != sb) {
rt->setStencilBuffer(sb);
@@ -172,8 +172,8 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
}
return attached;
}
- if (this->createStencilBufferForRenderTarget(rt, rt->allocatedWidth(),
- rt->allocatedHeight())) {
+ if (this->createStencilBufferForRenderTarget(rt,
+ rt->width(), rt->height())) {
rt->getStencilBuffer()->ref();
rt->getStencilBuffer()->transferToCacheAndLock();
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index cd9de91818..86a95a973c 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -104,20 +104,6 @@ void GrGpuGL::AdjustTextureMatrix(const GrGLTexture* texture,
GrMatrix* matrix) {
GrAssert(NULL != texture);
GrAssert(NULL != matrix);
- if (GR_Scalar1 != texture->contentScaleX() ||
- GR_Scalar1 != texture->contentScaleY()) {
- if (GrSamplerState::kRadial_SampleMode == mode) {
- GrMatrix scale;
- scale.setScale(texture->contentScaleX(), texture->contentScaleX());
- matrix->postConcat(scale);
- } else if (GrSamplerState::kNormal_SampleMode == mode) {
- GrMatrix scale;
- scale.setScale(texture->contentScaleX(), texture->contentScaleY());
- matrix->postConcat(scale);
- } else {
- GrPrintf("We haven't handled NPOT adjustment for other sample modes!");
- }
- }
GrGLTexture::Orientation orientation = texture->orientation();
if (GrGLTexture::kBottomUp_Orientation == orientation) {
GrMatrix invY;
@@ -136,10 +122,6 @@ bool GrGpuGL::TextureMatrixIsIdentity(const GrGLTexture* texture,
if (!sampler.getMatrix().isIdentity()) {
return false;
}
- if (GR_Scalar1 != texture->contentScaleX() ||
- GR_Scalar1 != texture->contentScaleY()) {
- return false;
- }
GrGLTexture::Orientation orientation = texture->orientation();
if (GrGLTexture::kBottomUp_Orientation == orientation) {
return false;
@@ -182,81 +164,6 @@ static bool fbo_test(const GrGLInterface* gl, int w, int h) {
return status == GR_GL_FRAMEBUFFER_COMPLETE;
}
-static bool probe_for_npot_render_target_support(const GrGLInterface* gl,
- bool hasNPOTTextureSupport) {
-
- /* Experimentation has found that some GLs that support NPOT textures
- do not support FBOs with a NPOT texture. They report "unsupported" FBO
- status. I don't know how to explicitly query for this. Do an
- experiment. Note they may support NPOT with a renderbuffer but not a
- texture. Presumably, the implementation bloats the renderbuffer
- internally to the next POT.
- */
- if (hasNPOTTextureSupport) {
- return fbo_test(gl, 200, 200);
- }
- return false;
-}
-
-static int probe_for_min_render_target_height(const GrGLInterface* gl,
- bool hasNPOTRenderTargetSupport,
- int maxRenderTargetSize) {
- /* The iPhone 4 has a restriction that for an FBO with texture color
- attachment with height <= 8 then the width must be <= height. Here
- we look for such a limitation.
- */
- if (gPrintStartupSpew) {
- GrPrintf("Small height FBO texture experiments\n");
- }
- int minRenderTargetHeight = GR_INVAL_GLINT;
- for (GrGLuint i = 1; i <= 256; hasNPOTRenderTargetSupport ? ++i : i *= 2) {
- GrGLuint w = maxRenderTargetSize;
- GrGLuint h = i;
- if (fbo_test(gl, w, h)) {
- if (gPrintStartupSpew) {
- GrPrintf("\t[%d, %d]: PASSED\n", w, h);
- }
- minRenderTargetHeight = i;
- break;
- } else {
- if (gPrintStartupSpew) {
- GrPrintf("\t[%d, %d]: FAILED\n", w, h);
- }
- }
- }
- GrAssert(GR_INVAL_GLINT != minRenderTargetHeight);
-
- return minRenderTargetHeight;
-}
-
-static int probe_for_min_render_target_width(const GrGLInterface* gl,
- bool hasNPOTRenderTargetSupport,
- int maxRenderTargetSize) {
-
- if (gPrintStartupSpew) {
- GrPrintf("Small width FBO texture experiments\n");
- }
- int minRenderTargetWidth = GR_INVAL_GLINT;
- for (GrGLuint i = 1; i <= 256; hasNPOTRenderTargetSupport ? i *= 2 : ++i) {
- GrGLuint w = i;
- GrGLuint h = maxRenderTargetSize;
- if (fbo_test(gl, w, h)) {
- if (gPrintStartupSpew) {
- GrPrintf("\t[%d, %d]: PASSED\n", w, h);
- }
- minRenderTargetWidth = i;
- break;
- } else {
- if (gPrintStartupSpew) {
- GrPrintf("\t[%d, %d]: FAILED\n", w, h);
- }
- }
- }
- GrAssert(GR_INVAL_GLINT != minRenderTargetWidth);
-
- return minRenderTargetWidth;
-}
-
GrGpuGL::GrGpuGL(const GrGLInterface* gl, GrGLBinding glBinding) {
fPrintedCaps = false;
@@ -416,14 +323,11 @@ void GrGpuGL::initCaps() {
if (fGLVersion >= GR_GL_VER(2,0) ||
this->hasExtension("GL_ARB_texture_non_power_of_two")) {
fCaps.fNPOTTextureTileSupport = true;
- fCaps.fNPOTTextureSupport = true;
} else {
fCaps.fNPOTTextureTileSupport = false;
- fCaps.fNPOTTextureSupport = false;
}
} else {
// Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
- fCaps.fNPOTTextureSupport = true;
fCaps.fNPOTTextureTileSupport = this->hasExtension("GL_OES_texture_npot");
}
@@ -434,35 +338,12 @@ void GrGpuGL::initCaps() {
// TODO: Make these a preprocess that generate some compile time constants.
// TODO: probe once at startup, rather than once per context creation.
- int expectNPOTTargets = fGL->fNPOTRenderTargetSupport;
- if (expectNPOTTargets == kProbe_GrGLCapability) {
- fCaps.fNPOTRenderTargetSupport =
- probe_for_npot_render_target_support(fGL, fCaps.fNPOTTextureSupport);
- } else {
- GrAssert(expectNPOTTargets == 0 || expectNPOTTargets == 1);
- fCaps.fNPOTRenderTargetSupport = (0 != expectNPOTTargets);
- }
-
GR_GL_GetIntegerv(fGL, GR_GL_MAX_TEXTURE_SIZE, &fCaps.fMaxTextureSize);
GR_GL_GetIntegerv(fGL, GR_GL_MAX_RENDERBUFFER_SIZE, &fCaps.fMaxRenderTargetSize);
// Our render targets are always created with textures as the color
// attachment, hence this min:
fCaps.fMaxRenderTargetSize = GrMin(fCaps.fMaxTextureSize, fCaps.fMaxRenderTargetSize);
- fCaps.fMinRenderTargetHeight = fGL->fMinRenderTargetHeight;
- if (fCaps.fMinRenderTargetHeight == kProbe_GrGLCapability) {
- fCaps.fMinRenderTargetHeight =
- probe_for_min_render_target_height(fGL, fCaps.fNPOTRenderTargetSupport,
- fCaps.fMaxRenderTargetSize);
- }
-
- fCaps.fMinRenderTargetWidth = fGL->fMinRenderTargetWidth;
- if (fCaps.fMinRenderTargetWidth == kProbe_GrGLCapability) {
- fCaps.fMinRenderTargetWidth =
- probe_for_min_render_target_width(fGL, fCaps.fNPOTRenderTargetSupport,
- fCaps.fMaxRenderTargetSize);
- }
-
this->initFSAASupport();
this->initStencilFormats();
}
@@ -649,8 +530,8 @@ GrTexture* GrGpuGL::onCreatePlatformTexture(const GrPlatformTextureDesc& desc) {
return NULL;
}
- glTexDesc.fContentWidth = glTexDesc.fAllocWidth = desc.fWidth;
- glTexDesc.fContentHeight = glTexDesc.fAllocHeight = desc.fHeight;
+ glTexDesc.fWidth = desc.fWidth;
+ glTexDesc.fHeight = desc.fHeight;
glTexDesc.fConfig = desc.fConfig;
glTexDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
glTexDesc.fOwnsID = false;
@@ -665,8 +546,8 @@ GrTexture* GrGpuGL::onCreatePlatformTexture(const GrPlatformTextureDesc& desc) {
glRTDesc.fOwnIDs = true;
glRTDesc.fConfig = desc.fConfig;
glRTDesc.fSampleCnt = desc.fSampleCnt;
- if (!this->createRenderTargetObjects(glTexDesc.fAllocWidth,
- glTexDesc.fAllocHeight,
+ if (!this->createRenderTargetObjects(glTexDesc.fWidth,
+ glTexDesc.fHeight,
glTexDesc.fTextureID,
&glRTDesc)) {
return NULL;
@@ -763,8 +644,8 @@ GrResource* GrGpuGL::onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc)
&texDesc.fUploadType)) {
return NULL;
}
- texDesc.fAllocWidth = texDesc.fContentWidth = desc.fWidth;
- texDesc.fAllocHeight = texDesc.fContentHeight = desc.fHeight;
+ texDesc.fWidth = desc.fWidth;
+ texDesc.fHeight = desc.fHeight;
texDesc.fConfig = desc.fConfig;
texDesc.fOrientation = GrGLTexture::kBottomUp_Orientation;
@@ -801,7 +682,7 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc,
// we assume the texture is bound
size_t bpp = GrBytesPerPixel(desc.fConfig);
- size_t trimRowBytes = desc.fContentWidth * bpp;
+ size_t trimRowBytes = desc.fWidth * bpp;
if (!rowBytes) {
rowBytes = trimRowBytes;
@@ -825,13 +706,13 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc,
} else {
if (data && (trimRowBytes != rowBytes || flipY)) {
// copy the data into our new storage, skipping the trailing bytes
- size_t trimSize = desc.fContentHeight * trimRowBytes;
+ size_t trimSize = desc.fHeight * trimRowBytes;
const char* src = (const char*)data;
if (flipY) {
- src += (desc.fContentHeight - 1) * rowBytes;
+ src += (desc.fHeight - 1) * rowBytes;
}
char* dst = (char*)tempStorage.reset(trimSize);
- for (int y = 0; y < desc.fContentHeight; y++) {
+ for (int y = 0; y < desc.fHeight; y++) {
memcpy(dst, src, trimRowBytes);
if (flipY) {
src -= rowBytes;
@@ -850,87 +731,20 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc,
if (kIndex_8_GrPixelConfig == desc.fConfig &&
this->getCaps().f8BitPaletteSupport) {
// ES only supports CompressedTexImage2D, not CompressedTexSubimage2D
- GrAssert(desc.fContentWidth == desc.fAllocWidth);
- GrAssert(desc.fContentHeight == desc.fAllocHeight);
- GrGLsizei imageSize = desc.fAllocWidth * desc.fAllocHeight +
+ GrGLsizei imageSize = desc.fWidth * desc.fHeight +
kGrColorTableSize;
GL_CALL(CompressedTexImage2D(GR_GL_TEXTURE_2D, 0, desc.fUploadFormat,
- desc.fAllocWidth, desc.fAllocHeight,
+ desc.fWidth, desc.fHeight,
0, imageSize, data));
if (this->glCaps().fUnpackRowLengthSupport) {
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
}
} else {
- if (NULL != data && (desc.fAllocWidth != desc.fContentWidth ||
- desc.fAllocHeight != desc.fContentHeight)) {
- GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat,
- desc.fAllocWidth, desc.fAllocHeight,
- 0, desc.fUploadFormat, desc.fUploadType, NULL));
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, 0, 0, desc.fContentWidth,
- desc.fContentHeight, desc.fUploadFormat,
- desc.fUploadType, data));
- if (this->glCaps().fUnpackRowLengthSupport) {
- GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
- }
-
- int extraW = desc.fAllocWidth - desc.fContentWidth;
- int extraH = desc.fAllocHeight - desc.fContentHeight;
- int maxTexels = extraW * extraH;
- maxTexels = GrMax(extraW * desc.fContentHeight, maxTexels);
- maxTexels = GrMax(desc.fContentWidth * extraH, maxTexels);
-
- SkAutoSMalloc<128*128> texels(bpp * maxTexels);
-
- if (extraH) {
- uint8_t* lastRowStart = (uint8_t*) data +
- (desc.fContentHeight - 1) * rowBytes;
- uint8_t* extraRowStart = (uint8_t*)texels.get();
-
- for (int i = 0; i < extraH; ++i) {
- memcpy(extraRowStart, lastRowStart, trimRowBytes);
- extraRowStart += trimRowBytes;
- }
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, 0,
- desc.fContentHeight, desc.fContentWidth,
- extraH, desc.fUploadFormat,
- desc.fUploadType, texels.get()));
- }
- if (extraW) {
- uint8_t* edgeTexel = (uint8_t*)data + trimRowBytes - bpp;
- uint8_t* extraTexel = (uint8_t*)texels.get();
- for (int j = 0; j < desc.fContentHeight; ++j) {
- for (int i = 0; i < extraW; ++i) {
- memcpy(extraTexel, edgeTexel, bpp);
- extraTexel += bpp;
- }
- edgeTexel += rowBytes;
- }
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, desc.fContentWidth,
- 0, extraW, desc.fContentHeight,
- desc.fUploadFormat, desc.fUploadType,
- texels.get()));
- }
- if (extraW && extraH) {
- uint8_t* cornerTexel = (uint8_t*)data +
- desc.fContentHeight * rowBytes - bpp;
- uint8_t* extraTexel = (uint8_t*)texels.get();
- for (int i = 0; i < extraW*extraH; ++i) {
- memcpy(extraTexel, cornerTexel, bpp);
- extraTexel += bpp;
- }
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, desc.fContentWidth,
- desc.fContentHeight, extraW, extraH,
- desc.fUploadFormat, desc.fUploadType,
- texels.get()));
- }
-
- } else {
- GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat,
- desc.fAllocWidth, desc.fAllocHeight, 0,
- desc.fUploadFormat, desc.fUploadType, data));
- if (this->glCaps().fUnpackRowLengthSupport) {
- GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
- }
+ GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat,
+ desc.fWidth, desc.fHeight, 0,
+ desc.fUploadFormat, desc.fUploadType, data));
+ if (this->glCaps().fUnpackRowLengthSupport) {
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
}
}
}
@@ -1044,10 +858,8 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
GrGLRenderTarget::Desc glRTDesc;
GrGLenum internalFormat;
- glTexDesc.fContentWidth = desc.fWidth;
- glTexDesc.fContentHeight = desc.fHeight;
- glTexDesc.fAllocWidth = desc.fWidth;
- glTexDesc.fAllocHeight = desc.fHeight;
+ glTexDesc.fWidth = desc.fWidth;
+ glTexDesc.fHeight = desc.fHeight;
glTexDesc.fConfig = desc.fConfig;
glTexDesc.fOwnsID = true;
@@ -1081,24 +893,8 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
}
if (renderTarget) {
- if (!caps.fNPOTRenderTargetSupport) {
- glTexDesc.fAllocWidth = GrNextPow2(desc.fWidth);
- glTexDesc.fAllocHeight = GrNextPow2(desc.fHeight);
- }
-
- glTexDesc.fAllocWidth = GrMax(caps.fMinRenderTargetWidth,
- glTexDesc.fAllocWidth);
- glTexDesc.fAllocHeight = GrMax(caps.fMinRenderTargetHeight,
- glTexDesc.fAllocHeight);
- if (glTexDesc.fAllocWidth > caps.fMaxRenderTargetSize ||
- glTexDesc.fAllocHeight > caps.fMaxRenderTargetSize) {
- return return_null_texture();
- }
- } else if (!caps.fNPOTTextureSupport) {
- glTexDesc.fAllocWidth = GrNextPow2(desc.fWidth);
- glTexDesc.fAllocHeight = GrNextPow2(desc.fHeight);
- if (glTexDesc.fAllocWidth > caps.fMaxTextureSize ||
- glTexDesc.fAllocHeight > caps.fMaxTextureSize) {
+ if (glTexDesc.fWidth > caps.fMaxRenderTargetSize ||
+ glTexDesc.fHeight > caps.fMaxRenderTargetSize) {
return return_null_texture();
}
}
@@ -1139,8 +935,8 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
#if GR_COLLECT_STATS
++fStats.fRenderTargetCreateCnt;
#endif
- if (!this->createRenderTargetObjects(glTexDesc.fAllocWidth,
- glTexDesc.fAllocHeight,
+ if (!this->createRenderTargetObjects(glTexDesc.fWidth,
+ glTexDesc.fHeight,
glTexDesc.fTextureID,
&glRTDesc)) {
GL_CALL(DeleteTextures(1, &glTexDesc.fTextureID));
@@ -1187,8 +983,8 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
// All internally created RTs are also textures. We don't create
// SBs for a client's standalone RT (that is RT that isnt also a texture).
GrAssert(rt->asTexture());
- GrAssert(width >= rt->allocatedWidth());
- GrAssert(height >= rt->allocatedHeight());
+ GrAssert(width >= rt->width());
+ GrAssert(height >= rt->height());
int samples = rt->numSamples();
GrGLuint sbID;
diff --git a/src/gpu/GrGpuGL.h b/src/gpu/GrGpuGL.h
index b5b5b15258..c1b17eeaeb 100644
--- a/src/gpu/GrGpuGL.h
+++ b/src/gpu/GrGpuGL.h
@@ -218,7 +218,7 @@ protected:
return GrGLHasExtensionFromString(ext, fExtensionString.c_str());
}
- // adjusts texture matrix to account for orientation, size, and npotness
+ // adjusts texture matrix to account for orientation
static void AdjustTextureMatrix(const GrGLTexture* texture,
GrSamplerState::SampleMode mode,
GrMatrix* matrix);
diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp
index ae5b1725a2..5ae6d65118 100644
--- a/src/gpu/GrGpuGLShaders.cpp
+++ b/src/gpu/GrGpuGLShaders.cpp
@@ -475,11 +475,6 @@ void GrGpuGLShaders::flushTextureDomain(int s) {
SkTSwap(values[1], values[3]);
}
- values[0] *= SkScalarToFloat(texture->contentScaleX());
- values[2] *= SkScalarToFloat(texture->contentScaleX());
- values[1] *= SkScalarToFloat(texture->contentScaleY());
- values[3] *= SkScalarToFloat(texture->contentScaleY());
-
GL_CALL(Uniform4fv(uni, 1, values));
}
}
@@ -581,12 +576,14 @@ void GrGpuGLShaders::flushTexelSize(int s) {
const int& uni = fProgramData->fUniLocations.fStages[s].fNormalizedTexelSizeUni;
if (GrGLProgram::kUnusedUniform != uni) {
GrGLTexture* texture = (GrGLTexture*) fCurrDrawState.fTextures[s];
- if (texture->allocatedWidth() != fProgramData->fTextureWidth[s] ||
- texture->allocatedHeight() != fProgramData->fTextureWidth[s]) {
+ if (texture->width() != fProgramData->fTextureWidth[s] ||
+ texture->height() != fProgramData->fTextureHeight[s]) {
- float texelSize[] = {1.f / texture->allocatedWidth(),
- 1.f / texture->allocatedHeight()};
+ float texelSize[] = {1.f / texture->width(),
+ 1.f / texture->height()};
GL_CALL(Uniform2fv(uni, 1, texelSize));
+ fProgramData->fTextureWidth[s] = texture->width();
+ fProgramData->fTextureHeight[s] = texture->height();
}
}
}
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index a5f1216571..7a53c0b301 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -31,8 +31,8 @@ size_t GrRenderTarget::sizeInBytes() const {
} else {
colorBits = GrBytesPerPixel(fConfig);
}
- uint64_t size = fAllocatedWidth;
- size *= fAllocatedHeight;
+ uint64_t size = fWidth;
+ size *= fHeight;
size *= colorBits;
size *= GrMax(1,fSampleCnt);
return (size_t)(size / 8);
diff --git a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
index 9bc80f0dde..0060c217f3 100644
--- a/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
+++ b/src/gpu/ios/GrGLDefaultInterface_iOS.cpp
@@ -18,9 +18,6 @@ const GrGLInterface* GrGLDefaultInterface() {
GrGLInteface* interface = new GrGLInterface;
glInterface.reset(interface);
- interface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- interface->fMinRenderTargetHeight = kProbe_GrGLCapability;
- interface->fMinRenderTargetWidth = kProbe_GrGLCapability;
interface->fActiveTexture = glActiveTexture;
interface->fAttachShader = glAttachShader;
interface->fBindAttribLocation = glBindAttribLocation;
diff --git a/src/gpu/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/mesa/GrGLCreateMesaInterface.cpp
index f289bcb7fd..596431c050 100644
--- a/src/gpu/mesa/GrGLCreateMesaInterface.cpp
+++ b/src/gpu/mesa/GrGLCreateMesaInterface.cpp
@@ -32,9 +32,6 @@ const GrGLInterface* GrGLCreateMesaInterface() {
return NULL;
}
GrGLInterface* interface = new GrGLInterface();
- interface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- interface->fMinRenderTargetHeight = kProbe_GrGLCapability;
- interface->fMinRenderTargetWidth = kProbe_GrGLCapability;
GR_GL_GET_PROC(ActiveTexture);
GR_GL_GET_PROC(BeginQuery);
diff --git a/src/gpu/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/unix/GrGLCreateNativeInterface_unix.cpp
index 2fc81a6c4f..000d667981 100644
--- a/src/gpu/unix/GrGLCreateNativeInterface_unix.cpp
+++ b/src/gpu/unix/GrGLCreateNativeInterface_unix.cpp
@@ -32,10 +32,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
GrGLInterface* interface = new GrGLInterface();
- interface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- interface->fMinRenderTargetHeight = kProbe_GrGLCapability;
- interface->fMinRenderTargetWidth = kProbe_GrGLCapability;
-
interface->fActiveTexture = glActiveTexture;
GR_GL_GET_PROC(AttachShader);
GR_GL_GET_PROC(BindAttribLocation);
diff --git a/src/gpu/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/win/GrGLCreateNativeInterface_win.cpp
index b5ccc35d1b..c67618c24d 100644
--- a/src/gpu/win/GrGLCreateNativeInterface_win.cpp
+++ b/src/gpu/win/GrGLCreateNativeInterface_win.cpp
@@ -37,10 +37,6 @@ const GrGLInterface* GrGLCreateNativeInterface() {
}
GrGLInterface* interface = new GrGLInterface();
- interface->fNPOTRenderTargetSupport = kProbe_GrGLCapability;
- interface->fMinRenderTargetHeight = kProbe_GrGLCapability;
- interface->fMinRenderTargetWidth = kProbe_GrGLCapability;
-
// Functions that are part of GL 1.1 will return NULL in
// wglGetProcAddress
interface->fBindTexture = glBindTexture;