summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2015-05-06 10:38:17 (GMT)
committerEmanuele Aina <emanuele.aina@collabora.com>2015-05-07 11:46:30 (GMT)
commitd03ce6fd2c0104477456a826184ebaa9a90b63bf (patch)
tree245e4a3e9ce89bb27545d8ea897efb0a089053c0
parent11ba1d89f7536afec2851943e5e74cfc0c547626 (diff)
downloadWebKit-d03ce6fd2c0104477456a826184ebaa9a90b63bf.tar.gz
WebKit-d03ce6fd2c0104477456a826184ebaa9a90b63bf.tar.xz
[DispmanX] Position elements taking overscan in account
Instead of just positioning DispmanX elements at 0,0 use the mailbox API to get the current overscan offset or center the frame on the screen if the configuration cannot be accessed (as it may be the case on older firmware releases).
-rw-r--r--Source/WebCore/platform/rpi/RedirectedDispmanxWindow.cpp12
-rw-r--r--Source/WebCore/platform/rpi/RedirectedDispmanxWindow.h1
-rw-r--r--Source/WebCore/platform/rpi/VideoCore.cpp25
-rw-r--r--Source/WebCore/platform/rpi/VideoCore.h1
4 files changed, 38 insertions, 1 deletions
diff --git a/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.cpp b/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.cpp
index 6945f02..e88e563 100644
--- a/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.cpp
+++ b/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.cpp
@@ -48,6 +48,7 @@ PassOwnPtr<RedirectedDispmanxWindow> RedirectedDispmanxWindow::create(const IntS
RedirectedDispmanxWindow::RedirectedDispmanxWindow(const IntSize& size)
: m_size(size)
+ , m_anchor()
, m_controlsResourceRect(IntRect())
, m_cursorResourceRect(IntRect())
, m_videoResourceRect(IntRect())
@@ -64,7 +65,16 @@ RedirectedDispmanxWindow::RedirectedDispmanxWindow(const IntSize& size)
, m_changedResources(0)
, m_isFullscreenForMediaElement(false)
{
+ DISPMANX_MODEINFO_T modeinfo;
+
ASSERT(VideoCore::ensureInitialized());
+
+ if (!VideoCore::getOverscanAnchorPoint(m_anchor)) {
+ if (vc_dispmanx_display_get_info(m_dispmanxDisplay, &modeinfo) >= 0) {
+ m_anchor.setX(((int) modeinfo.width - size.width()) / 2);
+ m_anchor.setY(((int) modeinfo.height - size.height()) / 2);
+ }
+ }
}
RedirectedDispmanxWindow::~RedirectedDispmanxWindow()
@@ -244,7 +254,7 @@ void RedirectedDispmanxWindow::updateElement(const DISPMANX_UPDATE_HANDLE_T& dis
VC_RECT_T vcSourceRect, vcDestinationRect;
vc_dispmanx_rect_set(&vcSourceRect, sourceRect.x(), sourceRect.y(), sourceRect.width() << 16, sourceRect.height() << 16);
- vc_dispmanx_rect_set(&vcDestinationRect, destinationRect.x(), destinationRect.y(), destinationRect.width(), destinationRect.height());
+ vc_dispmanx_rect_set(&vcDestinationRect, destinationRect.x() + m_anchor.x(), destinationRect.y() + m_anchor.y(), destinationRect.width(), destinationRect.height());
if (element) {
if (isResourceChanged)
diff --git a/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.h b/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.h
index af586f9..53e6e2d 100644
--- a/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.h
+++ b/Source/WebCore/platform/rpi/RedirectedDispmanxWindow.h
@@ -108,6 +108,7 @@ private:
void updateElement(const DISPMANX_UPDATE_HANDLE_T& dispmanxUpdate, DISPMANX_ELEMENT_HANDLE_T&, const int layer, const DISPMANX_RESOURCE_HANDLE_T&, const IntRect& sourceRect, const IntRect& destinationRect, const bool isResourceChanged, const bool isResourceMoved = false);
IntSize m_size;
+ IntPoint m_anchor;
IntRect m_controlsResourceRect;
IntRect m_cursorResourceRect;
IntRect m_videoResourceRect;
diff --git a/Source/WebCore/platform/rpi/VideoCore.cpp b/Source/WebCore/platform/rpi/VideoCore.cpp
index df45c1a..82f692d 100644
--- a/Source/WebCore/platform/rpi/VideoCore.cpp
+++ b/Source/WebCore/platform/rpi/VideoCore.cpp
@@ -24,6 +24,7 @@
*/
#include "config.h"
+#include "IntRect.h"
#include "VideoCore.h"
#if PLATFORM(RPI)
@@ -31,6 +32,13 @@
#include <fcntl.h>
#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h> /* ioctl */
+
+#define MAJOR_NUM 100
+#define DEVICE_FILE_NAME "/dev/vcio"
+#define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM, 0, char *)
+
namespace WebCore {
enum InitializationStatus {
@@ -60,6 +68,23 @@ bool VideoCore::ensureInitialized()
return true;
}
+bool VideoCore::getOverscanAnchorPoint(IntPoint& anchor)
+{
+ int fd = open(DEVICE_FILE_NAME, 0);
+ unsigned words[8] = {0x28, 0x00, 0x4000a, 0x10, 0x00, 0x00, 0x00, 0x00};
+
+ if (fd < 0)
+ return false;
+
+ bool success = ioctl(fd, IOCTL_MBOX_PROPERTY, words) >= 0;
+ if (success)
+ anchor = IntPoint(words[7], words[5]);
+
+ close(fd);
+
+ return success;
+}
+
} // namespace WebCore
#endif // PLATFORM(RPI)
diff --git a/Source/WebCore/platform/rpi/VideoCore.h b/Source/WebCore/platform/rpi/VideoCore.h
index 0c5bf9b..97998b1 100644
--- a/Source/WebCore/platform/rpi/VideoCore.h
+++ b/Source/WebCore/platform/rpi/VideoCore.h
@@ -48,6 +48,7 @@ namespace WebCore {
class VideoCore {
public:
static bool ensureInitialized();
+ static bool getOverscanAnchorPoint(IntPoint& anchor);
};
} // namespace WebCore