-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayerExBase.hpp
More file actions
131 lines (113 loc) · 3.44 KB
/
layerExBase.hpp
File metadata and controls
131 lines (113 loc) · 3.44 KB
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
#ifndef _layExBase_hpp_
#define _layExBase_hpp_
#include "tp_stub.h"
/**
* プロパティのキャッシュ処理用
*/
struct ObjectCache
{
typedef iTJSDispatch2* DispatchT;
typedef tjs_char const* NameT;
typedef tTVInteger IntegerT;
typedef ttstr StringT;
typedef tTJSVariant VariantT;
ObjectCache(DispatchT obj, NameT name) : _obj(obj), _cache(0), _name(name) {
tTJSVariant layer;
TVPExecuteExpression(TJS_W("Layer"), &layer);
tTJSVariant var;
if (TJS_SUCCEEDED(layer.AsObjectNoAddRef()->PropGet(TJS_IGNOREPROP, name, NULL, &var, layer.AsObjectNoAddRef()))) _cache = var;
else _Exception(TJS_W("FAILED: get property object :"));
}
~ObjectCache() {
if (_cache) _cache->Release();
}
inline VariantT GetValue() const {
VariantT var;
if (TJS_FAILED(_cache->PropGet(0, 0, 0, &var, _obj)))
_Exception(TJS_W("FAILED: get property value :"));
return var;
}
inline operator VariantT() const { return GetValue(); }
inline operator IntegerT() const { return static_cast<IntegerT>(GetValue()); }
inline VariantT operator ()(int numparams, VariantT **param) {
VariantT var;
if (TJS_FAILED(_cache->FuncCall(0, 0, 0, &var, numparams, param, _obj)))
_Exception(TJS_W("FAILED: function call :"));
return var;
}
inline void SetValue(int n) const {
VariantT var = n;
if (TJS_FAILED(_cache->PropSet(0, 0, 0, &var, _obj)))
_Exception(TJS_W("FAILED: get property value :"));
}
private:
DispatchT _obj, _cache;
NameT _name;
void _Exception(NameT mes) const {
TVPThrowExceptionMessage(mes, _name);
}
};
/**
* レイヤ拡張処理のベース
*/
struct layerExBase
{
typedef iTJSDispatch2* DispatchT;
typedef ObjectCache ObjectT;
typedef unsigned char* BufferT;
typedef unsigned char* BufferRT;
typedef tjs_int PitchT;
typedef tjs_int GeometryT;
DispatchT _obj;
/**
* コンストラクタ
*/
layerExBase(DispatchT obj)
: _obj(obj),
_pWidth( obj, TJS_W("imageWidth")),
_pHeight(obj, TJS_W("imageHeight")),
_pBuffer(obj, TJS_W("mainImageBufferForWrite")),
_pPitch( obj, TJS_W("mainImageBufferPitch")),
_pUpdate(obj, TJS_W("update")),
_pClipLeft( obj, TJS_W("clipLeft")),
_pClipTop( obj, TJS_W("clipTop")),
_pClipWidth( obj, TJS_W("clipWidth")),
_pClipHeight(obj, TJS_W("clipHeight")),
_width(0), _height(0), _pitch(0), _buffer(0), _clipLeft(0), _clipTop(0), _clipWidth(0), _clipHeight(0)
{
}
/**
* デストラクタ
*/
virtual ~layerExBase() {}
/**
* 再描画指定
*/
virtual void redraw() {
tTJSVariant vars [4] = { _pClipLeft, _pClipTop, _pClipWidth, _pClipHeight };
tTJSVariant *varsp[4] = { vars, vars+1, vars+2, vars+3 };
_pUpdate(4, varsp);
}
/**
* 情報更新
*/
virtual void reset() {
_width = (GeometryT)_pWidth;
_height = (GeometryT)_pHeight;
_buffer = (BufferT)(ObjectCache::IntegerT)_pBuffer;
_pitch = (PitchT)_pPitch;
_clipLeft = (GeometryT)_pClipLeft;
_clipTop = (GeometryT)_pClipTop;
_clipWidth = (GeometryT)_pClipWidth;
_clipHeight = (GeometryT)_pClipHeight;
}
protected:
ObjectT _pWidth, _pHeight, _pBuffer, _pPitch, _pUpdate;
GeometryT _width, _height;
BufferT _buffer;
PitchT _pitch;
// クリップ情報
ObjectT _pClipLeft, _pClipTop, _pClipWidth, _pClipHeight;
GeometryT _clipLeft, _clipTop, _clipWidth, _clipHeight;
};
#endif