aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLGpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 159cec721f..bef1f1919f 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1009,7 +1009,8 @@ void GrGLGpu::unbindCpuToGpuXferBuffer() {
bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight,
GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType,
int left, int top, int width, int height, GrPixelConfig dataConfig,
- const GrMipLevel texels[], int mipLevelCount) {
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided) {
SkASSERT(this->caps()->isConfigTexturable(texConfig));
SkDEBUGCODE(
SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
@@ -1075,6 +1076,11 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
// in case we need a temporary, trimmed copy of the src pixels
SkAutoSMalloc<128 * 128> tempStorage;
+ if (wasFullMipMapDataProvided) {
+ // Make sure this is initialized to true
+ *wasFullMipMapDataProvided = true;
+ }
+
// find the combined size of all the mip levels and the relative offset of
// each into the collective buffer
size_t combinedBufferSize = 0;
@@ -1088,6 +1094,9 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
individualMipOffsets.push_back(combinedBufferSize);
combinedBufferSize += trimmedSize;
} else {
+ if (wasFullMipMapDataProvided) {
+ *wasFullMipMapDataProvided = false;
+ }
individualMipOffsets.push_back(0);
}
@@ -1407,15 +1416,16 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
GrGLTexture::IDDesc idDesc;
idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
+ bool wasFullMipMapDataProvided = true;
GrGLTexture::TexParams initialTexParams;
if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams,
- texels, mipLevelCount)) {
+ texels, mipLevelCount, &wasFullMipMapDataProvided)) {
return return_null_texture();
}
- bool wasMipMapDataProvided = false;
+ bool mipsAllocated = false;
if (mipLevelCount > 1) {
- wasMipMapDataProvided = true;
+ mipsAllocated = true;
}
sk_sp<GrGLTexture> tex;
@@ -1429,10 +1439,11 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
return return_null_texture();
}
tex = sk_make_sp<GrGLTextureRenderTarget>(this, budgeted, desc, idDesc, rtIDDesc,
- wasMipMapDataProvided);
+ mipsAllocated, wasFullMipMapDataProvided);
tex->baseLevelWasBoundToFBO();
} else {
- tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc, wasMipMapDataProvided);
+ tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc,
+ mipsAllocated, wasFullMipMapDataProvided);
}
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
@@ -1603,7 +1614,8 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
bool renderTarget, GrGLTexture::TexParams* initialTexParams,
- const GrMipLevel texels[], int mipLevelCount) {
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided) {
info->fID = 0;
info->fTarget = GR_GL_TEXTURE_2D;
GL_CALL(GenTextures(1, &(info->fID)));
@@ -3165,6 +3177,9 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs
return;
}
+ // Make sure we at least have some base layer to make mips from
+ SkASSERT(texture->texturePriv().mipMapsAreValid());
+
// If we created a rt/tex and rendered to it without using a texture and now we're texturing
// from the rt it will still be the last bound texture, but it needs resolving.
GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTarget());