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

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

Issue 1759323002: Revert of enforce 16byte alignment in shader contexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkEmptyShader.h ('k') | src/core/SkLocalMatrixShader.h » ('j') | 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 bool isOpaque() const override; 73 bool isOpaque() const override;
74 74
75 #if SK_SUPPORT_GPU 75 #if SK_SUPPORT_GPU
76 const GrFragmentProcessor* asFragmentProcessor(GrContext*, 76 const GrFragmentProcessor* asFragmentProcessor(GrContext*,
77 const SkMatrix& viewM, 77 const SkMatrix& viewM,
78 const SkMatrix* localMatrix, 78 const SkMatrix* localMatrix,
79 SkFilterQuality) const overri de; 79 SkFilterQuality) const overri de;
80 #endif 80 #endif
81 81
82 size_t contextSize(const ContextRec&) const override;
83
82 class LightingShaderContext : public SkShader::Context { 84 class LightingShaderContext : public SkShader::Context {
83 public: 85 public:
84 // The context takes ownership of the states. It will call their destruc tors 86 // The context takes ownership of the states. It will call their destruc tors
85 // but will NOT free the memory. 87 // but will NOT free the memory.
86 LightingShaderContext(const SkLightingShaderImpl&, const ContextRec&, 88 LightingShaderContext(const SkLightingShaderImpl&, const ContextRec&,
87 SkBitmapProcState* diffuseState, SkBitmapProcState * normalState); 89 SkBitmapProcState* diffuseState, SkBitmapProcState * normalState);
88 ~LightingShaderContext() override; 90 ~LightingShaderContext() override;
89 91
90 void shadeSpan(int x, int y, SkPMColor[], int count) override; 92 void shadeSpan(int x, int y, SkPMColor[], int count) override;
91 93
92 uint32_t getFlags() const override { return fFlags; } 94 uint32_t getFlags() const override { return fFlags; }
93 95
94 private: 96 private:
95 SkBitmapProcState* fDiffuseState; 97 SkBitmapProcState* fDiffuseState;
96 SkBitmapProcState* fNormalState; 98 SkBitmapProcState* fNormalState;
97 uint32_t fFlags; 99 uint32_t fFlags;
98 100
99 typedef SkShader::Context INHERITED; 101 typedef SkShader::Context INHERITED;
100 }; 102 };
101 103
102 SK_TO_STRING_OVERRIDE() 104 SK_TO_STRING_OVERRIDE()
103 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingShaderImpl) 105 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingShaderImpl)
104 106
105 protected: 107 protected:
106 void flatten(SkWriteBuffer&) const override; 108 void flatten(SkWriteBuffer&) const override;
107 size_t onContextSize(const ContextRec&) const override;
108 Context* onCreateContext(const ContextRec&, void*) const override; 109 Context* onCreateContext(const ContextRec&, void*) const override;
109 bool computeNormTotalInverse(const ContextRec& rec, SkMatrix* normTotalInver se) const; 110 bool computeNormTotalInverse(const ContextRec& rec, SkMatrix* normTotalInver se) const;
110 111
111 private: 112 private:
112 SkBitmap fDiffuseMap; 113 SkBitmap fDiffuseMap;
113 SkBitmap fNormalMap; 114 SkBitmap fNormalMap;
114 115
115 SkAutoTUnref<const SkLightingShader::Lights> fLights; 116 SkAutoTUnref<const SkLightingShader::Lights> fLights;
116 117
117 SkMatrix fNormLocalMatrix; 118 SkMatrix fNormLocalMatrix;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 409 }
409 410
410 #endif 411 #endif
411 412
412 //////////////////////////////////////////////////////////////////////////// 413 ////////////////////////////////////////////////////////////////////////////
413 414
414 bool SkLightingShaderImpl::isOpaque() const { 415 bool SkLightingShaderImpl::isOpaque() const {
415 return fDiffuseMap.isOpaque(); 416 return fDiffuseMap.isOpaque();
416 } 417 }
417 418
419 size_t SkLightingShaderImpl::contextSize(const ContextRec&) const {
420 return 2 * sizeof(SkBitmapProcState) + sizeof(LightingShaderContext);
421 }
422
418 SkLightingShaderImpl::LightingShaderContext::LightingShaderContext(const SkLight ingShaderImpl& shader, 423 SkLightingShaderImpl::LightingShaderContext::LightingShaderContext(const SkLight ingShaderImpl& shader,
419 const Context Rec& rec, 424 const Context Rec& rec,
420 SkBitmapProcS tate* diffuseState, 425 SkBitmapProcS tate* diffuseState,
421 SkBitmapProcS tate* normalState) 426 SkBitmapProcS tate* normalState)
422 : INHERITED(shader, rec) 427 : INHERITED(shader, rec)
423 , fDiffuseState(diffuseState) 428 , fDiffuseState(diffuseState)
424 , fNormalState(normalState) 429 , fNormalState(normalState)
425 { 430 {
426 const SkPixmap& pixmap = fDiffuseState->fPixmap; 431 const SkPixmap& pixmap = fDiffuseState->fPixmap;
427 bool isOpaque = pixmap.isOpaque(); 432 bool isOpaque = pixmap.isOpaque();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 total.setConcat(*rec.fMatrix, fNormLocalMatrix); 648 total.setConcat(*rec.fMatrix, fNormLocalMatrix);
644 649
645 const SkMatrix* m = &total; 650 const SkMatrix* m = &total;
646 if (rec.fLocalMatrix) { 651 if (rec.fLocalMatrix) {
647 total.setConcat(*m, *rec.fLocalMatrix); 652 total.setConcat(*m, *rec.fLocalMatrix);
648 m = &total; 653 m = &total;
649 } 654 }
650 return m->invert(normTotalInverse); 655 return m->invert(normTotalInverse);
651 } 656 }
652 657
653 size_t SkLightingShaderImpl::onContextSize(const ContextRec&) const {
654 return 2 * sizeof(SkBitmapProcState) + sizeof(LightingShaderContext);
655 }
656
657 SkShader::Context* SkLightingShaderImpl::onCreateContext(const ContextRec& rec, 658 SkShader::Context* SkLightingShaderImpl::onCreateContext(const ContextRec& rec,
658 void* storage) const { 659 void* storage) const {
659 660
660 SkMatrix diffTotalInv; 661 SkMatrix diffTotalInv;
661 // computeTotalInverse was called in SkShader::createContext so we know it w ill succeed 662 // computeTotalInverse was called in SkShader::createContext so we know it w ill succeed
662 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv)); 663 SkAssertResult(this->computeTotalInverse(rec, &diffTotalInv));
663 664
664 SkMatrix normTotalInv; 665 SkMatrix normTotalInv;
665 if (!this->computeNormTotalInverse(rec, &normTotalInv)) { 666 if (!this->computeNormTotalInverse(rec, &normTotalInv)) {
666 return nullptr; 667 return nullptr;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 normLocalM); 718 normLocalM);
718 } 719 }
719 720
720 /////////////////////////////////////////////////////////////////////////////// 721 ///////////////////////////////////////////////////////////////////////////////
721 722
722 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 723 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
723 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 724 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
724 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 725 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
725 726
726 /////////////////////////////////////////////////////////////////////////////// 727 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/core/SkEmptyShader.h ('k') | src/core/SkLocalMatrixShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698