Merge lp:~artmello/gallery-app/gallery-app-remove_image_provider into lp:gallery-app
- gallery-app-remove_image_provider
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Florian Boucault |
Approved revision: | 1264 |
Merged at revision: | 1275 |
Proposed branch: | lp:~artmello/gallery-app/gallery-app-remove_image_provider |
Merge into: | lp:gallery-app |
Diff against target: |
804 lines (+12/-622) 12 files modified
rc/qml/MediaViewer/SingleMediaViewer.qml (+1/-0) src/CMakeLists.txt (+0/-3) src/gallery-application.cpp (+0/-8) src/photo/CMakeLists.txt (+7/-2) src/photo/photo-metadata.cpp (+1/-1) src/photoeditor/CMakeLists.txt (+0/-34) src/photoeditor/photo-image-provider.cpp (+0/-443) src/photoeditor/photo-image-provider.h (+0/-124) tests/unittests/mediaobjectfactory/CMakeLists.txt (+1/-2) tests/unittests/photo-metadata/CMakeLists.txt (+1/-2) tests/unittests/photo-metadata/tst_photo-metadata.cpp (+1/-1) tests/unittests/video/CMakeLists.txt (+0/-2) |
To merge this branch: | bzr merge lp:~artmello/gallery-app/gallery-app-remove_image_provider |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Florian Boucault (community) | Needs Fixing | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+282649@code.launchpad.net |
Commit message
Remove photo-image-
Move photo-metadata from photoeditor to photo folder
Description of the change
Remove photo-image-
Move photo-metadata from photoeditor to photo folder
PS Jenkins bot (ps-jenkins) wrote : | # |
Florian Boucault (fboucault) wrote : | # |
Pretty good. Too bad to realise there is still some code duplication (PhotoMetadata). In fact there is a delta between the version in gallery and the one in ui-extras. Can you fix it here? Here is the diff:
- 1264. By Arthur Mello
-
Reduce delta between photo metadata in gallery and in ui-extras
Arthur Mello (artmello) wrote : | # |
I tried to reduce the delta between both versions of photo-metadata. But I don't think we can change the order of exposure time keys on gallery version of it. It is desired that when you import some photo into gallery it shows up in today's event, so when some new file arrives we save the date at Exif.Photo.
Preview Diff
1 | === modified file 'rc/qml/MediaViewer/SingleMediaViewer.qml' |
2 | --- rc/qml/MediaViewer/SingleMediaViewer.qml 2015-11-05 19:04:22 +0000 |
3 | +++ rc/qml/MediaViewer/SingleMediaViewer.qml 2016-01-15 12:56:08 +0000 |
4 | @@ -21,6 +21,7 @@ |
5 | import Ubuntu.Components.Popups 1.3 |
6 | import Ubuntu.Content 1.3 |
7 | import Ubuntu.Thumbnailer 0.1 |
8 | +import Ubuntu.Components.Extras 0.2 |
9 | import Gallery 1.0 |
10 | import "../Components" |
11 | |
12 | |
13 | === modified file 'src/CMakeLists.txt' |
14 | --- src/CMakeLists.txt 2015-02-27 14:07:07 +0000 |
15 | +++ src/CMakeLists.txt 2016-01-15 12:56:08 +0000 |
16 | @@ -6,7 +6,6 @@ |
17 | add_subdirectory(database) |
18 | add_subdirectory(event) |
19 | add_subdirectory(media) |
20 | -add_subdirectory(photoeditor) |
21 | add_subdirectory(medialoader) |
22 | add_subdirectory(photo) |
23 | add_subdirectory(qml) |
24 | @@ -27,7 +26,6 @@ |
25 | ${gallery_event_src_SOURCE_DIR} |
26 | ${gallery_album_src_SOURCE_DIR} |
27 | ${gallery_photo_src_SOURCE_DIR} |
28 | - ${gallery_photoeditor_src_SOURCE_DIR} |
29 | ${gallery_video_src_SOURCE_DIR} |
30 | ${gallery_qml_src_SOURCE_DIR} |
31 | ${CMAKE_BINARY_DIR} |
32 | @@ -62,7 +60,6 @@ |
33 | gallery-media |
34 | gallery-medialoader |
35 | gallery-photo |
36 | - gallery-photoeditor |
37 | gallery-qml |
38 | gallery-util |
39 | gallery-video |
40 | |
41 | === modified file 'src/gallery-application.cpp' |
42 | --- src/gallery-application.cpp 2015-12-16 12:49:12 +0000 |
43 | +++ src/gallery-application.cpp 2016-01-15 12:56:08 +0000 |
44 | @@ -36,9 +36,6 @@ |
45 | // photo |
46 | #include "photo.h" |
47 | |
48 | -// photoeditor |
49 | -#include "photo-image-provider.h" |
50 | - |
51 | // qml |
52 | #include "qml-album-collection-model.h" |
53 | #include "qml-event-collection-model.h" |
54 | @@ -219,11 +216,6 @@ |
55 | { |
56 | m_view->setTitle("Gallery"); |
57 | |
58 | - PhotoImageProvider* provider = new PhotoImageProvider(); |
59 | - provider->setLogging(true); |
60 | - m_view->engine()->addImageProvider(PhotoImageProvider::PROVIDER_ID, |
61 | - provider); |
62 | - |
63 | QSize size = m_formFactors[m_cmdLineParser->formFactor()]; |
64 | |
65 | if (m_cmdLineParser->isPortrait()) |
66 | |
67 | === modified file 'src/photo/CMakeLists.txt' |
68 | --- src/photo/CMakeLists.txt 2015-02-27 13:17:00 +0000 |
69 | +++ src/photo/CMakeLists.txt 2016-01-15 12:56:08 +0000 |
70 | @@ -8,22 +8,27 @@ |
71 | ${gallery_database_src_SOURCE_DIR} |
72 | ${gallery_media_src_SOURCE_DIR} |
73 | ${gallery_medialoader_src_SOURCE_DIR} |
74 | - ${gallery_photoeditor_src_SOURCE_DIR} |
75 | ${gallery_util_src_SOURCE_DIR} |
76 | + ${EXIV2_INCLUDEDIR} |
77 | ${CMAKE_BINARY_DIR} |
78 | ) |
79 | |
80 | set(gallery_photo_HDRS |
81 | photo.h |
82 | + photo-metadata.h |
83 | ) |
84 | |
85 | set(gallery_photo_SRCS |
86 | photo.cpp |
87 | + photo-metadata.cpp |
88 | ) |
89 | |
90 | add_library(${GALLERY_PHOTO_LIB} |
91 | ${gallery_photo_SRCS} |
92 | ) |
93 | |
94 | -qt5_use_modules(${GALLERY_PHOTO_LIB} Widgets Core Quick) |
95 | +qt5_use_modules(${GALLERY_PHOTO_LIB} Widgets Core Qml Quick Xml) |
96 | |
97 | +target_link_libraries( ${GALLERY_PHOTO_LIB} |
98 | + ${EXIV2_LIBRARIES} |
99 | + ) |
100 | |
101 | === renamed file 'src/photoeditor/photo-metadata.cpp' => 'src/photo/photo-metadata.cpp' |
102 | --- src/photoeditor/photo-metadata.cpp 2015-05-06 20:15:54 +0000 |
103 | +++ src/photo/photo-metadata.cpp 2016-01-15 12:56:08 +0000 |
104 | @@ -219,7 +219,7 @@ |
105 | { |
106 | Exiv2::ExifData& exif_data = m_image->exifData(); |
107 | |
108 | - exif_data[EXIF_ORIENTATION_KEY] = orientation; |
109 | + exif_data[EXIF_ORIENTATION_KEY] = (Exiv2::UShortValue)orientation; |
110 | |
111 | if (!m_keysPresent.contains(EXIF_ORIENTATION_KEY)) |
112 | m_keysPresent.insert(EXIF_ORIENTATION_KEY); |
113 | |
114 | === renamed file 'src/photoeditor/photo-metadata.h' => 'src/photo/photo-metadata.h' |
115 | === removed directory 'src/photoeditor' |
116 | === removed file 'src/photoeditor/CMakeLists.txt' |
117 | --- src/photoeditor/CMakeLists.txt 2015-12-16 12:49:12 +0000 |
118 | +++ src/photoeditor/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
119 | @@ -1,34 +0,0 @@ |
120 | -project(gallery_photoeditor_src) |
121 | - |
122 | -set(GALLERY_PHOTOEDITOR_LIB gallery-photoeditor) |
123 | - |
124 | -include_directories( |
125 | - ${gallery_src_SOURCE_DIR} |
126 | - ${gallery_core_src_SOURCE_DIR} |
127 | - ${gallery_database_src_SOURCE_DIR} |
128 | - ${gallery_media_src_SOURCE_DIR} |
129 | - ${gallery_medialoader_src_SOURCE_DIR} |
130 | - ${gallery_util_src_SOURCE_DIR} |
131 | - ${EXIV2_INCLUDEDIR} |
132 | - ${CMAKE_BINARY_DIR} |
133 | - ) |
134 | - |
135 | -set(gallery_photoeditor_HDRS |
136 | - photo-image-provider.h |
137 | - photo-metadata.h |
138 | - ) |
139 | - |
140 | -set(gallery_photoeditor_SRCS |
141 | - photo-image-provider.cpp |
142 | - photo-metadata.cpp |
143 | - ) |
144 | - |
145 | -add_library(${GALLERY_PHOTOEDITOR_LIB} |
146 | - ${gallery_photoeditor_SRCS} |
147 | - ) |
148 | - |
149 | -qt5_use_modules(${GALLERY_PHOTOEDITOR_LIB} Core Qml Quick Xml Widgets) |
150 | - |
151 | -target_link_libraries( ${GALLERY_PHOTOEDITOR_LIB} |
152 | - ${EXIV2_LIBRARIES} |
153 | - ) |
154 | |
155 | === removed file 'src/photoeditor/photo-image-provider.cpp' |
156 | --- src/photoeditor/photo-image-provider.cpp 2015-11-23 17:42:29 +0000 |
157 | +++ src/photoeditor/photo-image-provider.cpp 1970-01-01 00:00:00 +0000 |
158 | @@ -1,443 +0,0 @@ |
159 | -/* |
160 | - * Copyright (C) 2011-2014 Canonical Ltd |
161 | - * |
162 | - * This program is free software: you can redistribute it and/or modify |
163 | - * it under the terms of the GNU General Public License version 3 as |
164 | - * published by the Free Software Foundation. |
165 | - * |
166 | - * This program is distributed in the hope that it will be useful, |
167 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
168 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
169 | - * GNU General Public License for more details. |
170 | - * |
171 | - * You should have received a copy of the GNU General Public License |
172 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
173 | - * |
174 | - * Authors: |
175 | - * Lucas Beeler <lucas@yorba.org> |
176 | - * Jim Nelson <jim@yorba.org> |
177 | - * Ugo Riboni <ugo.riboni@canonical.com> |
178 | - */ |
179 | - |
180 | -#include "photo-image-provider.h" |
181 | -#include "photo-metadata.h" |
182 | - |
183 | -#include <QDebug> |
184 | -#include <QElapsedTimer> |
185 | -#include <QImageReader> |
186 | -#include <QSize> |
187 | -#include <QUrlQuery> |
188 | - |
189 | -const char* PhotoImageProvider::PROVIDER_ID = "photo"; |
190 | -const char* PhotoImageProvider::PROVIDER_ID_SCHEME = "image://photo/"; |
191 | - |
192 | -const long MAX_CACHE_BYTES = 20L * 1024L * 1024L; |
193 | - |
194 | -/*! |
195 | - * \brief PhotoImageProvider::PhotoImageProvider |
196 | - */ |
197 | -PhotoImageProvider::PhotoImageProvider() |
198 | - : QQuickImageProvider(QQuickImageProvider::Image), |
199 | - m_cachedBytes(0), |
200 | - m_logImageLoading(false), |
201 | - m_emitCacheSignals(false) |
202 | -{ |
203 | -} |
204 | - |
205 | -/*! |
206 | - * \brief PhotoImageProvider::~PhotoImageProvider |
207 | - */ |
208 | -PhotoImageProvider::~PhotoImageProvider() |
209 | -{ |
210 | - // NOTE: This assumes that we are not receiving requests any longer |
211 | - while (!m_cachingOrder.isEmpty()) |
212 | - delete m_cache.value(m_cachingOrder.takeFirst()); |
213 | -} |
214 | - |
215 | -#define LOG_IMAGE_STATUS(status) { \ |
216 | - if (m_logImageLoading) \ |
217 | - loggingStr += status; \ |
218 | - } |
219 | - |
220 | -/*! |
221 | - * \brief PhotoImageProvider::requestImage |
222 | - * \param id |
223 | - * \param size |
224 | - * \param requestedSize |
225 | - * \return |
226 | - */ |
227 | -QImage PhotoImageProvider::requestImage(const QString& id, |
228 | - QSize* size, const QSize& requestedSize) |
229 | -{ |
230 | - // for LOG_IMAGE_STATUS |
231 | - QString loggingStr = ""; |
232 | - QElapsedTimer timer; |
233 | - if (m_logImageLoading) timer.start(); |
234 | - |
235 | - QUrl url(id); |
236 | - |
237 | - QImage readyImage; |
238 | - uint bytesLoaded = 0; |
239 | - |
240 | - CachedImage* cachedImage = claimCachedImageEntry(id, loggingStr); |
241 | - Q_ASSERT(cachedImage != NULL); |
242 | - |
243 | - readyImage = fetchCachedImage(cachedImage, requestedSize, &bytesLoaded, |
244 | - loggingStr); |
245 | - if (readyImage.isNull()) |
246 | - LOG_IMAGE_STATUS("load-failure "); |
247 | - |
248 | - releaseCachedImageEntry(cachedImage, bytesLoaded); |
249 | - |
250 | - if (m_logImageLoading) { |
251 | - if (bytesLoaded > 0) { |
252 | - qDebug("%s %s req:%dx%d ret:%dx%d cache:%ldb/%d loaded:%db time:%lldms", qPrintable(loggingStr), |
253 | - qPrintable(id), requestedSize.width(), requestedSize.height(), readyImage.width(), |
254 | - readyImage.height(), m_cachedBytes, m_cache.size(), bytesLoaded, |
255 | - timer.elapsed()); |
256 | - } else { |
257 | - qDebug("%s %s req:%dx%d ret:%dx%d cache:%ldb/%d time:%lldms", qPrintable(loggingStr), |
258 | - qPrintable(id), requestedSize.width(), requestedSize.height(), readyImage.width(), |
259 | - readyImage.height(), m_cachedBytes, m_cache.size(), timer.elapsed()); |
260 | - } |
261 | - } |
262 | - |
263 | - if (size != NULL) |
264 | - *size = readyImage.size(); |
265 | - |
266 | - return readyImage; |
267 | -} |
268 | - |
269 | -/*! |
270 | - * \brief PhotoImageProvider::setLogging enables to print photo loading |
271 | - * times to stout |
272 | - * \param enableLogging |
273 | - */ |
274 | -void PhotoImageProvider::setLogging(bool enableLogging) |
275 | -{ |
276 | - m_logImageLoading = enableLogging; |
277 | -} |
278 | - |
279 | -/*! |
280 | - * \brief PhotoImageProvider::setEmitCacheSignals enabled emitting signals to |
281 | - * track the status of the internal cache. |
282 | - * \param emitCacheSignals |
283 | - */ |
284 | -void PhotoImageProvider::setEmitCacheSignals(bool emitCacheSignals) |
285 | -{ |
286 | - m_emitCacheSignals = emitCacheSignals; |
287 | -} |
288 | - |
289 | -/*! |
290 | - * \brief PhotoImageProvider::claim_cached_image_entry |
291 | - * Returns a CachedImage with an inUseCount > 0, meaning it cannot be |
292 | - * removed from the cache until released |
293 | - * \param id |
294 | - * \param loggingStr |
295 | - * \return |
296 | - */ |
297 | -PhotoImageProvider::CachedImage* PhotoImageProvider::claimCachedImageEntry( |
298 | - const QString& id, QString& loggingStr) |
299 | -{ |
300 | - // lock the cache table and retrieve the element for the cached image; if |
301 | - // not found, create one as a placeholder |
302 | - m_cacheMutex.lock(); |
303 | - |
304 | - CachedImage* cachedImage = m_cache.value(id, NULL); |
305 | - if (cachedImage != NULL) { |
306 | - // remove CachedImage before prepending to FIFO |
307 | - m_cachingOrder.removeOne(id); |
308 | - } else { |
309 | - cachedImage = new CachedImage(id); |
310 | - m_cache.insert(id, cachedImage); |
311 | - LOG_IMAGE_STATUS("new-cache-entry "); |
312 | - } |
313 | - |
314 | - // add to front of FIFO |
315 | - m_cachingOrder.prepend(id); |
316 | - |
317 | - // should be the same size, always |
318 | - Q_ASSERT(m_cache.size() == m_cachingOrder.size()); |
319 | - |
320 | - // claim the CachedImage *while cacheMutex_ is locked* ... this prevents the |
321 | - // CachedImage from being removed from the cache while its being filled |
322 | - cachedImage->cleanCount++; |
323 | - |
324 | - m_cacheMutex.unlock(); |
325 | - |
326 | - return cachedImage; |
327 | -} |
328 | - |
329 | -/*! |
330 | - * \brief PhotoImageProvider::fetch_cached_image Inspects and loads a proper image |
331 | - * Inspects and loads a proper image for this request into the CachedImage |
332 | - * \param cachedImage |
333 | - * \param requestedSize |
334 | - * \param bytesLoaded |
335 | - * \param loggingStr |
336 | - * \return |
337 | - */ |
338 | -QImage PhotoImageProvider::fetchCachedImage(CachedImage *cachedImage, |
339 | - const QSize& requestedSize, |
340 | - uint* bytesLoaded, |
341 | - QString& loggingStr) |
342 | -{ |
343 | - Q_ASSERT(cachedImage != NULL); |
344 | - |
345 | - QString file = QUrl(cachedImage->id).path(); |
346 | - |
347 | - // the final image returned to the user |
348 | - QImage readyImage; |
349 | - Q_ASSERT(readyImage.isNull()); |
350 | - |
351 | - // lock the cached image itself to access |
352 | - cachedImage->imageMutex.lock(); |
353 | - |
354 | - // Depending on the file system used the last modified date of a file |
355 | - // might have a really low resolution (2s for FAT32, 1s for ext3). Therefore |
356 | - // we have to take the worse case and accept that there will be additional cache |
357 | - // misses when an image is requested again just after it has been cached. |
358 | - // There is no alternative to this other than accepting false cache hits, which |
359 | - // would result in bugs in the application. |
360 | - QFileInfo photoFile(file); |
361 | - QDateTime fileLastModified = photoFile.lastModified(); |
362 | - fileLastModified = fileLastModified.addSecs(2); |
363 | - |
364 | - // if image is available, see if a fit |
365 | - if (cachedImage->isCacheHit(requestedSize)) { |
366 | - if (cachedImage->cachedAt > fileLastModified) { |
367 | - readyImage = cachedImage->image; |
368 | - LOG_IMAGE_STATUS("cache-hit "); |
369 | - if (m_emitCacheSignals) Q_EMIT cacheHit(cachedImage->id, requestedSize); |
370 | - } else { |
371 | - // if the file was modified after the image was cached, reload it |
372 | - LOG_IMAGE_STATUS("cache-stale "); |
373 | - if (m_emitCacheSignals) cacheMiss(cachedImage->id, requestedSize, true); |
374 | - } |
375 | - } else { |
376 | - LOG_IMAGE_STATUS("cache-miss "); |
377 | - if (m_emitCacheSignals) cacheMiss(cachedImage->id, requestedSize, false); |
378 | - } |
379 | - |
380 | - if (bytesLoaded != NULL) |
381 | - *bytesLoaded = 0; |
382 | - |
383 | - // if unavailable or stale, load now |
384 | - if (readyImage.isNull()) { |
385 | - QImageReader reader(file); |
386 | - |
387 | - // load file's original size |
388 | - QSize fullSize = reader.size(); |
389 | - QSize loadSize(fullSize); |
390 | - |
391 | - // use scaled load-and-decode if size has been requested |
392 | - if (fullSize.isValid() && (requestedSize.width() > 0 || requestedSize.height() > 0)) { |
393 | - loadSize.scale(requestedSize, Qt::KeepAspectRatio); |
394 | - if (loadSize.width() > fullSize.width() || loadSize.height() > fullSize.height()) |
395 | - loadSize = fullSize; |
396 | - } |
397 | - |
398 | - if (loadSize != fullSize) { |
399 | - LOG_IMAGE_STATUS("scaled-load "); |
400 | - |
401 | - // configure reader for scaled load-and-decode |
402 | - reader.setScaledSize(loadSize); |
403 | - } else { |
404 | - LOG_IMAGE_STATUS("full-load "); |
405 | - } |
406 | - |
407 | - readyImage = reader.read(); |
408 | - if (!readyImage.isNull()) { |
409 | - if (!fullSize.isValid()) |
410 | - fullSize = readyImage.size(); |
411 | - |
412 | - Orientation orientation = TOP_LEFT_ORIGIN; |
413 | - std::unique_ptr<PhotoMetadata> metadata(PhotoMetadata::fromFile(file)); |
414 | - if (metadata.get() != NULL) |
415 | - orientation = metadata->orientation(); |
416 | - |
417 | - // rotate image if not TOP LEFT |
418 | - if (orientation != TOP_LEFT_ORIGIN) { |
419 | - readyImage = readyImage.transformed( |
420 | - OrientationCorrection::fromOrientation(orientation).toTransform()); |
421 | - } |
422 | - |
423 | - // If we are reloading an image, the cache total byte count will be the |
424 | - // difference in size between the old image and the new one (could be negative, for |
425 | - // example in cases of cropping). |
426 | - // If we are not reloading, then the current count will be zero and the total byte |
427 | - // count will be the full size of the newly loaded image. |
428 | - int currentByteCount = readyImage.byteCount(); |
429 | - |
430 | - cachedImage->storeImage(readyImage, fullSize, orientation); |
431 | - if (m_emitCacheSignals) Q_EMIT cacheAdd(cachedImage->id, requestedSize, loadSize); |
432 | - |
433 | - if (bytesLoaded != NULL) |
434 | - *bytesLoaded = readyImage.byteCount() - currentByteCount; |
435 | - } else { |
436 | - qDebug("Unable to load %s: %s", qPrintable(cachedImage->id), |
437 | - qPrintable(reader.errorString())); |
438 | - } |
439 | - } else { |
440 | - // if the image comes from the cache and the requested size is smaller |
441 | - // than what we cached, scale the image before returning it |
442 | - if (requestedSize.isValid()) { |
443 | - readyImage = readyImage.scaled(requestedSize, Qt::KeepAspectRatio); |
444 | - } |
445 | - } |
446 | - |
447 | - cachedImage->imageMutex.unlock(); |
448 | - |
449 | - return readyImage; |
450 | -} |
451 | - |
452 | -/*! |
453 | - * \brief PhotoImageProvider::release_cached_image_entry |
454 | - * Releases a CachedImage to the cache; takes its bytes loaded (0 if nothing |
455 | - * was loaded) and returns the current cached byte total |
456 | - * \param cachedImage |
457 | - * \param bytesLoaded |
458 | - * \param currentCacheEntries |
459 | - */ |
460 | -void PhotoImageProvider::releaseCachedImageEntry |
461 | -(CachedImage *cachedImage, uint bytesLoaded) |
462 | -{ |
463 | - Q_ASSERT(cachedImage != NULL); |
464 | - |
465 | - // update total cached bytes and remove excess bytes |
466 | - m_cacheMutex.lock(); |
467 | - |
468 | - m_cachedBytes += bytesLoaded; |
469 | - |
470 | - // update the CachedImage use count and byte count inside of *cachedMutex_ lock* |
471 | - Q_ASSERT(cachedImage->cleanCount > 0); |
472 | - cachedImage->cleanCount--; |
473 | - if (bytesLoaded != 0) |
474 | - cachedImage->byteCount = bytesLoaded; |
475 | - |
476 | - // trim the cache |
477 | - QList<CachedImage*> dropList; |
478 | - while (m_cachedBytes > MAX_CACHE_BYTES && !m_cachingOrder.isEmpty()) { |
479 | - QString droppedFile = m_cachingOrder.takeLast(); |
480 | - |
481 | - CachedImage* droppedCachedImage = m_cache.value(droppedFile); |
482 | - Q_ASSERT(droppedCachedImage != NULL); |
483 | - |
484 | - // for simplicity, stop when dropped item is in use or doesn't contain |
485 | - // an image (which it won't for too long) ... will clean up next time |
486 | - // through |
487 | - if (droppedCachedImage->cleanCount > 0) { |
488 | - m_cachingOrder.append(droppedFile); |
489 | - |
490 | - break; |
491 | - } |
492 | - |
493 | - // remove from map |
494 | - m_cache.remove(droppedFile); |
495 | - |
496 | - // decrement total cached size |
497 | - m_cachedBytes -= droppedCachedImage->byteCount; |
498 | - Q_ASSERT(m_cachedBytes >= 0); |
499 | - |
500 | - dropList.append(droppedCachedImage); |
501 | - } |
502 | - |
503 | - // coherency is good |
504 | - Q_ASSERT(m_cache.size() == m_cachingOrder.size()); |
505 | - |
506 | - m_cacheMutex.unlock(); |
507 | - |
508 | - // perform actual deletion outside of lock |
509 | - while (!dropList.isEmpty()) |
510 | - delete dropList.takeFirst(); |
511 | -} |
512 | - |
513 | -/*! |
514 | - * \brief PhotoImageProvider::orientSize |
515 | - * \param size |
516 | - * \param orientation |
517 | - * \return |
518 | - */ |
519 | -QSize PhotoImageProvider::orientSize(const QSize& size, Orientation orientation) |
520 | -{ |
521 | - switch (orientation) { |
522 | - case LEFT_TOP_ORIGIN: |
523 | - case RIGHT_TOP_ORIGIN: |
524 | - case RIGHT_BOTTOM_ORIGIN: |
525 | - case LEFT_BOTTOM_ORIGIN: |
526 | - return QSize(size.height(), size.width()); |
527 | - break; |
528 | - |
529 | - default: |
530 | - // no change |
531 | - return size; |
532 | - } |
533 | -} |
534 | - |
535 | -/*! |
536 | - * \brief PhotoImageProvider::CachedImage::CachedImage |
537 | - * \param id the full URI of the image |
538 | - * \param fileName the filename for the URI (the file itself) |
539 | - */ |
540 | -PhotoImageProvider::CachedImage::CachedImage(const QString& id) |
541 | - : id(id), orientation(TOP_LEFT_ORIGIN), cleanCount(0), byteCount(0) |
542 | -{ |
543 | -} |
544 | - |
545 | -/*! |
546 | - * \brief PhotoImageProvider::CachedImage::storeImage |
547 | - * Importand: the following should only be called when imageMutex_ is locked |
548 | - * \param image |
549 | - * \param fullSize |
550 | - * \param orientation |
551 | - */ |
552 | -void PhotoImageProvider::CachedImage::storeImage(const QImage& newImage, |
553 | - const QSize& newFullSize, |
554 | - Orientation newOrientation) |
555 | -{ |
556 | - image = newImage; |
557 | - fullSize = orientSize(newFullSize, orientation); |
558 | - orientation = newOrientation; |
559 | - cachedAt = QDateTime::currentDateTime(); |
560 | -} |
561 | - |
562 | -/*! |
563 | - * \brief PhotoImageProvider::CachedImage::isReady |
564 | - * \return |
565 | - */ |
566 | -bool PhotoImageProvider::CachedImage::isReady() const |
567 | -{ |
568 | - return !image.isNull(); |
569 | -} |
570 | - |
571 | -/*! |
572 | - * \brief PhotoImageProvider::CachedImage::isFullSized |
573 | - * \return |
574 | - */ |
575 | -bool PhotoImageProvider::CachedImage::isFullSized() const |
576 | -{ |
577 | - return isReady() && (image.size() == fullSize); |
578 | -} |
579 | - |
580 | -/*! |
581 | - * \brief PhotoImageProvider::CachedImage::isCacheHit |
582 | - * \param requestedSize |
583 | - * \return |
584 | - */ |
585 | -bool PhotoImageProvider::CachedImage::isCacheHit(const QSize& requestedSize) const |
586 | -{ |
587 | - if (!isReady()) |
588 | - return false; |
589 | - |
590 | - if (isFullSized()) |
591 | - return true; |
592 | - |
593 | - QSize properRequestedSize = orientSize(requestedSize, orientation); |
594 | - |
595 | - if ((properRequestedSize.width() != 0 && image.width() >= properRequestedSize.width()) |
596 | - || (properRequestedSize.height() != 0 && image.height() >= properRequestedSize.height())) { |
597 | - return true; |
598 | - } |
599 | - |
600 | - return false; |
601 | -} |
602 | |
603 | === removed file 'src/photoeditor/photo-image-provider.h' |
604 | --- src/photoeditor/photo-image-provider.h 2015-02-26 20:28:06 +0000 |
605 | +++ src/photoeditor/photo-image-provider.h 1970-01-01 00:00:00 +0000 |
606 | @@ -1,124 +0,0 @@ |
607 | -/* |
608 | - * Copyright (C) 2011-2014 Canonical Ltd |
609 | - * |
610 | - * This program is free software: you can redistribute it and/or modify |
611 | - * it under the terms of the GNU General Public License version 3 as |
612 | - * published by the Free Software Foundation. |
613 | - * |
614 | - * This program is distributed in the hope that it will be useful, |
615 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
616 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
617 | - * GNU General Public License for more details. |
618 | - * |
619 | - * You should have received a copy of the GNU General Public License |
620 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
621 | - * |
622 | - * Authors: |
623 | - * Lucas Beeler <lucas@yorba.org> |
624 | - * Jim Nelson <jim@yorba.org> |
625 | - * Ugo Riboni <ugo.riboni@canonical.com> |
626 | -*/ |
627 | - |
628 | -#ifndef PHOTO_IMAGE_PROVIDER_H_ |
629 | -#define PHOTO_IMAGE_PROVIDER_H_ |
630 | - |
631 | -// util |
632 | -#include "orientation.h" |
633 | - |
634 | -#include <QDateTime> |
635 | -#include <QFileInfo> |
636 | -#include <QImage> |
637 | -#include <QMap> |
638 | -#include <QMutex> |
639 | -#include <QObject> |
640 | -#include <QQuickImageProvider> |
641 | -#include <QSize> |
642 | -#include <QString> |
643 | -#include <QUrl> |
644 | - |
645 | -/*! |
646 | - * We use a custom image provider for the following reasons: |
647 | - * |
648 | - * 1. QML's image loader does not respect EXIF orientation. This provider will |
649 | - * rotate and mirror the image as necessary. |
650 | - * |
651 | - * 2. QML's image caching appears to be directly related to image size (scaling) |
652 | - * which leads to thrashing when animating a thumbnail or loading images at |
653 | - * various sizes. |
654 | - * The strategy here is to cache the largest requested size of the image |
655 | - * and downscale it if smaller versions are requested. This minimizes |
656 | - * expensive JPEG load-and-decodes. |
657 | - * |
658 | - * 3. Logging allows for monitoring of all image I/O, useful when debugging and |
659 | - * optimizing, and signals can be emitted to monitor and test cache operation. |
660 | - * |
661 | - * 4. The QML cache does not check if a file has been modified on disk after it |
662 | - * was cached, but our cache does. You should always set Image.cache to false |
663 | - * when loading images from this provider in QML. |
664 | - */ |
665 | -class PhotoImageProvider : public QObject, public QQuickImageProvider |
666 | -{ |
667 | - Q_OBJECT |
668 | - |
669 | -public: |
670 | - static const char* PROVIDER_ID; |
671 | - static const char* PROVIDER_ID_SCHEME; |
672 | - |
673 | - PhotoImageProvider(); |
674 | - virtual ~PhotoImageProvider(); |
675 | - |
676 | - virtual QImage requestImage(const QString& id, QSize* size, |
677 | - const QSize& requestedSize); |
678 | - |
679 | - void setLogging(bool enableLogging); |
680 | - void setEmitCacheSignals(bool emitCacheSignals); |
681 | - |
682 | -Q_SIGNALS: |
683 | - void cacheHit(QString id, QSize size); |
684 | - void cacheMiss(QString id, QSize size, bool wasStale); |
685 | - void cacheAdd(QString id, QSize size, QSize cachedSize); |
686 | - |
687 | -private: |
688 | - class CachedImage { |
689 | - public: |
690 | - const QString id; |
691 | - QMutex imageMutex; |
692 | - |
693 | - // these fields should only be accessed when imageMutex_ is locked |
694 | - QImage image; |
695 | - QSize fullSize; |
696 | - Orientation orientation; |
697 | - QDateTime cachedAt; |
698 | - |
699 | - // the following should only be accessed when cacheMutex_ is locked; the |
700 | - // counter controls removing a CachedImage entry from the cache table |
701 | - int cleanCount; |
702 | - uint byteCount; |
703 | - |
704 | - CachedImage(const QString& id); |
705 | - |
706 | - void storeImage(const QImage& newImage, const QSize& newFullSize, |
707 | - Orientation newOrientation); |
708 | - bool isFullSized() const; |
709 | - bool isReady() const; |
710 | - bool isCacheHit(const QSize& requestedSize) const; |
711 | - }; |
712 | - |
713 | - QMap<QString, CachedImage*> m_cache; |
714 | - QList<QString> m_cachingOrder; |
715 | - QMutex m_cacheMutex; |
716 | - long m_cachedBytes; |
717 | - bool m_logImageLoading; |
718 | - bool m_emitCacheSignals; |
719 | - |
720 | - static QSize orientSize(const QSize& size, Orientation orientation); |
721 | - |
722 | - CachedImage* claimCachedImageEntry(const QString& id, QString& loggingStr); |
723 | - |
724 | - QImage fetchCachedImage(CachedImage* cachedImage, const QSize& requestedSize, |
725 | - uint* bytesLoaded, QString& loggingStr); |
726 | - |
727 | - void releaseCachedImageEntry(CachedImage* cachedImage, uint bytesLoaded); |
728 | -}; |
729 | - |
730 | -#endif // PHOTO_IMAGE_PROVIDER_H_ |
731 | |
732 | === modified file 'tests/unittests/mediaobjectfactory/CMakeLists.txt' |
733 | --- tests/unittests/mediaobjectfactory/CMakeLists.txt 2015-08-19 19:24:21 +0000 |
734 | +++ tests/unittests/mediaobjectfactory/CMakeLists.txt 2016-01-15 12:56:08 +0000 |
735 | @@ -14,14 +14,13 @@ |
736 | ${gallery_media_src_SOURCE_DIR} |
737 | ${gallery_medialoader_src_SOURCE_DIR} |
738 | ${gallery_photo_src_SOURCE_DIR} |
739 | - ${gallery_photoeditor_src_SOURCE_DIR} |
740 | ${gallery_util_src_SOURCE_DIR} |
741 | ${gallery_video_src_SOURCE_DIR} |
742 | ) |
743 | |
744 | QT5_WRAP_CPP(MEDIAOBJECTFACTORY_MOCS |
745 | ${gallery_database_src_SOURCE_DIR}/media-table.h |
746 | - ${gallery_photoeditor_src_SOURCE_DIR}/photo-metadata.h |
747 | + ${gallery_photo_src_SOURCE_DIR}/photo-metadata.h |
748 | ${gallery_medialoader_src_SOURCE_DIR}/video-metadata.h |
749 | ) |
750 | |
751 | |
752 | === modified file 'tests/unittests/photo-metadata/CMakeLists.txt' |
753 | --- tests/unittests/photo-metadata/CMakeLists.txt 2015-05-08 17:05:20 +0000 |
754 | +++ tests/unittests/photo-metadata/CMakeLists.txt 2016-01-15 12:56:08 +0000 |
755 | @@ -13,7 +13,6 @@ |
756 | ${gallery_media_src_SOURCE_DIR} |
757 | ${gallery_medialoader_src_SOURCE_DIR} |
758 | ${gallery_photo_src_SOURCE_DIR} |
759 | - ${gallery_photoeditor_src_SOURCE_DIR} |
760 | ${gallery_util_src_SOURCE_DIR} |
761 | ${gallery_video_src_SOURCE_DIR} |
762 | ${EXIV2_INCLUDEDIR} |
763 | @@ -32,7 +31,7 @@ |
764 | add_definitions(-DSAMPLE_IMAGE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/images") |
765 | add_executable(photo-metadata |
766 | tst_photo-metadata.cpp |
767 | - ${gallery_photoeditor_src_SOURCE_DIR}/photo-metadata.cpp |
768 | + ${gallery_photo_src_SOURCE_DIR}/photo-metadata.cpp |
769 | ../stubs/album-table_stub.cpp |
770 | ../stubs/database_stub.cpp |
771 | ../stubs/media-table_stub.cpp |
772 | |
773 | === modified file 'tests/unittests/photo-metadata/tst_photo-metadata.cpp' |
774 | --- tests/unittests/photo-metadata/tst_photo-metadata.cpp 2015-05-08 17:05:20 +0000 |
775 | +++ tests/unittests/photo-metadata/tst_photo-metadata.cpp 2016-01-15 12:56:08 +0000 |
776 | @@ -16,7 +16,7 @@ |
777 | |
778 | #include <QtTest/QtTest> |
779 | |
780 | -#include "photoeditor/photo-metadata.h" |
781 | +#include "photo/photo-metadata.h" |
782 | |
783 | class tst_PhotoMetadata : public QObject |
784 | { |
785 | |
786 | === modified file 'tests/unittests/video/CMakeLists.txt' |
787 | --- tests/unittests/video/CMakeLists.txt 2015-02-26 20:28:06 +0000 |
788 | +++ tests/unittests/video/CMakeLists.txt 2016-01-15 12:56:08 +0000 |
789 | @@ -19,7 +19,6 @@ |
790 | ${gallery_media_src_SOURCE_DIR} |
791 | ${gallery_medialoader_src_SOURCE_DIR} |
792 | ${gallery_photo_src_SOURCE_DIR} |
793 | - ${gallery_photoeditor_src_SOURCE_DIR} |
794 | ${gallery_qml_src_SOURCE_DIR} |
795 | ${gallery_util_src_SOURCE_DIR} |
796 | ${gallery_video_src_SOURCE_DIR} |
797 | @@ -47,7 +46,6 @@ |
798 | gallery-media |
799 | gallery-medialoader |
800 | gallery-photo |
801 | - gallery-photoeditor |
802 | gallery-qml |
803 | gallery-util |
804 | gallery-video |
FAILED: Continuous integration, rev:1263 jenkins. qa.ubuntu. com/job/ gallery- app-ci/ 1224/ jenkins. qa.ubuntu. com/job/ gallery- app-vivid- amd64-ci/ 152 jenkins. qa.ubuntu. com/job/ gallery- app-vivid- armhf-ci/ 152 jenkins. qa.ubuntu. com/job/ gallery- app-vivid- armhf-ci/ 152/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ gallery- app-vivid- i386-ci/ 152 jenkins. qa.ubuntu. com/job/ generic- click-autopilot -vivid- touch/367 jenkins. qa.ubuntu. com/job/ generic- click-autopilot -runner- touch/1038 jenkins. qa.ubuntu. com/job/ generic- click-builder- vivid-armhf/ 907 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 26678
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/gallery- app-ci/ 1224/rebuild
http://