-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProxyShader.h
42 lines (35 loc) · 1.22 KB
/
ProxyShader.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
#ifndef PROXY_DEFINED
#define PROXY_DEFINED
#include "include/GShader.h"
#include "include/GBitmap.h"
#include "include/GMatrix.h"
#include "include/GPixel.h"
#include "include/GPoint.h"
class ProxyShader: public GShader{
public:
ProxyShader(GShader* shader, const GPoint pts[3], const GPoint texs[3]){
if(texs){
GMatrix T, P;
T.set6(texs[1].fX - texs[0].fX, texs[2].fX - texs[0].fX, texs[0].fX,
texs[1].fY - texs[0].fY, texs[2].fY - texs[0].fY, texs[0].fY);
P.set6(pts[1].fX - pts[0].fX, pts[2].fX - pts[0].fX, pts[0].fX,
pts[1].fY - pts[0].fY, pts[2].fY - pts[0].fY, pts[0].fY);
T.invert(&T);
extra.setConcat(P, T);
}
this -> realShader = shader;
}
bool isOpaque() override { return realShader -> isOpaque(); }
bool setContext(const GMatrix& ctm) override {
GMatrix mat;
mat.setConcat(ctm, extra);
return realShader -> setContext(mat);
}
void shadeRow(int x, int y, int count, GPixel row[]) override {
realShader ->shadeRow(x, y, count, row);
}
private:
GMatrix extra;
GShader* realShader;
};
#endif