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_* ...@@ -4,6 +4,7 @@ moc_*
*.o *.o
*.so *.so
*.user *.user
*.user.*
bin/* bin/*
gen/* gen/*
Makefile Makefile
......
...@@ -88,7 +88,7 @@ QAndroidOffscreenView::QAndroidOffscreenView( ...@@ -88,7 +88,7 @@ QAndroidOffscreenView::QAndroidOffscreenView(
qDebug()<<__PRETTY_FUNCTION__<<"Creating object of"<<view_class_name_; qDebug()<<__PRETTY_FUNCTION__<<"Creating object of"<<view_class_name_;
offscreen_view_.reset(new jcGeneric( offscreen_view_.reset(new jcGeneric(
view_class_name_.toAscii() view_class_name_.toLatin1()
, true // Keep ownership , true // Keep ownership
)); ));
......
...@@ -95,9 +95,6 @@ public: ...@@ -95,9 +95,6 @@ public:
* If texture is not ready, the rectangle is filled with fillColor. * If texture is not ready, the rectangle is filled with fillColor.
*/ */
virtual void paintGL(int l, int b, int w, int h); 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 //! Check if Android View already exists
bool isCreated() const; bool isCreated() const;
......
QT += qml quick QT += qml quick androidextras opengl
# Add more folders to ship with the application, here # Add more folders to ship with the application, here
folder_01.source = qml/AndroidWebView_Qt5 folder_01.source = qml/AndroidWebView_Qt5
...@@ -14,8 +14,23 @@ QML_IMPORT_PATH = ...@@ -14,8 +14,23 @@ QML_IMPORT_PATH =
# MOBILITY += # MOBILITY +=
# The .cpp file which was generated for your project. Feel free to hack it. # The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp fboinsgrenderer.cpp logorenderer.cpp SOURCES += main.cpp fboinsgrenderer.cpp logorenderer.cpp \
HEADERS += fboinsgrenderer.h logorenderer.h ../../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 # Installation path
# target.path = # target.path =
...@@ -28,3 +43,8 @@ OTHER_FILES += \ ...@@ -28,3 +43,8 @@ OTHER_FILES += \
main.qml main.qml
RESOURCES += AndroidWebView.qrc 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 @@ ...@@ -39,35 +39,44 @@
****************************************************************************/ ****************************************************************************/
#include "fboinsgrenderer.h" #include "fboinsgrenderer.h"
#include "logorenderer.h"
#include <QtGui/QOpenGLFramebufferObject> #include <QtGui/QOpenGLFramebufferObject>
#include <QtQuick/QQuickWindow> #include <QtQuick/QQuickWindow>
#include <qsgsimpletexturenode.h> #include <qsgsimpletexturenode.h>
class LogoInFboRenderer : public QQuickFramebufferObject::Renderer LogoInFboRenderer::LogoInFboRenderer()
: aview_("WebViewInQML", true, QSize(512, 512))
{ {
public: connect(&aview_, SIGNAL(updated()), this, SLOT(textureUpdated()));
LogoInFboRenderer() aview_.initializeGL();
{ aview_.setFillColor(Qt::red);
logo.initialize(); aview_.loadUrl("http://www.android.com/intl/en/about/");
} }
void render() { void LogoInFboRenderer::render()
logo.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(); update();
} }
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) { QOpenGLFramebufferObject * LogoInFboRenderer::createFramebufferObject(const QSize &size)
{
QOpenGLFramebufferObjectFormat format; QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); // format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(4); format.setSamples(4);
aview_.resize(size);
return new QOpenGLFramebufferObject(size, format); return new QOpenGLFramebufferObject(size, format);
} }
void LogoInFboRenderer::textureUpdated()
{
invalidateFramebufferObject();
}
LogoRenderer logo;
};
QQuickFramebufferObject::Renderer *FboInSGRenderer::createRenderer() const QQuickFramebufferObject::Renderer *FboInSGRenderer::createRenderer() const
{ {
......
...@@ -42,8 +42,7 @@ ...@@ -42,8 +42,7 @@
#define FBOINSGRENDERER_H #define FBOINSGRENDERER_H
#include <QtQuick/QQuickFramebufferObject> #include <QtQuick/QQuickFramebufferObject>
#include <QAndroidOffscreenWebView.h>
class LogoRenderer;
class FboInSGRenderer : public QQuickFramebufferObject class FboInSGRenderer : public QQuickFramebufferObject
{ {
...@@ -52,4 +51,17 @@ public: ...@@ -52,4 +51,17 @@ public:
Renderer *createRenderer() const; 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 #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