From 7c85d11a950cf88ce53cf15e6d4f21c3433fd24d Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 5 Jul 2004 23:51:57 +0000 Subject: tiled pixmap fix, patch from dhx (xyx@gm...), see mailing list --- src/FbTk/FbPixmap.cc | 24 +++++++++++++++++++++++- src/FbTk/FbPixmap.hh | 4 +++- src/FbTk/TextureRender.cc | 12 ++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index bbc8fcb..cac6cf0 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.cc,v 1.10 2004/01/11 12:48:46 fluxgen Exp $ +// $Id: FbPixmap.cc,v 1.11 2004/07/05 23:51:57 fluxgen Exp $ #include "FbPixmap.hh" #include "App.hh" @@ -248,6 +248,28 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) { m_pm = new_pm.release(); } +void FbPixmap::tile(unsigned int dest_width, unsigned int dest_height) { + if (drawable() == 0 || + (dest_width == width() && dest_height == height())) + return; + + Display *dpy = FbTk::App::instance()->display(); + + FbPixmap new_pm(drawable(), width(), height(), depth()); + + new_pm.copy(m_pm); + + resize(dest_width,dest_height); + + GC gc = XCreateGC(dpy, drawable(), 0, NULL); + + XSetTile(dpy,gc,new_pm.release()); + XSetFillStyle(dpy, gc, FillTiled); + XFillRectangle(dpy,drawable(),gc, 0, 0, dest_width, dest_height); +} + + + void FbPixmap::resize(unsigned int width, unsigned int height) { FbPixmap pm(drawable(), width, height, depth()); *this = pm.release(); diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index 3c1a4e5..77dc555 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.hh,v 1.11 2004/04/26 21:57:32 fluxgen Exp $ +// $Id: FbPixmap.hh,v 1.12 2004/07/05 23:51:57 fluxgen Exp $ #ifndef FBTK_FBPIXMAP_HH #define FBTK_FBPIXMAP_HH @@ -54,6 +54,8 @@ public: /// scales the pixmap to specified size void scale(unsigned int width, unsigned int height); void resize(unsigned int width, unsigned int height); + /// tiles the pixmap to specified size + void tile(unsigned int width, unsigned int height); /// drops pixmap and returns it Pixmap release(); diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 6f496d7..04fb2b3 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.cc,v 1.9 2004/06/07 11:46:05 rathnor Exp $ +// $Id: TextureRender.cc,v 1.10 2004/07/05 23:51:57 fluxgen Exp $ #include "TextureRender.hh" @@ -256,12 +256,16 @@ Pixmap TextureRender::renderGradient(const FbTk::Texture &texture) { Pixmap TextureRender::renderPixmap(const FbTk::Texture &src_texture) { if (width != src_texture.pixmap().width() || height != src_texture.pixmap().height()) { + // copy src_texture's pixmap and - // scale to fit our size + // scale/tile to fit our size FbPixmap new_pm(src_texture.pixmap()); - // if not tiled then scale it - if (! (src_texture.type() & Texture::TILED)) + + if ((src_texture.type() & Texture::TILED)) { + new_pm.tile(width,height); + } else { new_pm.scale(width, height); + } return new_pm.release(); } -- cgit v0.11.2