Mercurial > hg > svcore
comparison base/ZoomConstraint.h @ 1551:4de4284d0596
Merge from branch zoom
author | Chris Cannam |
---|---|
date | Wed, 10 Oct 2018 08:44:15 +0100 |
parents | 1f72a44f5638 |
children | 05c3fbaec8ea |
comparison
equal
deleted
inserted
replaced
1548:51d6551d5244 | 1551:4de4284d0596 |
---|---|
15 | 15 |
16 #ifndef SV_ZOOM_CONSTRAINT_H | 16 #ifndef SV_ZOOM_CONSTRAINT_H |
17 #define SV_ZOOM_CONSTRAINT_H | 17 #define SV_ZOOM_CONSTRAINT_H |
18 | 18 |
19 #include <stdlib.h> | 19 #include <stdlib.h> |
20 | |
21 #include "ZoomLevel.h" | |
20 | 22 |
21 /** | 23 /** |
22 * ZoomConstraint is a simple interface that describes a limitation on | 24 * ZoomConstraint is a simple interface that describes a limitation on |
23 * the available zoom sizes for a view, for example based on cache | 25 * the available zoom sizes for a view, for example based on cache |
24 * strategy or a (processing) window-size limitation. | 26 * strategy or a (processing) window-size limitation. |
37 RoundUp, | 39 RoundUp, |
38 RoundNearest | 40 RoundNearest |
39 }; | 41 }; |
40 | 42 |
41 /** | 43 /** |
42 * Given the "ideal" block size (frames per pixel) for a given | 44 * Given an "ideal" zoom level (frames per pixel or pixels per |
43 * zoom level, return the nearest viable block size for this | 45 * frame) for a given zoom level, return the nearest viable block |
44 * constraint. | 46 * size for this constraint. |
45 * | 47 * |
46 * For example, if a block size of 1523 frames per pixel is | 48 * For example, if a block size of 1523 frames per pixel is |
47 * requested but the underlying model only supports value | 49 * requested but the underlying model only supports value |
48 * summaries at powers-of-two block sizes, return 1024 or 2048 | 50 * summaries at powers-of-two block sizes, return 1024 or 2048 |
49 * depending on the rounding direction supplied. | 51 * depending on the rounding direction supplied. |
50 */ | 52 */ |
51 virtual int getNearestBlockSize(int requestedBlockSize, | 53 virtual ZoomLevel getNearestZoomLevel(ZoomLevel requestedZoomLevel, |
52 RoundingDirection = RoundNearest) | 54 RoundingDirection = RoundNearest) |
53 const | 55 const |
54 { | 56 { |
55 if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel(); | 57 if (getMaxZoomLevel() < requestedZoomLevel) return getMaxZoomLevel(); |
56 else return requestedBlockSize; | 58 else return requestedZoomLevel; |
57 } | 59 } |
58 | 60 |
61 /** | |
62 * Return the minimum zoom level within range for this constraint. | |
63 * Individual views will probably want to limit this, for example | |
64 * in order to ensure that at least one or two samples fit in the | |
65 * current window size, or in order to save on interpolation cost. | |
66 */ | |
67 virtual ZoomLevel getMinZoomLevel() const { | |
68 return { ZoomLevel::PixelsPerFrame, 512 }; | |
69 } | |
70 | |
59 /** | 71 /** |
60 * Return the maximum zoom level within range for this constraint. | 72 * Return the maximum zoom level within range for this constraint. |
61 * This is quite large -- individual views will probably want to | 73 * This is quite large -- individual views will probably want to |
62 * limit how far a user might reasonably zoom out based on other | 74 * limit how far a user might reasonably zoom out based on other |
63 * factors such as the duration of the file. | 75 * factors such as the duration of the file. |
64 */ | 76 */ |
65 virtual int getMaxZoomLevel() const { return 4194304; } // 2^22, arbitrarily | 77 virtual ZoomLevel getMaxZoomLevel() const { |
78 return { ZoomLevel::FramesPerPixel, 4194304 }; // 2^22, arbitrarily | |
79 } | |
66 }; | 80 }; |
67 | 81 |
68 #endif | 82 #endif |
69 | 83 |