tiled pixmap fix, patch from dhx (xyx@gm...), see mailing list

This commit is contained in:
fluxgen 2004-07-05 23:51:57 +00:00
parent df570bc945
commit 7c85d11a95
3 changed files with 34 additions and 6 deletions

View file

@ -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();

View file

@ -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();

View file

@ -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();
}