mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
GLDraw: context
git-svn-id: svn://ultimatepp.org/upp/trunk@6359 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6a6e0e6fb3
commit
a9ba86520e
2 changed files with 16 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ void ImageGLData::Init(const Image& img)
|
|||
// SysImageRealized(img); // ?
|
||||
}
|
||||
|
||||
static LRUCache<ImageGLData, int64> sTextureCache;
|
||||
static LRUCache<ImageGLData, Tuple2<uint64, uint64> > sTextureCache;
|
||||
static bool sReset;
|
||||
|
||||
ImageGLData::~ImageGLData()
|
||||
|
|
@ -54,11 +54,12 @@ void GLDraw::ResetCache()
|
|||
sReset = false;
|
||||
}
|
||||
|
||||
struct ImageGLDataMaker : LRUCache<ImageGLData, int64>::Maker {
|
||||
struct ImageGLDataMaker : LRUCache<ImageGLData, Tuple2<uint64, uint64> >::Maker {
|
||||
Image img;
|
||||
uint64 context;
|
||||
|
||||
virtual int64 Key() const { return img.GetSerialId(); }
|
||||
virtual int Make(ImageGLData& object) const { object.Init(img); return img.GetLength(); }
|
||||
virtual Tuple2<uint64, uint64> Key() const { return MakeTuple<uint64, uint64>(img.GetSerialId(), context); }
|
||||
virtual int Make(ImageGLData& object) const { object.Init(img); return img.GetLength(); }
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -71,6 +72,7 @@ void GLDraw::PutImage(Point p, const Image& img, const Rect& src)
|
|||
LLOG("SysImage cache pixels " << sTextureCache.GetSize() << ", count " << sTextureCache.GetCount());
|
||||
ImageGLDataMaker m;
|
||||
m.img = img;
|
||||
m.context = context;
|
||||
ImageGLData& sd = sTextureCache.Get(m);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
|
@ -143,8 +145,10 @@ void GLDraw::PutRect(const Rect& r, Color color)
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
void GLDraw::InitGL(Size sz)
|
||||
void GLDraw::InitGL(Size sz, uint64 context_)
|
||||
{
|
||||
context = context_;
|
||||
|
||||
SDraw::Init(sz);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue