Make sure GrBackendTextures are valid before starting to do things with them
Bug: skia: Change-Id: If05706f0fd732bb1b2bfb788b540e795fa724814 Reviewed-on: https://skia-review.googlesource.com/119887 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
255735e53b
commit
66aebf3b47
@ -328,7 +328,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
|||||||
GrWrapOwnership ownership,
|
GrWrapOwnership ownership,
|
||||||
SkImage::TextureReleaseProc releaseProc,
|
SkImage::TextureReleaseProc releaseProc,
|
||||||
SkImage::ReleaseContext releaseCtx) {
|
SkImage::ReleaseContext releaseCtx) {
|
||||||
if (backendTex.width() <= 0 || backendTex.height() <= 0) {
|
if (!backendTex.isValid() || backendTex.width() <= 0 || backendTex.height() <= 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,6 +345,9 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
|||||||
|
|
||||||
bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex, GrPixelConfig* config,
|
bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex, GrPixelConfig* config,
|
||||||
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs) {
|
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs) {
|
||||||
|
if (!tex.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
|
// TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
|
||||||
// create a fake image info here.
|
// create a fake image info here.
|
||||||
SkImageInfo info = SkImageInfo::Make(1, 1, ct, at, cs);
|
SkImageInfo info = SkImageInfo::Make(1, 1, ct, at, cs);
|
||||||
|
@ -404,6 +404,9 @@ sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context,
|
|||||||
bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex, GrPixelConfig* config,
|
bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex, GrPixelConfig* config,
|
||||||
int sampleCnt, SkColorType ct, sk_sp<SkColorSpace> cs,
|
int sampleCnt, SkColorType ct, sk_sp<SkColorSpace> cs,
|
||||||
bool texturable) {
|
bool texturable) {
|
||||||
|
if (!tex.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
|
// TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
|
||||||
// create a fake image info here.
|
// create a fake image info here.
|
||||||
SkImageInfo info = SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType, cs);
|
SkImageInfo info = SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType, cs);
|
||||||
@ -544,7 +547,7 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont
|
|||||||
if (!context) {
|
if (!context) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!SkSurface_Gpu::Valid(context->caps(), tex.config(), colorSpace.get())) {
|
if (!tex.isValid() || !SkSurface_Gpu::Valid(context->caps(), tex.config(), colorSpace.get())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sampleCnt = SkTMax(1, sampleCnt);
|
sampleCnt = SkTMax(1, sampleCnt);
|
||||||
|
Loading…
Reference in New Issue
Block a user