Line data Source code
1 : /** 2 : Copyright (c) 2023 Stappler LLC <admin@stappler.dev> 3 : 4 : Permission is hereby granted, free of charge, to any person obtaining a copy 5 : of this software and associated documentation files (the "Software"), to deal 6 : in the Software without restriction, including without limitation the rights 7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 : copies of the Software, and to permit persons to whom the Software is 9 : furnished to do so, subject to the following conditions: 10 : 11 : The above copyright notice and this permission notice shall be included in 12 : all copies or substantial portions of the Software. 13 : 14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 : THE SOFTWARE. 21 : **/ 22 : 23 : #ifndef XENOLITH_RENDERER_BASIC2D_XL2DFRAMECONTEXT_H_ 24 : #define XENOLITH_RENDERER_BASIC2D_XL2DFRAMECONTEXT_H_ 25 : 26 : #include "XLFrameContext.h" 27 : #include "XL2dCommandList.h" 28 : #include "XL2dLinearGradient.h" 29 : 30 : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d { 31 : 32 : class FrameContext2d : public FrameContext { 33 : public: 34 : static constexpr StringView MaterialAttachmentName = "MaterialInput2d"; 35 : static constexpr StringView VertexAttachmentName = "VertexInput2d"; 36 : static constexpr StringView LightDataAttachmentName = "ShadowLightDataAttachment"; 37 : static constexpr StringView ShadowVertexAttachmentName = "ShadowVertexAttachment"; 38 : static constexpr StringView SdfImageAttachmentName = "SdfImageAttachment"; 39 : 40 20 : virtual ~FrameContext2d() { } 41 : 42 : virtual void onEnter(xenolith::Scene *) override; 43 : virtual void onExit() override; 44 : 45 : virtual Rc<FrameContextHandle> makeHandle(FrameInfo &) override; 46 : virtual void submitHandle(FrameInfo &, FrameContextHandle *) override; 47 : 48 : protected: 49 : bool initWithQueue(core::Queue *); 50 : 51 : const core::AttachmentData *_materialAttachmentData = nullptr; 52 : const core::AttachmentData *_vertexAttachmentData = nullptr; 53 : const core::AttachmentData *_lightAttachmentData = nullptr; 54 : const core::AttachmentData *_shadowVertexAttachmentData = nullptr; 55 : const core::AttachmentData *_sdfImageAttachmentData = nullptr; 56 : 57 : bool _init = false; 58 : }; 59 : 60 : struct StateData : public Ref { 61 740 : virtual ~StateData() = default; 62 : 63 : virtual bool init(); 64 : virtual bool init(StateData *); 65 : 66 : Mat4 transform; 67 : Rc<LinearGradientData> gradient; 68 : }; 69 : 70 : } 71 : 72 : #endif /* XENOLITH_RENDERER_BASIC2D_XL2DFRAMECONTEXT_H_ */