-
Notifications
You must be signed in to change notification settings - Fork 7
/
HtmlLinearGradient.h
58 lines (41 loc) · 1.06 KB
/
HtmlLinearGradient.h
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
#pragma once
#include "HtmlCanvasGradient.h"
#include "OpenglFBO.h"
class HtmlLinearGradient :
public HtmlCanvasGradient
{
DEFINE_CUSTOM_CLASS(HtmlLinearGradient, HtmlCanvasGradient)
GLuint m_tex = 0;
int m_x0;
int m_y0;
int m_x1;
int m_y1;
struct COLORSTOP
{
float stop;
uint32_t color;
bool operator ==(const COLORSTOP&src)
{
return stop == src.stop&&color == src.color;
}
bool operator!=(const COLORSTOP&src)
{
return !operator==(src);
}
};
std::vector<COLORSTOP>m_stopList;
ImageData imgdata;
static std::unordered_map<HtmlLinearGradient*, HtmlLinearGradient*>s_gradientCache;//cocos2d每次都会createLinearGradient,因此使用缓存
public:
BEGIN_CUSTOM_FUNCTION
DEFINE_CUSTOM_FUNCTION("addColorStop", &HtmlLinearGradient::addColorStop,2)
END_CUSTOM_FUNCTION
BEGIN_CUSTOM_PROPERTY
END_CUSTOM_PROPERTY
HtmlLinearGradient();
virtual ~HtmlLinearGradient();
static bool InitClass(const HandleContext&context);
bool addColorStop(IFunctionCallbackArgs&args);
GLuint GetTexture();
bool equal(HtmlLinearGradient* src);
};