Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/core/SkLightingShader.cpp

Issue 1343123005: use SkBitmapProvider for shader-context (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: restore privacy Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698