1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/********************************************************************
*
*	File:		fsCTexture.h
*
*	Purpose:	Cocos2d-x implementation of a texture.
*
*********************************************************************/

#ifndef fsCTexturehdr
#define fsCTexturehdr

#include "../../fsITexture.h"

namespace ax
{
	class Texture2D;
	class Image;
}


class fsCTexture : public fsITexture
{
	friend class fsITexture;

public:

	ax::Texture2D* textureGet() const { return mTexture.get(); }

	fsS32 imageWidthGet() const override;
	fsS32 imageHeightGet() const override;
	fsS32 textureWidthGet() const override;
	fsS32 textureHeightGet() const override;

	fsBool hasAlphaChannelGet() const override;
	fsU8 alphaGet(fsS32 pU, fsS32 pV, fsS32 pCol, fsS32 pRow) const override;

	virtual ~fsCTexture();<--- Destructor in derived class

protected:

	void filterModeSetDo(fsFilterMode pNewMode) override;
	void wrapModeSetDo(fsWrapMode pNewMode) override;

	std::shared_ptr<fsITexture> doCloneSubSection(fsCBrush const* pBlend, fsPoint const& pOffset) const override;
	void doBlend(fsCBrush const* pBlend, fsPoint const& pOffset) override;

	fsSColour4B pixelGetDo(fsS32 pU, fsS32 pV, fsS32 pCol, fsS32 pRow) override;
	void doPixelSet(fsS32 pU, fsS32 pV, fsS32 pCol, fsS32 pRow, const fsSColour4B& pPixel) override;
	void doTextureCopyThroughStencil(std::shared_ptr<fsITexture> pSrc, std::shared_ptr<fsITexture> pStencil, fsS32 pU,
	                                 fsS32 pV, fsS32 pX, fsS32 pY, fsS32 pAlphaHitMaskThreshold) override;
	void doTextureCopyInto(std::shared_ptr<fsITexture> pSrc, fsS32 pU, fsS32 pV, fsS32 pX, fsS32 pY) override;

	fsU8 alphaValueGet(fsS32 pImgX, fsS32 pImgY) override;

	void createFromAlpha8Data(std::vector<fsU8>& pAlphaData, fsS32 pImgW, fsS32 pImgH,
	                          fsPoint const& pPOTDimenions) override;

	void createFromImage(fsIImage const* pImage) override;

	fsCTexture();

private:

	fsU32 v3FilterModes(fsFilterMode pNewMode);
	fsU32 v3WrapModes(fsWrapMode pNewMode);

	void alphaChannelsCombine(fsCBrush const* pBlend, fsPoint const& pOffset);

	void premultipliedAlphaReverse();

	fsS32 strideGet() const;

	std::shared_ptr<ax::Texture2D> mTexture;
};

#endif