| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 SkMatrix diffTotalInv; | 657 SkMatrix diffTotalInv; |
| 658 // computeTotalInverse was called in SkShader::createContext so we know it w
ill succeed | 658 // computeTotalInverse was called in SkShader::createContext so we know it w
ill succeed |
| 659 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv)); | 659 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv)); |
| 660 | 660 |
| 661 SkMatrix normTotalInv; | 661 SkMatrix normTotalInv; |
| 662 if (!this->computeNormTotalInverse(rec, &normTotalInv)) { | 662 if (!this->computeNormTotalInverse(rec, &normTotalInv)) { |
| 663 return nullptr; | 663 return nullptr; |
| 664 } | 664 } |
| 665 | 665 |
| 666 void* diffuseStateStorage = (char*)storage + sizeof(LightingShaderContext); | 666 void* diffuseStateStorage = (char*)storage + sizeof(LightingShaderContext); |
| 667 SkBitmapProcState* diffuseState = new (diffuseStateStorage) SkBitmapProcStat
e; | 667 SkBitmapProcState* diffuseState = new (diffuseStateStorage) SkBitmapProcStat
e(fDiffuseMap, |
| 668 SkShader::kClamp_TileMode, SkShade
r::kClamp_TileMode); |
| 668 SkASSERT(diffuseState); | 669 SkASSERT(diffuseState); |
| 669 | |
| 670 diffuseState->fTileModeX = SkShader::kClamp_TileMode; | |
| 671 diffuseState->fTileModeY = SkShader::kClamp_TileMode; | |
| 672 diffuseState->fOrigBitmap = fDiffuseMap; | |
| 673 if (!diffuseState->chooseProcs(diffTotalInv, *rec.fPaint)) { | 670 if (!diffuseState->chooseProcs(diffTotalInv, *rec.fPaint)) { |
| 674 diffuseState->~SkBitmapProcState(); | 671 diffuseState->~SkBitmapProcState(); |
| 675 return nullptr; | 672 return nullptr; |
| 676 } | 673 } |
| 677 | 674 |
| 678 void* normalStateStorage = (char*)storage + sizeof(LightingShaderContext) +
sizeof(SkBitmapProcState); | 675 void* normalStateStorage = (char*)storage + sizeof(LightingShaderContext) +
sizeof(SkBitmapProcState); |
| 679 SkBitmapProcState* normalState = new (normalStateStorage) SkBitmapProcState; | 676 SkBitmapProcState* normalState = new (normalStateStorage) SkBitmapProcState(
fNormalMap, |
| 677 SkShader::kClamp_TileMode, SkShader:
:kClamp_TileMode); |
| 680 SkASSERT(normalState); | 678 SkASSERT(normalState); |
| 681 | |
| 682 normalState->fTileModeX = SkShader::kClamp_TileMode; | |
| 683 normalState->fTileModeY = SkShader::kClamp_TileMode; | |
| 684 normalState->fOrigBitmap = fNormalMap; | |
| 685 if (!normalState->chooseProcs(normTotalInv, *rec.fPaint)) { | 679 if (!normalState->chooseProcs(normTotalInv, *rec.fPaint)) { |
| 686 diffuseState->~SkBitmapProcState(); | 680 diffuseState->~SkBitmapProcState(); |
| 687 normalState->~SkBitmapProcState(); | 681 normalState->~SkBitmapProcState(); |
| 688 return nullptr; | 682 return nullptr; |
| 689 } | 683 } |
| 690 | 684 |
| 691 return new (storage) LightingShaderContext(*this, rec, diffuseState, normalS
tate); | 685 return new (storage) LightingShaderContext(*this, rec, diffuseState, normalS
tate); |
| 692 } | 686 } |
| 693 | 687 |
| 694 /////////////////////////////////////////////////////////////////////////////// | 688 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 25 matching lines...) Expand all Loading... |
| 720 normLocalM); | 714 normLocalM); |
| 721 } | 715 } |
| 722 | 716 |
| 723 /////////////////////////////////////////////////////////////////////////////// | 717 /////////////////////////////////////////////////////////////////////////////// |
| 724 | 718 |
| 725 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 719 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
| 726 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 720 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
| 727 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 728 | 722 |
| 729 /////////////////////////////////////////////////////////////////////////////// | 723 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |