Merge lp:~osomon/webbrowser-app/webview-capture into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 845
Merged at revision: 846
Proposed branch: lp:~osomon/webbrowser-app/webview-capture
Merge into: lp:webbrowser-app
Diff against target: 52 lines (+8/-14)
2 files modified
src/app/webbrowser/item-capture.cpp (+7/-12)
src/app/webbrowser/item-capture.h (+1/-2)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/webview-capture
Reviewer Review Type Date Requested Status
Loïc Molinari (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+244550@code.launchpad.net

Commit message

Optimize the capture functionality.

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/item-capture.cpp'
2--- src/app/webbrowser/item-capture.cpp 2014-12-11 18:51:05 +0000
3+++ src/app/webbrowser/item-capture.cpp 2014-12-12 09:22:26 +0000
4@@ -85,15 +85,11 @@
5 m_request.clear();
6 QQuickShaderEffectTexture* texture =
7 qobject_cast<QQuickShaderEffectTexture*>(textureProvider()->texture());
8- QOpenGLContext* ctx =
9- QQuickItemPrivate::get(this)->sceneGraphRenderContext()->openglContext();
10- if (ctx->makeCurrent(ctx->surface())) {
11- QImage image = texture->toImage().mirrored();
12- if (!image.isNull()) {
13- QString filePath = m_cacheLocation + "/" + request + ".jpg";
14- QtConcurrent::run(this, &ItemCapture::saveImage, image, filePath, m_quality, request);
15- return newNode;
16- }
17+ QImage image = texture->toImage().mirrored();
18+ if (!image.isNull()) {
19+ QString filePath = m_cacheLocation + "/" + request + ".jpg";
20+ QtConcurrent::run(this, &ItemCapture::saveImage, image, filePath, request);
21+ return newNode;
22 }
23 QMetaObject::invokeMethod(this, "captureFinished", Qt::QueuedConnection,
24 Q_ARG(QString, request), Q_ARG(QUrl, QUrl()));
25@@ -111,11 +107,10 @@
26 scheduleUpdate();
27 }
28
29-void ItemCapture::saveImage(const QImage& image, const QString& filePath,
30- const int quality, const QString& request)
31+void ItemCapture::saveImage(const QImage& image, const QString& filePath, const QString& request)
32 {
33 QUrl capture;
34- if (image.save(filePath, 0, quality)) {
35+ if (image.save(filePath, 0, m_quality)) {
36 capture = QUrl::fromLocalFile(filePath);
37 }
38 QMetaObject::invokeMethod(this, "captureFinished", Qt::QueuedConnection,
39
40=== modified file 'src/app/webbrowser/item-capture.h'
41--- src/app/webbrowser/item-capture.h 2014-12-11 18:51:05 +0000
42+++ src/app/webbrowser/item-capture.h 2014-12-12 09:22:26 +0000
43@@ -51,8 +51,7 @@
44 private Q_SLOTS:
45 void onParentChanged(QQuickItem* parent);
46 void onParentVisibleChanged();
47- void saveImage(const QImage& image, const QString& filePath,
48- const int quality, const QString& request);
49+ void saveImage(const QImage& image, const QString& filePath, const QString& request);
50
51 private:
52 QString m_cacheLocation;

Subscribers

People subscribed via source and target branches

to status/vote changes: