void GLDraw::PutImage(Point p, const Image& img, const Rect& src) { if(img.GetLength() == 0) return; LLOG("PutImage " << img.GetSerialId() << ' ' << p.x << ", " << p.y << ", "<< img.GetSize()); LLOG("SysImage cache pixels " << sTextureCache.GetSize() << ", count " << sTextureCache.GetCount()); ImageGLDataMaker m; m.img = img; ImageGLData& sd = sTextureCache.Get(m); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, sd.texture_id); glColor3f(1.0f, 1.0f, 1.0f); if(src == img.GetSize()) { Rect r(p, img.GetSize()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex2i(r.left, r.top); glTexCoord2f(1, 0); glVertex2i(r.right, r.top); glTexCoord2f(0, 1); glVertex2i(r.left, r.bottom); glTexCoord2f(1, 1); glVertex2i(r.right, r.bottom); glEnd(); } else { Sizef iszf = img.GetSize(); Rect s = src & img.GetSize(); Rect r(p, s.GetSize()); Rectf h; h.left = (double)s.left / iszf.cx; h.right = (double)s.right / iszf.cx; h.top = (double)s.top / iszf.cy; h.bottom = (double)s.bottom / iszf.cy; glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(h.left, h.top); glVertex2i(r.left, r.top); glTexCoord2f(h.right, h.top); glVertex2i(r.right, r.top); glTexCoord2f(h.left, h.bottom); glVertex2i(r.left, r.bottom); glTexCoord2f(h.right, h.bottom); glVertex2i(r.right, r.bottom); glEnd(); } glDisable(GL_TEXTURE_2D); sTextureCache.Shrink(4 * 1024 * 768, 1000); }
void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color) { GuiLock __; if(img.GetLength() == 0) return; LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize()); ImageSysDataMaker m; static LRUCache<ImageSysData, int64> cache; LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount()); m.img = img; cache.Get(m).Paint(*this, x, y, src, color); Size sz = Ctrl::GetPrimaryScreenArea().GetSize(); cache.Shrink(4 * sz.cx * sz.cy, 1000); // Cache must be after Paint because of PaintOnly! }
void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, Color color) { GuiLock __; if(img.GetLength() == 0) return; LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << x << ", " << y << ", "<< img.GetSize()); ImageSysDataMaker m; static LRUCache<ImageSysData, int64> cache; LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount()); m.img = img; ImageSysData& sd = cache.Get(m); if(!IsNull(color)) { SetColor(color); cairo_mask_surface(cr, sd.surface, x, y); } else { cairo_set_source_surface(cr, sd.surface, x, y); cairo_paint(cr); } cache.Shrink(4 * 1024 * 768, 1000); // Cache must be after Paint because of PaintOnly! }