-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompositeShader.h
36 lines (29 loc) · 957 Bytes
/
CompositeShader.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
#ifndef COMP_DEFINED
#define COMP_DEFINED
#include "include/GShader.h"
#include "GBlend.h"
#include "include/GPixel.h"
#include "include/GPoint.h"
class CompositeShader: public GShader{
public:
CompositeShader(GShader* shader1, GShader* shader2){
this -> shader1 = shader1;
this -> shader2 = shader2;
}
bool isOpaque() override { return shader1 -> isOpaque() && shader2 -> isOpaque(); }
bool setContext(const GMatrix& ctm) override{
return shader1 -> setContext(ctm) && shader2 -> setContext(ctm);
}
void shadeRow(int x, int y, int count, GPixel row[]) override{
GPixel scratch[count];
shader1 -> shadeRow(x, y, count, scratch);
shader2 -> shadeRow(x, y, count, row);
for(int i = 0; i < count; i++){
row[i] = GMultPixel(row[i], scratch[i]);
}
}
private:
GShader* shader1;
GShader* shader2;
};
#endif