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

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

Issue 2173513002: Cleanup of code that converts from GPU-backed resources to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@fix-sync
Patch Set: Created 4 years, 5 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
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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 return kIndex_8_GrPixelConfig; 455 return kIndex_8_GrPixelConfig;
456 case kGray_8_SkColorType: 456 case kGray_8_SkColorType:
457 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu 457 return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu
458 case kRGBA_F16_SkColorType: 458 case kRGBA_F16_SkColorType:
459 return kRGBA_half_GrPixelConfig; 459 return kRGBA_half_GrPixelConfig;
460 } 460 }
461 SkASSERT(0); // shouldn't get here 461 SkASSERT(0); // shouldn't get here
462 return kUnknown_GrPixelConfig; 462 return kUnknown_GrPixelConfig;
463 } 463 }
464 464
465 bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut, 465 bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) {
466 sk_sp<SkColorSpace>* csOut) {
467 SkColorType ct; 466 SkColorType ct;
468 sk_sp<SkColorSpace> cs = nullptr;
469 switch (config) { 467 switch (config) {
470 case kAlpha_8_GrPixelConfig: 468 case kAlpha_8_GrPixelConfig:
471 ct = kAlpha_8_SkColorType; 469 ct = kAlpha_8_SkColorType;
472 break; 470 break;
473 case kIndex_8_GrPixelConfig: 471 case kIndex_8_GrPixelConfig:
474 ct = kIndex_8_SkColorType; 472 ct = kIndex_8_SkColorType;
475 break; 473 break;
476 case kRGB_565_GrPixelConfig: 474 case kRGB_565_GrPixelConfig:
477 ct = kRGB_565_SkColorType; 475 ct = kRGB_565_SkColorType;
478 break; 476 break;
479 case kRGBA_4444_GrPixelConfig: 477 case kRGBA_4444_GrPixelConfig:
480 ct = kARGB_4444_SkColorType; 478 ct = kARGB_4444_SkColorType;
481 break; 479 break;
482 case kRGBA_8888_GrPixelConfig: 480 case kRGBA_8888_GrPixelConfig:
483 ct = kRGBA_8888_SkColorType; 481 ct = kRGBA_8888_SkColorType;
484 break; 482 break;
485 case kBGRA_8888_GrPixelConfig: 483 case kBGRA_8888_GrPixelConfig:
486 ct = kBGRA_8888_SkColorType; 484 ct = kBGRA_8888_SkColorType;
487 break; 485 break;
488 case kSRGBA_8888_GrPixelConfig: 486 case kSRGBA_8888_GrPixelConfig:
489 ct = kRGBA_8888_SkColorType; 487 ct = kRGBA_8888_SkColorType;
490 cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
491 break; 488 break;
492 case kSBGRA_8888_GrPixelConfig: 489 case kSBGRA_8888_GrPixelConfig:
493 ct = kBGRA_8888_SkColorType; 490 ct = kBGRA_8888_SkColorType;
494 cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
495 break; 491 break;
496 case kRGBA_half_GrPixelConfig: 492 case kRGBA_half_GrPixelConfig:
497 ct = kRGBA_F16_SkColorType; 493 ct = kRGBA_F16_SkColorType;
498 break; 494 break;
499 default: 495 default:
500 return false; 496 return false;
501 } 497 }
502 if (ctOut) { 498 if (ctOut) {
503 *ctOut = ct; 499 *ctOut = ct;
504 } 500 }
505 if (csOut) {
506 *csOut = cs;
507 }
508 return true; 501 return true;
509 } 502 }
510 503
511 //////////////////////////////////////////////////////////////////////////////// //////////////// 504 //////////////////////////////////////////////////////////////////////////////// ////////////////
512 505
513 static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi tiveIsSrc) { 506 static inline bool blend_requires_shader(const SkXfermode::Mode mode, bool primi tiveIsSrc) {
514 if (primitiveIsSrc) { 507 if (primitiveIsSrc) {
515 return SkXfermode::kSrc_Mode != mode; 508 return SkXfermode::kSrc_Mode != mode;
516 } else { 509 } else {
517 return SkXfermode::kDst_Mode != mode; 510 return SkXfermode::kDst_Mode != mode;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp); 727 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp);
735 } 728 }
736 729
737 return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), al lowSRGBInputs, 730 return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), al lowSRGBInputs,
738 grPaint); 731 grPaint);
739 } 732 }
740 733
741 734
742 //////////////////////////////////////////////////////////////////////////////// //////////////// 735 //////////////////////////////////////////////////////////////////////////////// ////////////////
743 736
744 SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque,
745 sk_sp<SkColorSpace> colorSpace) {
746 #ifdef SK_DEBUG
747 const GrSurfaceDesc& desc = tex->desc();
748 SkASSERT(w <= desc.fWidth);
749 SkASSERT(h <= desc.fHeight);
750 #endif
751 const GrPixelConfig config = tex->config();
752 SkColorType ct = kUnknown_SkColorType;
753 SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
754 if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) {
755 ct = kUnknown_SkColorType;
756 }
757 return SkImageInfo::Make(w, h, ct, at, std::move(colorSpace));
758 }
759
760 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain tFilterQuality, 737 GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality pain tFilterQuality,
761 const SkMatrix& view M, 738 const SkMatrix& view M,
762 const SkMatrix& loca lM, 739 const SkMatrix& loca lM,
763 bool* doBicubic) { 740 bool* doBicubic) {
764 *doBicubic = false; 741 *doBicubic = false;
765 GrTextureParams::FilterMode textureFilterMode; 742 GrTextureParams::FilterMode textureFilterMode;
766 switch (paintFilterQuality) { 743 switch (paintFilterQuality) {
767 case kNone_SkFilterQuality: 744 case kNone_SkFilterQuality:
768 textureFilterMode = GrTextureParams::kNone_FilterMode; 745 textureFilterMode = GrTextureParams::kNone_FilterMode;
769 break; 746 break;
(...skipping 21 matching lines...) Expand all
791 SkErrorInternals::SetError( kInvalidPaint_SkError, 768 SkErrorInternals::SetError( kInvalidPaint_SkError,
792 "Sorry, I don't understand the filtering " 769 "Sorry, I don't understand the filtering "
793 "mode you asked for. Falling back to " 770 "mode you asked for. Falling back to "
794 "MIPMaps."); 771 "MIPMaps.");
795 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 772 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
796 break; 773 break;
797 774
798 } 775 }
799 return textureFilterMode; 776 return textureFilterMode;
800 } 777 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/SkGrPriv.h » ('j') | src/image/SkImage_Gpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698