| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkGr.h" | 9 #include "SkGr.h" |
| 10 #include "SkGrPriv.h" | 10 #include "SkGrPriv.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
geted budgeted) { | 237 GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
geted budgeted) { |
| 238 const SkPixmap* pmap = &pixmap; | 238 const SkPixmap* pmap = &pixmap; |
| 239 SkPixmap tmpPixmap; | 239 SkPixmap tmpPixmap; |
| 240 SkBitmap tmpBitmap; | 240 SkBitmap tmpBitmap; |
| 241 | 241 |
| 242 const GrCaps* caps = ctx->caps(); | 242 const GrCaps* caps = ctx->caps(); |
| 243 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps); | 243 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps); |
| 244 | 244 |
| 245 if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) && | 245 if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) && |
| 246 pixmap.info().colorSpace() && pixmap.info().colorSpace()->gammaCloseToSR
GB()) { | 246 kSRGB_SkColorProfileType == pixmap.info().profileType()) { |
| 247 // We were supplied sRGB as the profile type, but we don't have a suitab
le pixel config. | 247 // We were supplied sRGB as the profile type, but we don't have a suitab
le pixel config. |
| 248 // Convert to 8888 sRGB so we can handle the data correctly. The raster
backend doesn't | 248 // Convert to 8888 sRGB so we can handle the data correctly. The raster
backend doesn't |
| 249 // handle sRGB Index8 -> sRGB 8888 correctly (yet), so lie about both th
e source and | 249 // handle sRGB Index8 -> sRGB 8888 correctly (yet), so lie about both th
e source and |
| 250 // destination (claim they're linear): | 250 // destination (claim they're linear): |
| 251 SkImageInfo linSrcInfo = SkImageInfo::Make(pixmap.width(), pixmap.height
(), | 251 SkImageInfo linSrcInfo = SkImageInfo::Make(pixmap.width(), pixmap.height
(), |
| 252 pixmap.colorType(), pixmap.al
phaType()); | 252 pixmap.colorType(), pixmap.al
phaType()); |
| 253 SkPixmap linSrcPixmap(linSrcInfo, pixmap.addr(), pixmap.rowBytes(), pixm
ap.ctable()); | 253 SkPixmap linSrcPixmap(linSrcInfo, pixmap.addr(), pixmap.rowBytes(), pixm
ap.ctable()); |
| 254 | 254 |
| 255 SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.
height(), | 255 SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(pixmap.width(), pixmap.
height(), |
| 256 kSRGB_SkColorProfileTyp
e); | 256 kSRGB_SkColorProfileTyp
e); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params,
gammaTreatment, | 411 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params,
gammaTreatment, |
| 412 nullptr)
; | 412 nullptr)
; |
| 413 } | 413 } |
| 414 return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, gammaTr
eatment); | 414 return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, gammaTr
eatment); |
| 415 } | 415 } |
| 416 | 416 |
| 417 /////////////////////////////////////////////////////////////////////////////// | 417 /////////////////////////////////////////////////////////////////////////////// |
| 418 | 418 |
| 419 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass | 419 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass |
| 420 // alpha info, that will be considered. | 420 // alpha info, that will be considered. |
| 421 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkCol
orSpace* cs, | 421 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf
ileType pt, |
| 422 const GrCaps& caps) { | 422 const GrCaps& caps) { |
| 423 // We intentionally ignore profile type for non-8888 formats. Anything we ca
n't support | 423 // We intentionally ignore profile type for non-8888 formats. Anything we ca
n't support |
| 424 // in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture. | 424 // in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture. |
| 425 switch (ct) { | 425 switch (ct) { |
| 426 case kUnknown_SkColorType: | 426 case kUnknown_SkColorType: |
| 427 return kUnknown_GrPixelConfig; | 427 return kUnknown_GrPixelConfig; |
| 428 case kAlpha_8_SkColorType: | 428 case kAlpha_8_SkColorType: |
| 429 return kAlpha_8_GrPixelConfig; | 429 return kAlpha_8_GrPixelConfig; |
| 430 case kRGB_565_SkColorType: | 430 case kRGB_565_SkColorType: |
| 431 return kRGB_565_GrPixelConfig; | 431 return kRGB_565_GrPixelConfig; |
| 432 case kARGB_4444_SkColorType: | 432 case kARGB_4444_SkColorType: |
| 433 return kRGBA_4444_GrPixelConfig; | 433 return kRGBA_4444_GrPixelConfig; |
| 434 case kRGBA_8888_SkColorType: | 434 case kRGBA_8888_SkColorType: |
| 435 return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB()) | 435 return (kSRGB_SkColorProfileType == pt && caps.srgbSupport()) |
| 436 ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; | 436 ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; |
| 437 case kBGRA_8888_SkColorType: | 437 case kBGRA_8888_SkColorType: |
| 438 return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB()) | 438 return (kSRGB_SkColorProfileType == pt && caps.srgbSupport()) |
| 439 ? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig; | 439 ? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig; |
| 440 case kIndex_8_SkColorType: | 440 case kIndex_8_SkColorType: |
| 441 return kIndex_8_GrPixelConfig; | 441 return kIndex_8_GrPixelConfig; |
| 442 case kGray_8_SkColorType: | 442 case kGray_8_SkColorType: |
| 443 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu | 443 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu |
| 444 case kRGBA_F16_SkColorType: | 444 case kRGBA_F16_SkColorType: |
| 445 return kRGBA_half_GrPixelConfig; | 445 return kRGBA_half_GrPixelConfig; |
| 446 } | 446 } |
| 447 SkASSERT(0); // shouldn't get here | 447 SkASSERT(0); // shouldn't get here |
| 448 return kUnknown_GrPixelConfig; | 448 return kUnknown_GrPixelConfig; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 SkErrorInternals::SetError( kInvalidPaint_SkError, | 768 SkErrorInternals::SetError( kInvalidPaint_SkError, |
| 769 "Sorry, I don't understand the filtering
" | 769 "Sorry, I don't understand the filtering
" |
| 770 "mode you asked for. Falling back to " | 770 "mode you asked for. Falling back to " |
| 771 "MIPMaps."); | 771 "MIPMaps."); |
| 772 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 772 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 773 break; | 773 break; |
| 774 | 774 |
| 775 } | 775 } |
| 776 return textureFilterMode; | 776 return textureFilterMode; |
| 777 } | 777 } |
| OLD | NEW |