ReaderContentTile.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // ReaderContentTile.m
  3. // Reader v2.8.6
  4. //
  5. // Created by Julius Oklamcak on 2011-07-01.
  6. // Copyright © 2011-2015 Julius Oklamcak. All rights reserved.
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights to
  11. // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  12. // of the Software, and to permit persons to whom the Software is furnished to
  13. // do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in all
  16. // copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. //
  25. #import "ReaderContentTile.h"
  26. @implementation ReaderContentTile
  27. #pragma mark - Constants
  28. #define LEVELS_OF_DETAIL 16
  29. #pragma mark - ReaderContentTile class methods
  30. + (CFTimeInterval)fadeDuration
  31. {
  32. return 0.001; // iOS bug (flickering tiles) workaround
  33. }
  34. #pragma mark - ReaderContentTile instance methods
  35. - (instancetype)init
  36. {
  37. if ((self = [super init])) // Initialize superclass
  38. {
  39. self.levelsOfDetail = LEVELS_OF_DETAIL; // Zoom levels
  40. self.levelsOfDetailBias = (LEVELS_OF_DETAIL - 1); // Bias
  41. UIScreen *mainScreen = [UIScreen mainScreen]; // Main screen
  42. CGFloat screenScale = [mainScreen scale]; // Main screen scale
  43. CGRect screenBounds = [mainScreen bounds]; // Main screen bounds
  44. CGFloat w_pixels = (screenBounds.size.width * screenScale);
  45. CGFloat h_pixels = (screenBounds.size.height * screenScale);
  46. CGFloat max = ((w_pixels < h_pixels) ? h_pixels : w_pixels);
  47. CGFloat sizeOfTiles = ((max < 512.0f) ? 512.0f : 1024.0f);
  48. self.tileSize = CGSizeMake(sizeOfTiles, sizeOfTiles);
  49. }
  50. return self;
  51. }
  52. @end