| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 #include "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
| 9 #include "SkGradientShaderPriv.h" | 9 #include "SkGradientShaderPriv.h" |
| 10 #include "SkHalf.h" | 10 #include "SkHalf.h" |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 | 1491 |
| 1492 SkGradientShaderBase::GradientBitmapType bitmapType = | 1492 SkGradientShaderBase::GradientBitmapType bitmapType = |
| 1493 SkGradientShaderBase::GradientBitmapType::kLegacy; | 1493 SkGradientShaderBase::GradientBitmapType::kLegacy; |
| 1494 if (args.fGammaCorrect) { | 1494 if (args.fGammaCorrect) { |
| 1495 // Try to use F16 if we can | 1495 // Try to use F16 if we can |
| 1496 if (args.fContext->caps()->isConfigTexturable(kRGBA_half_GrPixel
Config)) { | 1496 if (args.fContext->caps()->isConfigTexturable(kRGBA_half_GrPixel
Config)) { |
| 1497 bitmapType = SkGradientShaderBase::GradientBitmapType::kHalf
Float; | 1497 bitmapType = SkGradientShaderBase::GradientBitmapType::kHalf
Float; |
| 1498 } else if (args.fContext->caps()->isConfigTexturable(kSRGBA_8888
_GrPixelConfig)) { | 1498 } else if (args.fContext->caps()->isConfigTexturable(kSRGBA_8888
_GrPixelConfig)) { |
| 1499 bitmapType = SkGradientShaderBase::GradientBitmapType::kSRGB
; | 1499 bitmapType = SkGradientShaderBase::GradientBitmapType::kSRGB
; |
| 1500 } else { | 1500 } else { |
| 1501 // This should never happen, but just fall back to legacy be
havior | 1501 // This can happen, but only if someone explicitly creates a
n unsupported |
| 1502 SkDEBUGFAIL("Requesting a gamma-correct gradient FP without
F16 or sRGB"); | 1502 // (eg sRGB) surface. Just fall back to legacy behavior. |
| 1503 } | 1503 } |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 SkBitmap bitmap; | 1506 SkBitmap bitmap; |
| 1507 shader.getGradientTableBitmap(&bitmap, bitmapType); | 1507 shader.getGradientTableBitmap(&bitmap, bitmapType); |
| 1508 | 1508 |
| 1509 GrTextureStripAtlas::Desc desc; | 1509 GrTextureStripAtlas::Desc desc; |
| 1510 desc.fWidth = bitmap.width(); | 1510 desc.fWidth = bitmap.width(); |
| 1511 desc.fHeight = 32; | 1511 desc.fHeight = 32; |
| 1512 desc.fRowHeight = bitmap.height(); | 1512 desc.fRowHeight = bitmap.height(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 (*stops)[i] = stop; | 1614 (*stops)[i] = stop; |
| 1615 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1615 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1616 } | 1616 } |
| 1617 } | 1617 } |
| 1618 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1618 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1619 | 1619 |
| 1620 return outColors; | 1620 return outColors; |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 #endif | 1623 #endif |
| OLD | NEW |