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" |
11 | 11 |
12 #include "GrCaps.h" | 12 #include "GrCaps.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrDrawContext.h" | 14 #include "GrDrawContext.h" |
15 #include "GrGpuResourcePriv.h" | 15 #include "GrGpuResourcePriv.h" |
16 #include "GrImageIDTextureAdjuster.h" | 16 #include "GrImageIDTextureAdjuster.h" |
17 #include "GrTextureParamsAdjuster.h" | 17 #include "GrTextureParamsAdjuster.h" |
18 #include "GrTexturePriv.h" | 18 #include "GrTexturePriv.h" |
19 #include "GrTypes.h" | 19 #include "GrTypes.h" |
20 #include "GrXferProcessor.h" | 20 #include "GrXferProcessor.h" |
21 #include "GrYUVProvider.h" | 21 #include "GrYUVProvider.h" |
22 | 22 |
23 #include "SkColorFilter.h" | 23 #include "SkColorFilter.h" |
24 #include "SkConfig8888.h" | 24 #include "SkConfig8888.h" |
25 #include "SkCanvas.h" | 25 #include "SkCanvas.h" |
26 #include "SkColorSpaceXform.h" | |
27 #include "SkData.h" | 26 #include "SkData.h" |
28 #include "SkErrorInternals.h" | 27 #include "SkErrorInternals.h" |
29 #include "SkMessageBus.h" | 28 #include "SkMessageBus.h" |
30 #include "SkMipMap.h" | 29 #include "SkMipMap.h" |
31 #include "SkPixelRef.h" | 30 #include "SkPixelRef.h" |
32 #include "SkPM4fPriv.h" | 31 #include "SkPM4fPriv.h" |
33 #include "SkResourceCache.h" | 32 #include "SkResourceCache.h" |
34 #include "SkTemplates.h" | 33 #include "SkTemplates.h" |
35 #include "SkYUVPlanesCache.h" | 34 #include "SkYUVPlanesCache.h" |
36 #include "effects/GrBicubicEffect.h" | 35 #include "effects/GrBicubicEffect.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 GrDrawContext* dc, | 522 GrDrawContext* dc, |
524 const SkPaint& skPaint, | 523 const SkPaint& skPaint, |
525 const SkMatrix& viewM, | 524 const SkMatrix& viewM, |
526 sk_sp<GrFragmentProcessor>* shaderPro
cessor, | 525 sk_sp<GrFragmentProcessor>* shaderPro
cessor, |
527 SkXfermode::Mode* primColorMode, | 526 SkXfermode::Mode* primColorMode, |
528 bool primitiveIsSrc, | 527 bool primitiveIsSrc, |
529 GrPaint* grPaint) { | 528 GrPaint* grPaint) { |
530 grPaint->setAntiAlias(skPaint.isAntiAlias()); | 529 grPaint->setAntiAlias(skPaint.isAntiAlias()); |
531 grPaint->setAllowSRGBInputs(dc->isGammaCorrect()); | 530 grPaint->setAllowSRGBInputs(dc->isGammaCorrect()); |
532 | 531 |
533 GrColor4f origColor; | 532 // Raw translation of the SkPaint color to our 4f format: |
| 533 GrColor4f origColor = GrColor4f::FromGrColor(SkColorToUnpremulGrColor(skPain
t.getColor())); |
534 | 534 |
535 // Linearize, if the color is meant to be in sRGB gamma: | 535 // Linearize, if the color is meant to be in sRGB gamma: |
536 if (dc->isGammaCorrect()) { | 536 if (dc->isGammaCorrect()) { |
537 SkColorSpaceXform* xform = dc->getColorXformFromSRGB(); | 537 origColor.fRGBA[0] = exact_srgb_to_linear(origColor.fRGBA[0]); |
538 SkASSERT(xform); | 538 origColor.fRGBA[1] = exact_srgb_to_linear(origColor.fRGBA[1]); |
| 539 origColor.fRGBA[2] = exact_srgb_to_linear(origColor.fRGBA[2]); |
539 | 540 |
540 // FIXME (msarett): Support BGRA inputs to SkColorSpaceXform? | 541 if (dc->getColorXformFromSRGB()) { |
541 uint32_t rgba = SkSwizzle_RB(skPaint.getColor()); | 542 origColor = dc->getColorXformFromSRGB()->apply(origColor); |
542 xform->apply(&origColor, &rgba, 1, SkColorSpaceXform::kRGBA_F32_ColorFor
mat, | 543 } |
543 kUnpremul_SkAlphaType); | |
544 } else { | |
545 // Raw translation of the SkPaint color to our 4f format: | |
546 origColor = GrColor4f::FromGrColor(SkColorToUnpremulGrColor(skPaint.getC
olor())); | |
547 } | 544 } |
548 | 545 |
549 // Setup the initial color considering the shader, the SkPaint color, and th
e presence or not | 546 // Setup the initial color considering the shader, the SkPaint color, and th
e presence or not |
550 // of per-vertex colors. | 547 // of per-vertex colors. |
551 sk_sp<GrFragmentProcessor> shaderFP; | 548 sk_sp<GrFragmentProcessor> shaderFP; |
552 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc))
{ | 549 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc))
{ |
553 if (shaderProcessor) { | 550 if (shaderProcessor) { |
554 shaderFP = *shaderProcessor; | 551 shaderFP = *shaderProcessor; |
555 } else if (const SkShader* shader = skPaint.getShader()) { | 552 } else if (const SkShader* shader = skPaint.getShader()) { |
556 shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &
viewM, nullptr, | 553 shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &
viewM, nullptr, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 SkErrorInternals::SetError( kInvalidPaint_SkError, | 774 SkErrorInternals::SetError( kInvalidPaint_SkError, |
778 "Sorry, I don't understand the filtering
" | 775 "Sorry, I don't understand the filtering
" |
779 "mode you asked for. Falling back to " | 776 "mode you asked for. Falling back to " |
780 "MIPMaps."); | 777 "MIPMaps."); |
781 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 778 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
782 break; | 779 break; |
783 | 780 |
784 } | 781 } |
785 return textureFilterMode; | 782 return textureFilterMode; |
786 } | 783 } |
OLD | NEW |