From: Gunnar Sletta Date: Tue, 13 Sep 2011 10:23:27 +0000 (+0200) Subject: fix declarative to work after broken refactor X-Git-Tag: qt-v5.0.0-alpha1~1696 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e47ade5e86c96eef95f43bb181ace17524acb19c;p=profile%2Fivi%2Fqtdeclarative.git fix declarative to work after broken refactor Change-Id: I5a30f8c45e21344060ea6e61d440d6fea822f9de --- diff --git a/src/declarative/items/context2d/qsgcontext2d.cpp b/src/declarative/items/context2d/qsgcontext2d.cpp index 50ce1e4..af2676f 100644 --- a/src/declarative/items/context2d/qsgcontext2d.cpp +++ b/src/declarative/items/context2d/qsgcontext2d.cpp @@ -58,8 +58,6 @@ #include #include "qv8engine_p.h" -#include -#include #include "qdeclarativeengine.h" QT_BEGIN_NAMESPACE /*! @@ -344,12 +342,15 @@ static QImage qt_texture_to_image(QSGTexture* texture) { if (!texture || !texture->textureId()) return QImage(); - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); format.setInternalTextureFormat(GL_RGBA); format.setMipmap(false); - QGLFramebufferObject* fbo = new QGLFramebufferObject(texture->textureSize(), format); + QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(texture->textureSize(), format); +#if 0 + // ### refactor fbo->drawTexture(QPointF(0,0), texture->textureId(), GL_TEXTURE_2D); +#endif return fbo->toImage(); } @@ -723,15 +724,7 @@ static v8::Handle ctx2d_globalAlpha(v8::Local, const v8:: QV8Context2DResource *r = v8_resource_cast(info.This()); CHECK_CONTEXT(r) - -<<<<<<< HEAD return v8::Number::New(r->context->state.globalAlpha); -======= - QV8Engine *engine = V8ENGINE_ACCESSOR(); - Q_UNUSED(engine) - - return v8::Boolean::New(r->context->valid()); ->>>>>>> refactor } static void ctx2d_globalAlpha_set(v8::Local, v8::Local value, const v8::AccessorInfo &info) @@ -2171,13 +2164,12 @@ static v8::Handle ctx2d_imageData_mirror(const v8::Arguments &args) return v8::Undefined(); } -<<<<<<< HEAD if (args.Length() == 1) { horizontal = args[0]->BooleanValue(); } else if (args.Length() == 2) { horizontal = args[0]->BooleanValue(); vertical = args[1]->BooleanValue(); -======= + } #if 0 // ### refactor // blur the alpha channel @@ -2188,7 +2180,6 @@ static v8::Handle ctx2d_imageData_mirror(const v8::Arguments &args) qt_blurImage(&blurPainter, shadowImg, state.shadowBlur, false, true); blurPainter.end(); shadowImg = blurred; ->>>>>>> refactor } #endif @@ -2266,7 +2257,9 @@ static v8::Handle ctx2d_imageData_filter(const v8::Arguments &args) blurred.fill(Qt::transparent); QPainter blurPainter(&blurred); +#if 0 qt_blurImage(&blurPainter, r->image, blur, true, false); +#endif blurPainter.end(); r->image = blurred; } @@ -2832,9 +2825,9 @@ static int textAlignOffset(QSGContext2D::TextAlignType value, const QFontMetrics { int offset = 0; if (value == QSGContext2D::Start) - value = QApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Left : QSGContext2D::Right; + value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Left : QSGContext2D::Right; else if (value == QSGContext2D::End) - value = QApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Right: QSGContext2D::Left; + value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QSGContext2D::Right: QSGContext2D::Left; switch (value) { case QSGContext2D::QSGContext2D::Center: offset = metrics.width(text)/2; diff --git a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp index 8eb9513..0448fa0 100644 --- a/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp +++ b/src/declarative/items/context2d/qsgcontext2dcommandbuffer.cpp @@ -42,7 +42,6 @@ #include "qsgcontext2dcommandbuffer_p.h" #include "qsgcanvasitem_p.h" #include "qdeclarative.h" -#include #include #define HAS_SHADOW(offsetX, offsetY, blur, color) (color.isValid() && color.alpha() && (blur || offsetX || offsetY)) @@ -65,7 +64,9 @@ static QImage makeShadowImage(const QImage& image, qreal offsetX, qreal offsetY, QImage blurred(shadowImg.size(), QImage::Format_ARGB32); blurred.fill(0); QPainter blurPainter(&blurred); +#if 0 qt_blurImage(&blurPainter, shadowImg, blur, true, false); +#endif blurPainter.end(); shadowImg = blurred; } diff --git a/src/declarative/items/context2d/qsgcontext2dtexture.cpp b/src/declarative/items/context2d/qsgcontext2dtexture.cpp index 6e2c7c3..920ab9b 100644 --- a/src/declarative/items/context2d/qsgcontext2dtexture.cpp +++ b/src/declarative/items/context2d/qsgcontext2dtexture.cpp @@ -4,9 +4,10 @@ #include "qsgitem_p.h" #include "private/qsgtexture_p.h" #include "qsgcontext2dcommandbuffer_p.h" +#include -#include -#include +#include +#include #include #define QT_MINIMUM_FBO_SIZE 64 @@ -361,6 +362,7 @@ void QSGContext2DTexture::clearTiles() QSGContext2DFBOTexture::QSGContext2DFBOTexture() : QSGContext2DTexture() , m_fbo(0) + , m_paint_device(0) { m_threadRendering = false; } @@ -492,7 +494,7 @@ void QSGContext2DFBOTexture::compositeTile(QSGContext2DTile* tile) source.moveTo(source.topLeft() - t->rect().topLeft()); target.moveTo(target.topLeft() - m_canvasWindow.topLeft()); - QGLFramebufferObject::blitFramebuffer(m_fbo, target, t->fbo(), source); + QOpenGLFramebufferObject::blitFramebuffer(m_fbo, target, t->fbo(), source); } } QSGCanvasItem::RenderTarget QSGContext2DFBOTexture::renderTarget() const @@ -507,8 +509,8 @@ QPaintDevice* QSGContext2DFBOTexture::beginPainting() delete m_fbo; m_fbo = 0; } else if (!m_fbo || m_fbo->size() != m_fboSize) { - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); format.setInternalTextureFormat(GL_RGBA); format.setMipmap(false); format.setTextureTarget(GL_TEXTURE_2D); @@ -516,11 +518,17 @@ QPaintDevice* QSGContext2DFBOTexture::beginPainting() glDisable(GL_DEPTH_TEST); glDepthMask(false); - m_fbo = new QGLFramebufferObject(m_fboSize, format); + m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); glBindTexture(GL_TEXTURE_2D, m_fbo->texture()); updateBindOptions(false); } - return m_fbo; + + m_fbo->bind(); + + if (!m_paint_device) + m_paint_device = new QOpenGLPaintDevice(m_fbo->size()); + + return m_paint_device; } void qt_quit_context2d_render_thread() diff --git a/src/declarative/items/context2d/qsgcontext2dtexture_p.h b/src/declarative/items/context2d/qsgcontext2dtexture_p.h index 50e5be7..0fb3154 100644 --- a/src/declarative/items/context2d/qsgcontext2dtexture_p.h +++ b/src/declarative/items/context2d/qsgcontext2dtexture_p.h @@ -46,8 +46,8 @@ #include "qsgcanvasitem_p.h" #include "qsgcontext2d_p.h" -#include -#include +#include +#include #include #include @@ -152,10 +152,11 @@ private Q_SLOTS: private: QImage m_grabedImage; - QGLFramebufferObject *m_fbo; + QOpenGLFramebufferObject *m_fbo; QMutex m_mutex; QWaitCondition m_condition; QSize m_fboSize; + QPaintDevice *m_paint_device; }; class QSGPlainTexture; diff --git a/src/declarative/items/context2d/qsgcontext2dtile.cpp b/src/declarative/items/context2d/qsgcontext2dtile.cpp index 695c30f..14051b6 100644 --- a/src/declarative/items/context2d/qsgcontext2dtile.cpp +++ b/src/declarative/items/context2d/qsgcontext2dtile.cpp @@ -41,8 +41,9 @@ #include "qsgcontext2dtile_p.h" -#include -#include +#include +#include +#include QSGContext2DTile::QSGContext2DTile() : m_dirty(true) @@ -63,6 +64,7 @@ QPainter* QSGContext2DTile::createPainter(bool smooth) m_painter.end(); if (m_device) { + aboutToDraw(); m_painter.begin(m_device); m_painter.resetTransform(); m_painter.setCompositionMode(QPainter::CompositionMode_Source); @@ -97,11 +99,21 @@ QSGContext2DFBOTile::QSGContext2DFBOTile() { } + QSGContext2DFBOTile::~QSGContext2DFBOTile() { delete m_fbo; } +void QSGContext2DFBOTile::aboutToDraw() +{ + m_fbo->bind(); + if (!m_device) { + m_device = new QOpenGLPaintDevice(rect().size()); + } +} + + void QSGContext2DFBOTile::setRect(const QRect& r) { if (m_rect == r) @@ -109,8 +121,8 @@ void QSGContext2DFBOTile::setRect(const QRect& r) m_rect = r; m_dirty = true; if (!m_fbo || m_fbo->size() != r.size()) { - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); format.setInternalTextureFormat(GL_RGBA); format.setMipmap(false); @@ -118,9 +130,8 @@ void QSGContext2DFBOTile::setRect(const QRect& r) m_painter.end(); delete m_fbo; - m_fbo = new QGLFramebufferObject(r.size(), format); + m_fbo = new QOpenGLFramebufferObject(r.size(), format); } - m_device = m_fbo; } diff --git a/src/declarative/items/context2d/qsgcontext2dtile_p.h b/src/declarative/items/context2d/qsgcontext2dtile_p.h index cee2125..d5317f9 100644 --- a/src/declarative/items/context2d/qsgcontext2dtile_p.h +++ b/src/declarative/items/context2d/qsgcontext2dtile_p.h @@ -43,7 +43,7 @@ #define QSGCONTEXT2DTILE_P_H #include "qsgcontext2d_p.h" -#include +#include QT_BEGIN_HEADER @@ -68,7 +68,10 @@ public: virtual void setRect(const QRect& r) = 0; virtual QPainter* createPainter(bool smooth = false); + protected: + virtual void aboutToDraw() {} + uint m_dirty : 1; QRect m_rect; QPaintDevice* m_device; @@ -82,9 +85,15 @@ public: QSGContext2DFBOTile(); ~QSGContext2DFBOTile(); virtual void setRect(const QRect& r); - QGLFramebufferObject* fbo() const {return m_fbo;} + QOpenGLFramebufferObject* fbo() const {return m_fbo;} + +protected: + void aboutToDraw(); + private: - QGLFramebufferObject *m_fbo; + + + QOpenGLFramebufferObject *m_fbo; }; class QSGContext2DImageTile : public QSGContext2DTile diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp index e0bbf28..174942d 100644 --- a/src/declarative/particles/qsgcustomparticle.cpp +++ b/src/declarative/particles/qsgcustomparticle.cpp @@ -477,14 +477,8 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes() } s.vertexCode = qt_particles_template_vertex_code + s.vertexCode; -<<<<<<< HEAD - m_material.setProgramSource(s); - foreach (const QString &str, m_groups){ -======= m_material->setProgramSource(s); - - foreach (const QString &str, m_particles){ ->>>>>>> refactor + foreach (const QString &str, m_groups){ int gIdx = m_system->m_groupIds[str]; int count = m_system->m_groupData[gIdx]->size(); //Create Particle Geometry