-
Notifications
You must be signed in to change notification settings - Fork 9
/
GS.Pixel.pas
160 lines (122 loc) · 4.25 KB
/
GS.Pixel.pas
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{ -----------------------------------------------------------------------------
This program is free software: Under statement of join file README - LGPL.txt
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Unit Name : GS.Pixel
Author : Vincent Gsell (vincent dot gsell at gmail dot com)
Purpose : basic Pixel class introduced by interface.
Date: : 2020031
History :
20200301 - Creating unit.
Credits :
Description :
-----------------------------------------------------------------------------}
unit GS.Pixel;
{$I GSCore.Inc}
interface
Uses Classes, SysUtils,
GS.Geometry.Mesh2d;
Type
///
/// Interface for the "real" graphic memory surface. See GS.Pixel32 for a full impl. exemple.
///
iPixSurface = interface;
///
/// The base access to the pixel is happening throught pixel's shader.
/// Even if it is a very slow methods, this implementation allow very clear
/// access (in a code point of view) to the pixel.
///
iPixShader = interface;
///
/// This interface allow to use others graphics lib, such as hundreds available
/// on the net. Pixel designed to be platform agnostic, but service should be
/// platform dedicated. If you need performance, or if you want to not adapt
/// or rewrite existing proven code, service is the way.
///
iPixService = interface;
///
/// this interface is reserved to advanced "drawable" object.
///
iPixDrawable = interface;
///
/// All full effect on surface (blur, disolve, matrix will pass throught this
/// interface.
///
iPixSurfaceEffect = interface;
//Using graphics stuff, friend class, fine memory tuning needed :
//Desactivate attached memory management.
TPixelInterfacedObject = class(TInterfacedObject)
public
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
End;
//Pixel shader. (per pixel work)
iPixShader = interface
procedure process;
end;
//Whole surface, use shader in a more direct way.
iPixSurfaceEffect = interface
procedure init(surface : iPixSurface);
procedure process;
end;
iPixSurface = interface
function getSurfacePtr : pointer;
function getSurfaceScanLinePtr(LineIndex : Int32) : pointer;
procedure resize(width,height : Int32);
procedure copyTo(targetPixel32 : iPixSurface);
function isEmpty : boolean;
procedure moveTo(const x,y : Int32);
procedure lineTo(const x,y : Int32);
procedure pixel(const x,y : Int32);
procedure rectangle(const x,y,xx,yy : Int32);
procedure setFragmentShader(shader : iPixShader); //set a pixel draw shader.
procedure draw(objToRender : iPixDrawable); //draw a "drawable"
procedure setVertice(indice : uInt32; x,y : single); //load vertex data.
procedure setVerticeUV(indice : uint32; u,v : single);
procedure setVerticeColor(indice: uint32; r,g,b,a : single);
procedure rasterize; //Make a raster triangle using given vertex data.
procedure beginDraw; //Perform technical/logical operation and setting before drawing.
procedure endDraw; //Indicate the end logical drawing operation.
// procedure invoke(service : iPixService);
procedure clear;
function width : uInt32;
function height : uInt32;
end;
iPixDrawable = interface
function mesh : TGSRawMesh2D;
function getShader : iPixShader;
end;
iPixService = interface
function uri : string;
function id : string;
procedure Ask(param : TStream);
procedure Answer(content : TStream; success : boolean; report : TStream);
end;
///
///
///
/// F R O N T E N D
///
///
TPixel = class
// procedure ActiveBackend(backName : string);
end;
implementation
{ TPixelInterfacedObject }
function TPixelInterfacedObject._AddRef: Integer;
begin
result := -1;
end;
function TPixelInterfacedObject._Release: Integer;
begin
result := -1;
end;
end.