RenderQueue.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef RenderQueue_h
  19. #define RenderQueue_h
  20. #include "TileIndex.h"
  21. #include <BlackBerryPlatformIntRectRegion.h>
  22. #include <BlackBerryPlatformPrimitives.h>
  23. namespace BlackBerry {
  24. namespace WebKit {
  25. class BackingStorePrivate;
  26. class BackingStoreGeometry;
  27. enum SortDirection {
  28. LeftToRight = 0,
  29. RightToLeft,
  30. TopToBottom,
  31. BottomToTop,
  32. NumSortDirections
  33. };
  34. class RenderQueue {
  35. public:
  36. enum JobType { VisibleZoom, VisibleScroll, RegularRender, NonVisibleScroll };
  37. enum ClearJobsFlags {
  38. ClearRegularRenderJobs = 1 << 0,
  39. ClearIncompleteScrollJobs = 1 << 1,
  40. ClearIncompleteZoomJobs = 1 << 2,
  41. ClearCompletedJobs = 1 << 3,
  42. ClearAnyJobs = 0xFFFFFFFF,
  43. DontClearRegularRenderJobs = ClearAnyJobs & ~ClearRegularRenderJobs,
  44. DontClearCompletedJobs = ClearAnyJobs & ~ClearCompletedJobs,
  45. };
  46. RenderQueue(BackingStorePrivate*);
  47. void reset();
  48. bool isEmpty(bool shouldPerformRegularRenderJobs = true) const;
  49. bool hasCurrentRegularRenderJob() const;
  50. bool hasCurrentVisibleZoomJob() const;
  51. bool hasCurrentVisibleScrollJob() const;
  52. bool isCurrentVisibleZoomJob(const TileIndex&) const;
  53. bool isCurrentVisibleZoomJobCompleted(const TileIndex&) const;
  54. bool isCurrentVisibleScrollJob(const TileIndex&) const;
  55. bool isCurrentVisibleScrollJobCompleted(const TileIndex&) const;
  56. bool isCurrentRegularRenderJob(const TileIndex&, BackingStoreGeometry*) const;
  57. bool currentRegularRenderJobBatchUnderPressure() const;
  58. void setCurrentRegularRenderJobBatchUnderPressure(bool);
  59. void eventQueueCycled();
  60. void addToQueue(JobType, const Platform::IntRectRegion&);
  61. void updateSortDirection(int lastDeltaX, int lastDeltaY);
  62. void visibleContentChanged(const Platform::IntRect&);
  63. void backingStoreRectChanging(const Platform::IntRect& oldRect, const Platform::IntRect& newRect);
  64. void clear(const TileIndexList&, BackingStoreGeometry*, ClearJobsFlags);
  65. void clear(const Platform::IntRectRegion&, ClearJobsFlags);
  66. bool regularRenderJobsPreviouslyAttemptedButNotRendered(const Platform::IntRect&);
  67. Platform::IntRectRegion regularRenderJobsNotRenderedRegion() const { return m_regularRenderJobsNotRenderedRegion; }
  68. void render(bool shouldPerformRegularRenderJobs = true);
  69. private:
  70. TileIndexList tileIndexesIntersectingRegion(const Platform::IntRectRegion&, BackingStoreGeometry*) const;
  71. TileIndexList tileIndexesFullyContainedInRegion(const Platform::IntRectRegion&, BackingStoreGeometry*) const;
  72. Platform::IntRectRegion tileRegion(const TileIndexList&, BackingStoreGeometry*) const;
  73. void clearRegions(const Platform::IntRectRegion&, ClearJobsFlags);
  74. void clearTileIndexes(const TileIndexList&, ClearJobsFlags);
  75. // Render items from the queue.
  76. void renderRegularRenderJobs(bool allAtOnceIfPossible);
  77. void renderScrollZoomJobs(TileIndexList* outstandingJobs, TileIndexList* completedJobs, bool allAtOnceIfPossible, bool shouldBlitWhenCompleted);
  78. void scrollZoomJobsCompleted(const TileIndexList& outstandingJobs, TileIndexList* completedJobs, bool shouldBlit);
  79. // Internal method to add to the various queues.
  80. void addToRegularQueue(const Platform::IntRectRegion&);
  81. void addToScrollZoomQueue(const TileIndexList&, TileIndexList* queue);
  82. void quickSort(TileIndexList*);
  83. BackingStorePrivate* m_parent;
  84. // The highest priority queue.
  85. TileIndexList m_visibleZoomJobs;
  86. TileIndexList m_visibleZoomJobsCompleted;
  87. TileIndexList m_visibleScrollJobs;
  88. TileIndexList m_visibleScrollJobsCompleted;
  89. // The lowest priority queue.
  90. TileIndexList m_nonVisibleScrollJobs;
  91. TileIndexList m_nonVisibleScrollJobsCompleted;
  92. // The regular render jobs are in the middle.
  93. Platform::IntRectRegion m_regularRenderJobsRegion;
  94. TileIndexList m_currentRegularRenderJobsBatch;
  95. Platform::IntRectRegion m_currentRegularRenderJobsBatchRegion;
  96. bool m_rectsAddedToRegularRenderJobsInCurrentCycle;
  97. bool m_currentRegularRenderJobsBatchUnderPressure;
  98. // Holds the region of the page that we attempt to render, but the
  99. // backingstore was not in the right place at the time. This will
  100. // be checked before we try to restore a tile to it's last rendered
  101. // place.
  102. Platform::IntRectRegion m_regularRenderJobsNotRenderedRegion;
  103. SortDirection m_primarySortDirection;
  104. SortDirection m_secondarySortDirection;
  105. };
  106. } // namespace WebKit
  107. } // namespace BlackBerry
  108. #endif // RenderQueue_h