aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rwxr-xr-xsrc/gpu/GrContext.cpp4
-rw-r--r--src/gpu/GrDrawTarget.cpp14
-rw-r--r--src/gpu/GrSurface.cpp6
-rw-r--r--src/gpu/SkGr.cpp16
-rw-r--r--src/gpu/SkGrPixelRef.cpp12
-rw-r--r--src/gpu/gl/GrGLCaps.cpp26
-rw-r--r--src/gpu/gl/GrGLDefines.h2
-rw-r--r--src/gpu/gl/GrGpuGL.cpp10
8 files changed, 73 insertions, 17 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index cc6a637267..c637101d07 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1222,7 +1222,7 @@ void GrContext::flush(int flagsBitfield) {
bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes,
const void* inPixels, size_t outRowBytes, void* outPixels) {
SkSrcPixelInfo srcPI;
- if (!GrPixelConfig2ColorType(srcConfig, &srcPI.fColorType)) {
+ if (!GrPixelConfig2ColorAndProfileType(srcConfig, &srcPI.fColorType, NULL)) {
return false;
}
srcPI.fAlphaType = kUnpremul_SkAlphaType;
@@ -1483,7 +1483,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
// Perform any conversions we weren't able to perform using a scratch texture.
if (unpremul || swapRAndB) {
SkDstPixelInfo dstPI;
- if (!GrPixelConfig2ColorType(dstConfig, &dstPI.fColorType)) {
+ if (!GrPixelConfig2ColorAndProfileType(dstConfig, &dstPI.fColorType, NULL)) {
return false;
}
dstPI.fAlphaType = kUnpremul_SkAlphaType;
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 9ba9265f68..18ea72cd57 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -1139,6 +1139,7 @@ SkString GrDrawTargetCaps::dump() const {
"RGBA444", // kRGBA_4444_GrPixelConfig,
"RGBA8888", // kRGBA_8888_GrPixelConfig,
"BGRA8888", // kBGRA_8888_GrPixelConfig,
+ "SRGBA8888",// kSRGBA_8888_GrPixelConfig,
"ETC1", // kETC1_GrPixelConfig,
"LATC", // kLATC_GrPixelConfig,
"R11EAC", // kR11_EAC_GrPixelConfig,
@@ -1153,12 +1154,13 @@ SkString GrDrawTargetCaps::dump() const {
GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kASTC_12x12_GrPixelConfig);
- GR_STATIC_ASSERT(11 == kRGBA_float_GrPixelConfig);
- GR_STATIC_ASSERT(12 == kAlpha_half_GrPixelConfig);
+ GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig);
+ GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig);
+ GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig);
+ GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig);
+ GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig);
+ GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index 1ca305b5a1..678755a58f 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -43,10 +43,12 @@ bool GrSurface::readPixels(int left, int top, int width, int height,
SkImageInfo GrSurface::info() const {
SkColorType colorType;
- if (!GrPixelConfig2ColorType(this->config(), &colorType)) {
+ SkColorProfileType profileType;
+ if (!GrPixelConfig2ColorAndProfileType(this->config(), &colorType, &profileType)) {
sk_throw();
}
- return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_SkAlphaType);
+ return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_SkAlphaType,
+ profileType);
}
// TODO: This should probably be a non-member helper function. It might only be needed in
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ff74fe92ca..4a2b90e7a6 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -426,7 +426,7 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
// alpha info, that will be considered.
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) {
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt) {
switch (ct) {
case kUnknown_SkColorType:
return kUnknown_GrPixelConfig;
@@ -437,6 +437,9 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) {
case kARGB_4444_SkColorType:
return kRGBA_4444_GrPixelConfig;
case kRGBA_8888_SkColorType:
+ if (kSRGB_SkColorProfileType == pt) {
+ return kSRGBA_8888_GrPixelConfig;
+ }
return kRGBA_8888_GrPixelConfig;
case kBGRA_8888_SkColorType:
return kBGRA_8888_GrPixelConfig;
@@ -447,8 +450,10 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) {
return kUnknown_GrPixelConfig;
}
-bool GrPixelConfig2ColorType(GrPixelConfig config, SkColorType* ctOut) {
+bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut,
+ SkColorProfileType* ptOut) {
SkColorType ct;
+ SkColorProfileType pt = kLinear_SkColorProfileType;
switch (config) {
case kAlpha_8_GrPixelConfig:
ct = kAlpha_8_SkColorType;
@@ -468,12 +473,19 @@ bool GrPixelConfig2ColorType(GrPixelConfig config, SkColorType* ctOut) {
case kBGRA_8888_GrPixelConfig:
ct = kBGRA_8888_SkColorType;
break;
+ case kSRGBA_8888_GrPixelConfig:
+ ct = kRGBA_8888_SkColorType;
+ pt = kSRGB_SkColorProfileType;
+ break;
default:
return false;
}
if (ctOut) {
*ctOut = ct;
}
+ if (ptOut) {
+ *ptOut = pt;
+ }
return true;
}
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 1784d5595e..f752bf0001 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -54,7 +54,7 @@ bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
///////////////////////////////////////////////////////////////////////////////
static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorType dstCT,
- const SkIRect* subset) {
+ SkColorProfileType dstPT, const SkIRect* subset) {
if (NULL == texture || kUnknown_SkColorType == dstCT) {
return NULL;
}
@@ -78,7 +78,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
srcRect = *subset;
}
desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
- desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType);
+ desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT);
GrTexture* dst = context->createUncachedTexture(desc, NULL, 0);
if (NULL == dst) {
@@ -91,7 +91,8 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
context->copySurface(dst->asRenderTarget(), texture, srcRect, SkIPoint::Make(0,0),
GrContext::kFlushWrites_PixelOp);
- SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType);
+ SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType,
+ dstPT);
SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, dst));
SkSafeUnref(dst);
return pixelRef;
@@ -125,7 +126,8 @@ GrTexture* SkGrPixelRef::getTexture() {
return NULL;
}
-SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, const SkIRect* subset) {
+SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT,
+ const SkIRect* subset) {
if (NULL == fSurface) {
return NULL;
}
@@ -136,7 +138,7 @@ SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, const SkIRect* subset) {
// a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
// independently of that texture. Texture-backed pixel refs, on the other
// hand, own their GrTextures, and are thus self-contained.
- return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, subset);
+ return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstPT, subset);
}
static bool tryAllocBitmapPixels(SkBitmap* bitmap) {
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index cfb9558c76..b729820ca5 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -478,6 +478,23 @@ void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
}
}
+ if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) {
+ if (kGL_GrGLStandard == standard) {
+ if (ctxInfo.version() >= GR_GL_VER(3,0) ||
+ ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
+ ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
+ fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
+ fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
+ }
+ } else {
+ if (ctxInfo.version() >= GR_GL_VER(3,0) ||
+ ctxInfo.hasExtension("GL_EXT_sRGB")) {
+ fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
+ fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
+ }
+ }
+ }
+
if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
@@ -560,6 +577,15 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
}
+ // Check for sRGBA
+ if (kGL_GrGLStandard == standard) {
+ fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
+ (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB"));
+ } else {
+ fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
+ (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
+ }
+
// Compressed texture support
// glCompressedTexImage2D is available on all OpenGL ES devices...
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index 0eb5149a8c..fc44252515 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -770,6 +770,8 @@
#define GR_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GR_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GR_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GR_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GR_GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
#define GR_GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
#define GR_GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
#define GR_GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index b36e8870cd..96af8af47f 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2310,6 +2310,16 @@ bool GrGLGpu::configToGLFormats(GrPixelConfig config,
*externalFormat = GR_GL_BGRA;
*externalType = GR_GL_UNSIGNED_BYTE;
break;
+ case kSRGBA_8888_GrPixelConfig:
+ *internalFormat = GR_GL_SRGB_ALPHA;
+ *externalFormat = GR_GL_SRGB_ALPHA;
+ if (getSizedInternalFormat) {
+ *internalFormat = GR_GL_SRGB8_ALPHA8;
+ } else {
+ *internalFormat = GR_GL_SRGB_ALPHA;
+ }
+ *externalType = GR_GL_UNSIGNED_BYTE;
+ break;
case kRGB_565_GrPixelConfig:
*internalFormat = GR_GL_RGB;
*externalFormat = GR_GL_RGB;