Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: src/gpu/SkGr.cpp

Issue 2074103004: Revert of More removal of SkColorProfileType... (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrSurface.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 return kIndex_8_GrPixelConfig; 446 return kIndex_8_GrPixelConfig;
447 case kGray_8_SkColorType: 447 case kGray_8_SkColorType:
448 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu 448 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu
449 case kRGBA_F16_SkColorType: 449 case kRGBA_F16_SkColorType:
450 return kRGBA_half_GrPixelConfig; 450 return kRGBA_half_GrPixelConfig;
451 } 451 }
452 SkASSERT(0); // shouldn't get here 452 SkASSERT(0); // shouldn't get here
453 return kUnknown_GrPixelConfig; 453 return kUnknown_GrPixelConfig;
454 } 454 }
455 455
456 bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut, 456 bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut,
457 sk_sp<SkColorSpace>* csOut) { 457 SkColorProfileType* ptOut) {
458 SkColorType ct; 458 SkColorType ct;
459 sk_sp<SkColorSpace> cs = nullptr; 459 SkColorProfileType pt = kLinear_SkColorProfileType;
460 switch (config) { 460 switch (config) {
461 case kAlpha_8_GrPixelConfig: 461 case kAlpha_8_GrPixelConfig:
462 ct = kAlpha_8_SkColorType; 462 ct = kAlpha_8_SkColorType;
463 break; 463 break;
464 case kIndex_8_GrPixelConfig: 464 case kIndex_8_GrPixelConfig:
465 ct = kIndex_8_SkColorType; 465 ct = kIndex_8_SkColorType;
466 break; 466 break;
467 case kRGB_565_GrPixelConfig: 467 case kRGB_565_GrPixelConfig:
468 ct = kRGB_565_SkColorType; 468 ct = kRGB_565_SkColorType;
469 break; 469 break;
470 case kRGBA_4444_GrPixelConfig: 470 case kRGBA_4444_GrPixelConfig:
471 ct = kARGB_4444_SkColorType; 471 ct = kARGB_4444_SkColorType;
472 break; 472 break;
473 case kRGBA_8888_GrPixelConfig: 473 case kRGBA_8888_GrPixelConfig:
474 ct = kRGBA_8888_SkColorType; 474 ct = kRGBA_8888_SkColorType;
475 break; 475 break;
476 case kBGRA_8888_GrPixelConfig: 476 case kBGRA_8888_GrPixelConfig:
477 ct = kBGRA_8888_SkColorType; 477 ct = kBGRA_8888_SkColorType;
478 break; 478 break;
479 case kSRGBA_8888_GrPixelConfig: 479 case kSRGBA_8888_GrPixelConfig:
480 ct = kRGBA_8888_SkColorType; 480 ct = kRGBA_8888_SkColorType;
481 cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 481 pt = kSRGB_SkColorProfileType;
482 break; 482 break;
483 case kSBGRA_8888_GrPixelConfig: 483 case kSBGRA_8888_GrPixelConfig:
484 ct = kBGRA_8888_SkColorType; 484 ct = kBGRA_8888_SkColorType;
485 cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 485 pt = kSRGB_SkColorProfileType;
486 break; 486 break;
487 case kRGBA_half_GrPixelConfig: 487 case kRGBA_half_GrPixelConfig:
488 ct = kRGBA_F16_SkColorType; 488 ct = kRGBA_F16_SkColorType;
489 break; 489 break;
490 default: 490 default:
491 return false; 491 return false;
492 } 492 }
493 if (ctOut) { 493 if (ctOut) {
494 *ctOut = ct; 494 *ctOut = ct;
495 } 495 }
496 if (csOut) { 496 if (ptOut) {
497 *csOut = cs; 497 *ptOut = pt;
498 } 498 }
499 return true; 499 return true;
500 } 500 }
501 501
502 //////////////////////////////////////////////////////////////////////////////// //////////////// 502 //////////////////////////////////////////////////////////////////////////////// ////////////////
503 503
504 static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi tiveIsSrc) { 504 static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi tiveIsSrc) {
505 if (primitiveIsSrc) { 505 if (primitiveIsSrc) {
506 return SkXfermode::kSrc_Mode != mode; 506 return SkXfermode::kSrc_Mode != mode;
507 } else { 507 } else {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 717
718 //////////////////////////////////////////////////////////////////////////////// //////////////// 718 //////////////////////////////////////////////////////////////////////////////// ////////////////
719 719
720 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { 720 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) {
721 #ifdef SK_DEBUG 721 #ifdef SK_DEBUG
722 const GrSurfaceDesc& desc = tex->desc(); 722 const GrSurfaceDesc& desc = tex->desc();
723 SkASSERT(w <= desc.fWidth); 723 SkASSERT(w <= desc.fWidth);
724 SkASSERT(h <= desc.fHeight); 724 SkASSERT(h <= desc.fHeight);
725 #endif 725 #endif
726 const GrPixelConfig config = tex->config(); 726 const GrPixelConfig config = tex->config();
727 SkColorType ct = kUnknown_SkColorType; 727 SkColorType ct;
728 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 728 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
729 if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) { 729 if (!GrPixelConfig2ColorAndProfileType(config, &ct, nullptr)) {
730 ct = kUnknown_SkColorType; 730 ct = kUnknown_SkColorType;
731 } 731 }
732 return SkImageInfo::Make(w, h, ct, at); 732 return SkImageInfo::Make(w, h, ct, at);
733 } 733 }
734 734
735 735
736 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) { 736 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) {
737 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); 737 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
738 dst->setInfo(info); 738 dst->setInfo(info);
739 dst->setPixelRef(new SkGrPixelRef(info, src))->unref(); 739 dst->setPixelRef(new SkGrPixelRef(info, src))->unref();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 SkErrorInternals::SetError( kInvalidPaint_SkError, 773 SkErrorInternals::SetError( kInvalidPaint_SkError,
774 "Sorry, I don't understand the filtering " 774 "Sorry, I don't understand the filtering "
775 "mode you asked for. Falling back to " 775 "mode you asked for. Falling back to "
776 "MIPMaps."); 776 "MIPMaps.");
777 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 777 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
778 break; 778 break;
779 779
780 } 780 }
781 return textureFilterMode; 781 return textureFilterMode;
782 } 782 }
OLDNEW
« no previous file with comments | « src/gpu/GrSurface.cpp ('k') | src/gpu/SkGrPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698