aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-12-18 14:48:15 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-18 21:17:46 +0000
commitf5d8758f29390fd5c135df12bc8a5e196854eda2 (patch)
treea7de0b54b030dda4549bc9feb0a0e2ff65ded7d6 /src/gpu/gl
parent4fafedd33add9948db1147c60d681ed9340984fd (diff)
Add new SkImage factory to create from GrBackendTexture with SkColorType
Bug: skia: Change-Id: I46bdc54b6d9cdacc8f5a06644aa6b110837879f0 Reviewed-on: https://skia-review.googlesource.com/84342 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp55
-rw-r--r--src/gpu/gl/GrGLCaps.h2
-rw-r--r--src/gpu/gl/GrGLGpu.cpp4
3 files changed, 60 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index efc6628266..05e3268dc9 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2361,3 +2361,58 @@ int GrGLCaps::getSampleCount(int requestedCount, GrPixelConfig config) const {
return fConfigTable[config].fColorSampleCounts[count-1];
}
+bool GrGLCaps::onValidateBackendTexture(GrBackendTexture* tex, SkColorType ct) const {
+ const GrGLTextureInfo* texInfo = tex->getGLTextureInfo();
+ if (!texInfo) {
+ return false;
+ }
+ GrGLenum format = texInfo->fFormat;
+ tex->fConfig = kUnknown_GrPixelConfig;
+
+ switch (ct) {
+ case kUnknown_SkColorType:
+ return false;
+ case kAlpha_8_SkColorType:
+ if (GR_GL_ALPHA8 == format) {
+ tex->fConfig = kAlpha_8_as_Alpha_GrPixelConfig;
+ } else if (GR_GL_R8 == format) {
+ tex->fConfig = kAlpha_8_as_Red_GrPixelConfig;
+ }
+ break;
+ case kRGB_565_SkColorType:
+ if (GR_GL_RGB565 == format) {
+ tex->fConfig = kRGB_565_GrPixelConfig;
+ }
+ break;
+ case kARGB_4444_SkColorType:
+ if (GR_GL_RGBA4 == format) {
+ tex->fConfig = kRGBA_4444_GrPixelConfig;
+ }
+ break;
+ case kRGBA_8888_SkColorType:
+ if (GR_GL_RGBA8 == format) {
+ tex->fConfig = kRGBA_8888_GrPixelConfig;
+ }
+ break;
+ case kBGRA_8888_SkColorType:
+ if (GR_GL_BGRA8 == format) {
+ tex->fConfig = kBGRA_8888_GrPixelConfig;
+ }
+ break;
+ case kGray_8_SkColorType:
+ if (GR_GL_LUMINANCE8 == format) {
+ tex->fConfig = kGray_8_as_Lum_GrPixelConfig;
+ } else if (GR_GL_R8 == format) {
+ tex->fConfig = kGray_8_as_Red_GrPixelConfig;
+ }
+ break;
+ case kRGBA_F16_SkColorType:
+ if (GR_GL_RGBA16F == format) {
+ tex->fConfig = kRGBA_half_GrPixelConfig;
+ }
+ break;
+ }
+
+ return kUnknown_GrPixelConfig != tex->fConfig;
+}
+
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 3a50e8a393..38cbfe8747 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -416,6 +416,8 @@ public:
}
private:
+ bool onValidateBackendTexture(GrBackendTexture*, SkColorType) const override;
+
enum ExternalFormatUsage {
kTexImage_ExternalFormatUsage,
kOther_ExternalFormatUsage,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 95eb339db8..7b66bcc8a1 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -4421,6 +4421,8 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, i
return GrBackendTexture(); // invalid
}
+ info.fFormat = this->glCaps().configSizedInternalFormat(config);
+
this->unbindCpuToGpuXferBuffer();
// Figure out the number of mip levels.
@@ -4447,7 +4449,7 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, i
height = SkTMax(1, height / 2);
}
- return GrBackendTexture(w, h, config, mipMapped, info);
+ return GrBackendTexture(w, h, mipMapped, info);
}
bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {