BackingStoreVisualizationViewportAccessor.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
  3. */
  4. #include "config.h"
  5. #include "BackingStoreVisualizationViewportAccessor.h"
  6. #include "BackingStore_p.h"
  7. #include <BlackBerryPlatformPrimitives.h>
  8. #include <algorithm>
  9. using BlackBerry::Platform::FloatPoint;
  10. using BlackBerry::Platform::IntPoint;
  11. using BlackBerry::Platform::IntSize;
  12. using BlackBerry::Platform::ViewportAccessor;
  13. namespace BlackBerry {
  14. namespace WebKit {
  15. BackingStoreVisualizationViewportAccessor::BackingStoreVisualizationViewportAccessor(ViewportAccessor* originalAccessor, BackingStorePrivate* backingStorePrivate)
  16. : m_originalAccessor(originalAccessor)
  17. , m_backingStorePrivate(backingStorePrivate)
  18. {
  19. }
  20. IntSize BackingStoreVisualizationViewportAccessor::pixelContentsSize() const
  21. {
  22. return roundToPixelFromDocumentContents(documentContentsRect()).size();
  23. }
  24. IntSize BackingStoreVisualizationViewportAccessor::documentContentsSize() const
  25. {
  26. return m_originalAccessor->documentContentsSize();
  27. }
  28. IntPoint BackingStoreVisualizationViewportAccessor::pixelScrollPosition() const
  29. {
  30. return roundToPixelFromDocumentContents(
  31. toDocumentContents(state()->backingStoreOffset(), state()->scale()));
  32. }
  33. IntPoint BackingStoreVisualizationViewportAccessor::documentScrollPosition() const
  34. {
  35. return roundToDocumentContents(state()->backingStoreOffset(), state()->scale());
  36. }
  37. IntSize BackingStoreVisualizationViewportAccessor::pixelViewportSize() const
  38. {
  39. return m_originalAccessor->pixelViewportSize();
  40. }
  41. IntSize BackingStoreVisualizationViewportAccessor::documentViewportSize() const
  42. {
  43. return roundToDocumentFromPixelContents(pixelViewportRect()).size();
  44. }
  45. IntPoint BackingStoreVisualizationViewportAccessor::destinationSurfaceOffset() const
  46. {
  47. return m_originalAccessor->destinationSurfaceOffset();
  48. }
  49. double BackingStoreVisualizationViewportAccessor::scale() const
  50. {
  51. return state()->scale() / std::max(state()->numberOfTilesWide(), state()->numberOfTilesHigh());
  52. }
  53. BackingStoreGeometry* BackingStoreVisualizationViewportAccessor::state() const
  54. {
  55. return m_backingStorePrivate->frontState();
  56. }
  57. } // namespace WebKit
  58. } // namespace BlackBerry