| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 origColors += desc.fCount; | 134 origColors += desc.fCount; |
| 135 *origColors = desc.fColors[desc.fCount - 1]; | 135 *origColors = desc.fColors[desc.fCount - 1]; |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Convert our SkColor colors to SkColor4f as well | 138 // Convert our SkColor colors to SkColor4f as well |
| 139 for (int i = 0; i < fColorCount; ++i) { | 139 for (int i = 0; i < fColorCount; ++i) { |
| 140 fOrigColors4f[i] = SkColor4f::FromColor(fOrigColors[i]); | 140 fOrigColors4f[i] = SkColor4f::FromColor(fOrigColors[i]); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Color space refers to fColors4f, so it's always linear gamma | 143 // Color space refers to fColors4f, so it's always linear gamma |
| 144 fColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)->makeLin
earGamma(); | 144 fColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); |
| 145 } else { | 145 } else { |
| 146 SkASSERT(desc.fColors4f && desc.fColorSpace && desc.fColorSpace->gammaIs
Linear()); | 146 SkASSERT(desc.fColors4f && desc.fColorSpace && desc.fColorSpace->gammaIs
Linear()); |
| 147 | 147 |
| 148 // Now copy over the colors, adding the dummies as needed | 148 // Now copy over the colors, adding the dummies as needed |
| 149 SkColor4f* origColors = fOrigColors4f; | 149 SkColor4f* origColors = fOrigColors4f; |
| 150 if (dummyFirst) { | 150 if (dummyFirst) { |
| 151 *origColors++ = desc.fColors4f[0]; | 151 *origColors++ = desc.fColors4f[0]; |
| 152 } | 152 } |
| 153 memcpy(origColors, desc.fColors4f, desc.fCount * sizeof(SkColor4f)); | 153 memcpy(origColors, desc.fColors4f, desc.fCount * sizeof(SkColor4f)); |
| 154 if (dummyLast) { | 154 if (dummyLast) { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 // allocate and populate the bitmap's data directly. | 676 // allocate and populate the bitmap's data directly. |
| 677 | 677 |
| 678 SkImageInfo info; | 678 SkImageInfo info; |
| 679 switch (bitmapType) { | 679 switch (bitmapType) { |
| 680 case GradientBitmapType::kSRGB: | 680 case GradientBitmapType::kSRGB: |
| 681 info = SkImageInfo::Make(kCache32Count, 1, kRGBA_8888_SkColo
rType, | 681 info = SkImageInfo::Make(kCache32Count, 1, kRGBA_8888_SkColo
rType, |
| 682 kPremul_SkAlphaType, | 682 kPremul_SkAlphaType, |
| 683 SkColorSpace::NewNamed(SkColorSpace
::kSRGB_Named)); | 683 SkColorSpace::NewNamed(SkColorSpace
::kSRGB_Named)); |
| 684 break; | 684 break; |
| 685 case GradientBitmapType::kHalfFloat: | 685 case GradientBitmapType::kHalfFloat: |
| 686 info = SkImageInfo::Make(kCache32Count, 1, kRGBA_F16_SkColor
Type, | 686 info = SkImageInfo::Make( |
| 687 kPremul_SkAlphaType, | 687 kCache32Count, 1, kRGBA_F16_SkColorType, kPremul_SkAlpha
Type, |
| 688 SkColorSpace::NewNamed(SkColorSpace
::kSRGB_Named) | 688 SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named))
; |
| 689 ->makeLinearGamma()); | |
| 690 break; | 689 break; |
| 691 default: | 690 default: |
| 692 SkFAIL("Unexpected bitmap type"); | 691 SkFAIL("Unexpected bitmap type"); |
| 693 return; | 692 return; |
| 694 } | 693 } |
| 695 bitmap->allocPixels(info); | 694 bitmap->allocPixels(info); |
| 696 this->initLinearBitmap(bitmap); | 695 this->initLinearBitmap(bitmap); |
| 697 } | 696 } |
| 698 gCache->add(storage.get(), size, *bitmap); | 697 gCache->add(storage.get(), size, *bitmap); |
| 699 } | 698 } |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 (*stops)[i] = stop; | 1613 (*stops)[i] = stop; |
| 1615 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1614 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1616 } | 1615 } |
| 1617 } | 1616 } |
| 1618 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1617 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1619 | 1618 |
| 1620 return outColors; | 1619 return outColors; |
| 1621 } | 1620 } |
| 1622 | 1621 |
| 1623 #endif | 1622 #endif |
| OLD | NEW |