diff --git a/src/plane.cpp b/src/plane.cpp index 11eb6df..dc67ad1 100644 --- a/src/plane.cpp +++ b/src/plane.cpp @@ -33,6 +33,8 @@ #include "shader.h" #include "glstate.h" +#include + struct PlanePrivate { Bitmap *bitmap; @@ -52,6 +54,8 @@ struct PlanePrivate EtcTemps tmp; + sigc::connection prepareCon; + PlanePrivate() : bitmap(0), opacity(255), @@ -61,7 +65,15 @@ struct PlanePrivate ox(0), oy(0), zoomX(1), zoomY(1), quadSourceDirty(false) - {} + { + prepareCon = shState->prepareDraw.connect + (sigc::mem_fun(this, &PlanePrivate::prepare)); + } + + ~PlanePrivate() + { + prepareCon.disconnect(); + } void updateQuadSource() { @@ -73,6 +85,18 @@ struct PlanePrivate quad.setTexRect(srcRect); } + + void prepare() + { + if (quadSourceDirty) + { + updateQuadSource(); + quadSourceDirty = false; + } + + if (bitmap) + bitmap->flush(); + } }; Plane::Plane(Viewport *viewport) @@ -176,12 +200,6 @@ void Plane::draw() if (!p->opacity) return; - if (p->quadSourceDirty) - { - p->updateQuadSource(); - p->quadSourceDirty = false; - } - ShaderBase *base; if (p->color->hasEffect() || p->tone->hasEffect() || p->opacity != 255) @@ -210,7 +228,6 @@ void Plane::draw() glState.blendMode.pushSet(p->blendType); - p->bitmap->flush(); p->bitmap->bindTex(*base); TEX::setRepeat(true); diff --git a/src/sprite.cpp b/src/sprite.cpp index 520c413..b9e3f52 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -59,6 +59,8 @@ struct SpritePrivate EtcTemps tmp; + sigc::connection prepareCon; + SpritePrivate() : bitmap(0), srcRect(&tmp.rect), @@ -73,11 +75,15 @@ struct SpritePrivate { updateSrcRectCon(); + + prepareCon = shState->prepareDraw.connect + (sigc::mem_fun(this, &SpritePrivate::prepare)); } ~SpritePrivate() { srcRectCon.disconnect(); + prepareCon.disconnect(); } void recomputeBushDepth() @@ -112,6 +118,12 @@ struct SpritePrivate srcRectCon = srcRect->valueChanged.connect (sigc::mem_fun(this, &SpritePrivate::onSrcRectChange)); } + + void prepare() + { + if (bitmap) + bitmap->flush(); + } }; Sprite::Sprite(Viewport *viewport) @@ -313,8 +325,6 @@ void Sprite::draw() if (emptyFlashFlag) return; - p->bitmap->flush(); - ShaderBase *base; bool renderEffect = p->color->hasEffect() ||