Commit 89dd48f0 authored by Sergey Galin's avatar Sergey Galin

[VNA-28] Sample with WebView in QML compiles and runs (but doesn't load a page yet)

parent 97f0bd12
......@@ -4,6 +4,7 @@ moc_*
*.o
*.so
*.user
*.user.*
bin/*
gen/*
Makefile
......
......@@ -88,7 +88,7 @@ QAndroidOffscreenView::QAndroidOffscreenView(
qDebug()<<__PRETTY_FUNCTION__<<"Creating object of"<<view_class_name_;
offscreen_view_.reset(new jcGeneric(
view_class_name_.toAscii()
view_class_name_.toLatin1()
, true // Keep ownership
));
......
......@@ -95,9 +95,6 @@ public:
* If texture is not ready, the rectangle is filled with fillColor.
*/
virtual void paintGL(int l, int b, int w, int h);
void paintGL(const QRect & targetRect) { paintGL(targetRect.left(), targetRect.bottom(), targetRect.width(), targetRect.height()); }
void paintGL(const QPoint & point) { paintGL(QRect(point, size_)); }
void paintGL(int x, int y) { paintGL(QRect(QPoint(x, y), size_)); }
//! Check if Android View already exists
bool isCreated() const;
......
QT += qml quick
QT += qml quick androidextras opengl
# Add more folders to ship with the application, here
folder_01.source = qml/AndroidWebView_Qt5
......@@ -14,8 +14,23 @@ QML_IMPORT_PATH =
# MOBILITY +=
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp fboinsgrenderer.cpp logorenderer.cpp
HEADERS += fboinsgrenderer.h logorenderer.h
SOURCES += main.cpp fboinsgrenderer.cpp logorenderer.cpp \
../../QtOffscreenViews/QAndroidOffscreenView.cpp \
../../QtOffscreenViews/QAndroidOffscreenWebView.cpp \
../../QtOffscreenViews/QAndroidQPAPluginGap.cpp \
../../QtOffscreenViews/QOpenGLTextureHolder.cpp \
../../JNIUtils/jcGeneric.cpp \
../../JNIUtils/JclassPtr.cpp \
../../JNIUtils/JniEnvPtr.cpp
HEADERS += fboinsgrenderer.h logorenderer.h \
../../QtOffscreenViews/QAndroidOffscreenView.h \
../../QtOffscreenViews/QAndroidOffscreenWebView.h \
../../QtOffscreenViews/QAndroidQPAPluginGap.h \
../../QtOffscreenViews/QOpenGLTextureHolder.h \
../../JNIUtils/jcGeneric.h \
../../JNIUtils/JclassPtr.h \
../../JNIUtils/JniEnvPtr.h \
../../JNIUtils/stdafx.h
# Installation path
# target.path =
......@@ -28,3 +43,8 @@ OTHER_FILES += \
main.qml
RESOURCES += AndroidWebView.qrc
INCLUDEPATH += ../../JNIUtils ../../QtOffscreenViews
LIBS += -L../../QtOffscreenViews -lQtOffscreenViews -L../../JNIUtils -lJNIUtils
POST_TARGETDEPS += ../../QtOffscreenViews/libQtOffscreenViews.a ../../JNIUtils/libJNIUtils.a
......@@ -39,35 +39,44 @@
****************************************************************************/
#include "fboinsgrenderer.h"
#include "logorenderer.h"
#include <QtGui/QOpenGLFramebufferObject>
#include <QtQuick/QQuickWindow>
#include <qsgsimpletexturenode.h>
class LogoInFboRenderer : public QQuickFramebufferObject::Renderer
LogoInFboRenderer::LogoInFboRenderer()
: aview_("WebViewInQML", true, QSize(512, 512))
{
public:
LogoInFboRenderer()
{
logo.initialize();
}
connect(&aview_, SIGNAL(updated()), this, SLOT(textureUpdated()));
aview_.initializeGL();
aview_.setFillColor(Qt::red);
aview_.loadUrl("http://www.android.com/intl/en/about/");
}
void render() {
logo.render();
void LogoInFboRenderer::render()
{
// qDebug()<<"Grym"<<__FUNCTION__<<"Size:"<<aview_.size().height()<<"x"<<aview_.size().width();
// logo.render();
// aview_.paintGL(QPoint(0, 0));
aview_.paintGL(0, 0, aview_.size().height(), aview_.size().width());
update();
}
}
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) {
QOpenGLFramebufferObject * LogoInFboRenderer::createFramebufferObject(const QSize &size)
{
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
// format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(4);
aview_.resize(size);
return new QOpenGLFramebufferObject(size, format);
}
}
void LogoInFboRenderer::textureUpdated()
{
invalidateFramebufferObject();
}
LogoRenderer logo;
};
QQuickFramebufferObject::Renderer *FboInSGRenderer::createRenderer() const
{
......
......@@ -42,8 +42,7 @@
#define FBOINSGRENDERER_H
#include <QtQuick/QQuickFramebufferObject>
class LogoRenderer;
#include <QAndroidOffscreenWebView.h>
class FboInSGRenderer : public QQuickFramebufferObject
{
......@@ -52,4 +51,17 @@ public:
Renderer *createRenderer() const;
};
class LogoInFboRenderer : public QObject, public QQuickFramebufferObject::Renderer
{
Q_OBJECT
public:
LogoInFboRenderer();
void render();
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
protected slots:
void textureUpdated();
protected:
QAndroidOffscreenWebView aview_;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment