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