mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@5658 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ba7723648f
commit
e65b00e447
4 changed files with 146 additions and 32 deletions
|
|
@ -1,32 +1,33 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
library
|
||||
gtk-x11-2.0,
|
||||
gdk-x11-2.0,
|
||||
atk-1.0,
|
||||
gdk_pixbuf-2.0,
|
||||
m,
|
||||
pangocairo-1.0,
|
||||
fontconfig,
|
||||
Xext,
|
||||
Xrender,
|
||||
Xinerama,
|
||||
Xi,
|
||||
Xrandr,
|
||||
Xcursor,
|
||||
Xfixes,
|
||||
pango-1.0,
|
||||
cairo,
|
||||
X11,
|
||||
gobject-2.0,
|
||||
gmodule-2.0,
|
||||
dl,
|
||||
glib-2.0;
|
||||
|
||||
file
|
||||
t.iml,
|
||||
test.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
library
|
||||
gtk-x11-2.0,
|
||||
gdk-x11-2.0,
|
||||
atk-1.0,
|
||||
gdk_pixbuf-2.0,
|
||||
m,
|
||||
pangocairo-1.0,
|
||||
fontconfig,
|
||||
Xext,
|
||||
Xrender,
|
||||
Xinerama,
|
||||
Xi,
|
||||
Xrandr,
|
||||
Xcursor,
|
||||
Xfixes,
|
||||
pango-1.0,
|
||||
cairo,
|
||||
X11,
|
||||
gobject-2.0,
|
||||
gmodule-2.0,
|
||||
dl,
|
||||
glib-2.0;
|
||||
|
||||
file
|
||||
t.iml,
|
||||
test.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
|
|
|
|||
4
uppdev/GTK/init
Normal file
4
uppdev/GTK/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _GTK_icpp_init_stub
|
||||
#define _GTK_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
25
uppdev/GtkApp/BackDraw.cpp
Normal file
25
uppdev/GtkApp/BackDraw.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "GtkApp.h"
|
||||
|
||||
class BackDraw : public SystemDraw {
|
||||
public:
|
||||
virtual bool IsPaintingOp(const Rect& r) const; // TODO!
|
||||
|
||||
protected:
|
||||
Pixmap pixmap;
|
||||
Size size;
|
||||
Draw *painting;
|
||||
Point painting_offset;
|
||||
|
||||
public:
|
||||
void Put(SystemDraw& w, int x, int y);
|
||||
void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); }
|
||||
|
||||
void Create(SystemDraw& w, int cx, int cy);
|
||||
void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); }
|
||||
void Destroy();
|
||||
|
||||
void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; }
|
||||
|
||||
BackDraw();
|
||||
~BackDraw();
|
||||
};
|
||||
84
uppdev/GtkApp/ImageDraw.cpp
Normal file
84
uppdev/GtkApp/ImageDraw.cpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#include "GtkApp.h"
|
||||
|
||||
void CairoImageDraw::Init(Size sz)
|
||||
{
|
||||
isz = sz;
|
||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
|
||||
cr = cairo_create(surface);
|
||||
alpha_surface = NULL;
|
||||
}
|
||||
|
||||
Draw& CairoImageDraw::Alpha()
|
||||
{
|
||||
if(!alpha_surface) {
|
||||
alpha_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
|
||||
alpha.cr = cairo_create(alpha_surface);
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
void CairoImageDraw::FetchStraight(ImageBuffer& b) const
|
||||
{
|
||||
cairo_surface_flush(surface);
|
||||
byte *a = (byte *)cairo_image_surface_get_data(surface);
|
||||
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, isz.cx);
|
||||
RGBA *t = b;
|
||||
byte *aa = NULL;
|
||||
if(alpha_surface) {
|
||||
cairo_surface_flush(alpha_surface);
|
||||
aa = (byte *)cairo_image_surface_get_data(alpha_surface);
|
||||
}
|
||||
for(int yy = 0; yy < isz.cy; yy++) {
|
||||
RGBA *s = (RGBA *)a;
|
||||
RGBA *e = s + isz.cx;
|
||||
if(aa) {
|
||||
RGBA *ss = (RGBA *)aa;
|
||||
while(s < e) {
|
||||
*t = *s++;
|
||||
(t++)->a = (ss++)->r;
|
||||
}
|
||||
aa += stride;
|
||||
}
|
||||
else
|
||||
while(s < e) {
|
||||
*t = *s++;
|
||||
(t++)->a = 255;
|
||||
}
|
||||
a += stride;
|
||||
}
|
||||
}
|
||||
|
||||
CairoImageDraw::operator Image() const
|
||||
{
|
||||
ImageBuffer img(isz);
|
||||
FetchStraight(img);
|
||||
Premultiply(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
Image CairoImageDraw::GetStraight() const
|
||||
{
|
||||
ImageBuffer img(isz);
|
||||
FetchStraight(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
CairoImageDraw::CairoImageDraw(Size sz)
|
||||
{
|
||||
Init(sz);
|
||||
}
|
||||
|
||||
CairoImageDraw::CairoImageDraw(int cx, int cy)
|
||||
{
|
||||
Init(Size(cx, cy));
|
||||
}
|
||||
|
||||
CairoImageDraw::~CairoImageDraw()
|
||||
{
|
||||
cairo_destroy(cr);
|
||||
cairo_surface_destroy(surface);
|
||||
if(alpha_surface) {
|
||||
cairo_destroy(alpha.cr);
|
||||
cairo_surface_destroy(alpha_surface);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue