OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkBitmapProcState.h" | 8 #include "SkBitmapProcState.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkEmptyShader.h" | 10 #include "SkEmptyShader.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // computeTotalInverse was called in SkShader::createContext so we know it w
ill succeed | 670 // computeTotalInverse was called in SkShader::createContext so we know it w
ill succeed |
671 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv)); | 671 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv)); |
672 | 672 |
673 SkMatrix normTotalInv; | 673 SkMatrix normTotalInv; |
674 if (!this->computeNormTotalInverse(rec, &normTotalInv)) { | 674 if (!this->computeNormTotalInverse(rec, &normTotalInv)) { |
675 return nullptr; | 675 return nullptr; |
676 } | 676 } |
677 | 677 |
678 void* diffuseStateStorage = (char*)storage + sizeof(LightingShaderContext); | 678 void* diffuseStateStorage = (char*)storage + sizeof(LightingShaderContext); |
679 SkBitmapProcState* diffuseState = new (diffuseStateStorage) SkBitmapProcStat
e(fDiffuseMap, | 679 SkBitmapProcState* diffuseState = new (diffuseStateStorage) SkBitmapProcStat
e(fDiffuseMap, |
680 SkShader::kClamp_TileMode, SkShade
r::kClamp_TileMode); | 680 SkShader::kClamp_TileMode, SkShade
r::kClamp_TileMode, |
| 681 SkMipMap::De
duceTreatment(rec)); |
681 SkASSERT(diffuseState); | 682 SkASSERT(diffuseState); |
682 if (!diffuseState->setup(diffTotalInv, *rec.fPaint)) { | 683 if (!diffuseState->setup(diffTotalInv, *rec.fPaint)) { |
683 diffuseState->~SkBitmapProcState(); | 684 diffuseState->~SkBitmapProcState(); |
684 return nullptr; | 685 return nullptr; |
685 } | 686 } |
686 | 687 |
687 void* normalStateStorage = (char*)storage + sizeof(LightingShaderContext) +
sizeof(SkBitmapProcState); | 688 void* normalStateStorage = (char*)storage + sizeof(LightingShaderContext) +
sizeof(SkBitmapProcState); |
688 SkBitmapProcState* normalState = new (normalStateStorage) SkBitmapProcState(
fNormalMap, | 689 SkBitmapProcState* normalState = new (normalStateStorage) SkBitmapProcState(
fNormalMap, |
689 SkShader::kClamp_TileMode, SkShader:
:kClamp_TileMode); | 690 SkShader::kClamp_TileMode, SkShader:
:kClamp_TileMode, |
| 691 SkMipMap::De
duceTreatment(rec)); |
690 SkASSERT(normalState); | 692 SkASSERT(normalState); |
691 if (!normalState->setup(normTotalInv, *rec.fPaint)) { | 693 if (!normalState->setup(normTotalInv, *rec.fPaint)) { |
692 diffuseState->~SkBitmapProcState(); | 694 diffuseState->~SkBitmapProcState(); |
693 normalState->~SkBitmapProcState(); | 695 normalState->~SkBitmapProcState(); |
694 return nullptr; | 696 return nullptr; |
695 } | 697 } |
696 | 698 |
697 return new (storage) LightingShaderContext(*this, rec, diffuseState, normalS
tate); | 699 return new (storage) LightingShaderContext(*this, rec, diffuseState, normalS
tate); |
698 } | 700 } |
699 | 701 |
(...skipping 26 matching lines...) Expand all Loading... |
726 invNormRotation, diffLocalM, normLoc
alM); | 728 invNormRotation, diffLocalM, normLoc
alM); |
727 } | 729 } |
728 | 730 |
729 /////////////////////////////////////////////////////////////////////////////// | 731 /////////////////////////////////////////////////////////////////////////////// |
730 | 732 |
731 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 733 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
732 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 734 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
733 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 735 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
734 | 736 |
735 /////////////////////////////////////////////////////////////////////////////// | 737 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |