Import Cobalt 6.14838
Change-Id: I49864fe26f7f6fca3777d185823aa31251e8ae57
diff --git a/src/starboard/raspi/shared/window_internal.cc b/src/starboard/raspi/shared/window_internal.cc
index 532ecd4..cb03c2d 100644
--- a/src/starboard/raspi/shared/window_internal.cc
+++ b/src/starboard/raspi/shared/window_internal.cc
@@ -14,21 +14,19 @@
#include "starboard/raspi/shared/window_internal.h"
-#include <bcm_host.h>
-
#include "starboard/log.h"
namespace {
const int32_t kLayer = 0;
-const DISPMANX_RESOURCE_HANDLE_T kResource = DISPMANX_NO_HANDLE;
} // namespace
-SbWindowPrivate::SbWindowPrivate(DISPMANX_DISPLAY_HANDLE_T display,
- const SbWindowOptions* options)
- : display(display), element(DISPMANX_NO_HANDLE) {
- VC_RECT_T destination_rect;
- VC_RECT_T source_rect;
+using starboard::raspi::shared::DispmanxDisplay;
+using starboard::raspi::shared::DispmanxElement;
+using starboard::raspi::shared::DispmanxRect;
+using starboard::raspi::shared::DispmanxResource;
+SbWindowPrivate::SbWindowPrivate(const DispmanxDisplay& display,
+ const SbWindowOptions* options) {
uint32_t window_width = 0;
uint32_t window_height = 0;
if (options && options->size.width > 0 && options->size.height > 0) {
@@ -41,41 +39,23 @@
SB_DCHECK(result >= 0);
}
- destination_rect.x = 0;
- destination_rect.y = 0;
- destination_rect.width = window_width;
- destination_rect.height = window_height;
-
- source_rect.x = 0;
- source_rect.y = 0;
- // This shift is part of the examples, but unexplained. It appears to work.
- source_rect.width = window_width << 16;
- source_rect.height = window_height << 16;
-
+ DispmanxRect destination_rect(0, 0, window_width, window_height);
+ // The "<< 16"s are part of the examples, but unexplained. It appears to work.
+ DispmanxRect source_rect(0, 0, window_width << 16, window_height << 16);
+ // The window doesn't have an image resource associated with it.
+ DispmanxResource resource;
// Creating a window (called an "element" here, created by adding it to the
// display) must happen within an "update", which seems to represent a sort of
// window manager transaction.
- DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0 /*screen*/);
- SB_DCHECK(update != DISPMANX_NO_HANDLE);
- element = vc_dispmanx_element_add(update, display, kLayer, &destination_rect,
- kResource, &source_rect,
- DISPMANX_PROTECTION_NONE, NULL /*alpha*/,
- NULL /*clamp*/, DISPMANX_NO_ROTATE);
- SB_DCHECK(element != DISPMANX_NO_HANDLE);
- int32_t result = vc_dispmanx_update_submit_sync(update);
- SB_DCHECK(result == 0) << " result=" << result;
-
+ element.reset(new DispmanxElement(display, kLayer, destination_rect, resource,
+ source_rect));
// We can then populate this struct, a pointer to which is what EGL expects as
// a "native window" handle.
- window.element = element;
+ window.element = element->handle();
window.width = window_width;
window.height = window_height;
}
SbWindowPrivate::~SbWindowPrivate() {
- DISPMANX_UPDATE_HANDLE_T update = vc_dispmanx_update_start(0 /*screen*/);
- int32_t result = vc_dispmanx_element_remove(update, element);
- SB_DCHECK(result == 0) << " result=" << result;
- vc_dispmanx_update_submit_sync(update);
- element = DISPMANX_NO_HANDLE;
+ element.reset();
}