OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #ifndef SkLinearBitmapPipeline_sampler_DEFINED | 8 #ifndef SkLinearBitmapPipeline_sampler_DEFINED |
9 #define SkLinearBitmapPipeline_sampler_DEFINED | 9 #define SkLinearBitmapPipeline_sampler_DEFINED |
10 | 10 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 Next* const fNext; | 438 Next* const fNext; |
439 Accessor fAccessor; | 439 Accessor fAccessor; |
440 }; | 440 }; |
441 | 441 |
442 // From an edgeType, the integer value of a pixel vs, and the integer value of t
he extreme edge | 442 // From an edgeType, the integer value of a pixel vs, and the integer value of t
he extreme edge |
443 // vMax, take the point which might be off the tile by one pixel and either wrap
it or pin it to | 443 // vMax, take the point which might be off the tile by one pixel and either wrap
it or pin it to |
444 // generate the right pixel. The value vs is on the interval [-1, vMax + 1]. It
produces a value | 444 // generate the right pixel. The value vs is on the interval [-1, vMax + 1]. It
produces a value |
445 // on the interval [0, vMax]. | 445 // on the interval [0, vMax]. |
446 // Note: vMax is not width or height, but width-1 or height-1 because it is the
largest valid pixel. | 446 // Note: vMax is not width or height, but width-1 or height-1 because it is the
largest valid pixel. |
447 static inline int adjust_edge(SkShader::TileMode edgeType, int vs, int vMax) { | 447 static inline int adjust_edge(SkShader::TileMode edgeType, int vs, int vMax) { |
448 SkASSERT(-1 <= vs && vs <= vMax + 1) | 448 SkASSERT(-1 <= vs && vs <= vMax + 1); |
449 switch (edgeType) { | 449 switch (edgeType) { |
450 case SkShader::kClamp_TileMode: | 450 case SkShader::kClamp_TileMode: |
451 case SkShader::kMirror_TileMode: | 451 case SkShader::kMirror_TileMode: |
452 vs = std::max(vs, 0); | 452 vs = std::max(vs, 0); |
453 vs = std::min(vs, vMax); | 453 vs = std::min(vs, vMax); |
454 break; | 454 break; |
455 case SkShader::kRepeat_TileMode: | 455 case SkShader::kRepeat_TileMode: |
456 vs = (vs <= vMax) ? vs : 0; | 456 vs = (vs <= vMax) ? vs : 0; |
457 vs = (vs >= 0) ? vs : vMax; | 457 vs = (vs >= 0) ? vs : vMax; |
458 break; | 458 break; |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 const SkShader::TileMode fXEdgeType; | 1027 const SkShader::TileMode fXEdgeType; |
1028 const int fXMax; | 1028 const int fXMax; |
1029 const SkShader::TileMode fYEdgeType; | 1029 const SkShader::TileMode fYEdgeType; |
1030 const int fYMax; | 1030 const int fYMax; |
1031 Accessor fAccessor; | 1031 Accessor fAccessor; |
1032 }; | 1032 }; |
1033 | 1033 |
1034 } // namespace | 1034 } // namespace |
1035 | 1035 |
1036 #endif // SkLinearBitmapPipeline_sampler_DEFINED | 1036 #endif // SkLinearBitmapPipeline_sampler_DEFINED |
OLD | NEW |