hwc: Update to new API
* Updates HWC to use the Jellybean MR1 API
* Remove qcom_ui which was using parts of the old API
Change-Id: I663363547b193d2318aae88f2256a9baed1e3d4b
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index db6597d..c132f16 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -61,7 +61,7 @@
/*
* Save callback functions registered to HWC
*/
-static void hwc_registerProcs(struct hwc_composer_device* dev,
+static void hwc_registerProcs(struct hwc_composer_device_1* dev,
hwc_procs_t const* procs)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
@@ -72,7 +72,8 @@
ctx->device.reserved_proc[0] = (void*)procs;
}
-static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list)
+static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays,
+ hwc_display_contents_1_t** displays)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
ctx->overlayInUse = false;
@@ -81,40 +82,46 @@
ctx->qbuf->unlockAllPrevious();
return 0;
- if (LIKELY(list)) {
- //reset for this draw round
- VideoOverlay::reset();
- ExtOnly::reset();
+ for (uint32_t i = 0; i <numDisplays; i++) {
+ hwc_display_contents_1_t* list = displays[i];
+ ctx->dpys[i] = list->dpy;
+ //XXX: Actually handle the multiple displays
+ if (LIKELY(list)) {
+ //reset for this draw round
+ VideoOverlay::reset();
+ ExtOnly::reset();
- getLayerStats(ctx, list);
- if(VideoOverlay::prepare(ctx, list)) {
- ctx->overlayInUse = true;
- //Nothing here
- } else if(ExtOnly::prepare(ctx, list)) {
- ctx->overlayInUse = true;
- } else if(UIMirrorOverlay::prepare(ctx, list)) {
- ctx->overlayInUse = true;
- } else if(MDPComp::configure(dev, list)) {
- ctx->overlayInUse = true;
- } else if (0) {
- //Other features
- ctx->overlayInUse = true;
- } else { // Else set this flag to false, otherwise video cases
- // fail in non-overlay targets.
- ctx->overlayInUse = false;
+ getLayerStats(ctx, list);
+ if(VideoOverlay::prepare(ctx, list)) {
+ ctx->overlayInUse = true;
+ //Nothing here
+ } else if(ExtOnly::prepare(ctx, list)) {
+ ctx->overlayInUse = true;
+ } else if(UIMirrorOverlay::prepare(ctx, list)) {
+ ctx->overlayInUse = true;
+ } else if(MDPComp::configure(dev, list)) {
+ ctx->overlayInUse = true;
+ } else if (0) {
+ //Other features
+ ctx->overlayInUse = true;
+ } else { // Else set this flag to false, otherwise video cases
+ // fail in non-overlay targets.
+ ctx->overlayInUse = false;
+ }
}
}
return 0;
}
-static int hwc_eventControl(struct hwc_composer_device* dev,
+static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy,
int event, int enabled)
{
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
private_module_t* m = reinterpret_cast<private_module_t*>(
ctx->mFbDev->common.module);
+ //XXX: Handle dpy
switch(event) {
case HWC_EVENT_VSYNC:
if(ioctl(m->framebuffer->fd, MSMFB_OVERLAY_VSYNC_CTRL, &enabled) < 0)
@@ -130,7 +137,18 @@
return ret;
}
-static int hwc_query(struct hwc_composer_device* dev,
+static int hwc_blank(struct hwc_composer_device_1* dev, int dpy, int blank)
+{
+ //XXX: Handle based on dpy
+ if(blank) {
+ hwc_context_t* ctx = (hwc_context_t*)(dev);
+ ctx->mOverlay->setState(ovutils::OV_CLOSED);
+ ctx->qbuf->unlockAllPrevious();
+ }
+ return 0;
+}
+
+static int hwc_query(struct hwc_composer_device_1* dev,
int param, int* value)
{
hwc_context_t* ctx = (hwc_context_t*)(dev);
@@ -153,29 +171,32 @@
}
-static int hwc_set(hwc_composer_device_t *dev,
- hwc_display_t dpy,
- hwc_surface_t sur,
- hwc_layer_list_t* list)
+static int hwc_set(hwc_composer_device_1 *dev,
+ size_t numDisplays,
+ hwc_display_contents_1_t** displays)
{
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
- if (LIKELY(list)) {
- VideoOverlay::draw(ctx, list);
- ExtOnly::draw(ctx, list);
- MDPComp::draw(ctx, list);
- EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
- UIMirrorOverlay::draw(ctx);
- if(ctx->mExtDisplay->getExternalDisplay())
- ctx->mExtDisplay->commit();
- } else {
- ctx->mOverlay->setState(ovutils::OV_CLOSED);
- ctx->qbuf->unlockAllPrevious();
+ for (uint32_t i = 0; i <numDisplays; i++) {
+ hwc_display_contents_1_t* list = displays[i];
+ //XXX: Actually handle the multiple displays
+ if (LIKELY(list)) {
+ VideoOverlay::draw(ctx, list);
+ ExtOnly::draw(ctx, list);
+ MDPComp::draw(ctx, list);
+ EGLBoolean success = eglSwapBuffers((EGLDisplay)list->dpy,
+ (EGLSurface)list->sur);
+ UIMirrorOverlay::draw(ctx);
+ if(ctx->mExtDisplay->getExternalDisplay())
+ ctx->mExtDisplay->commit();
+ } else {
+ ctx->mOverlay->setState(ovutils::OV_CLOSED);
+ ctx->qbuf->unlockAllPrevious();
+ }
+
+ if(!ctx->overlayInUse)
+ ctx->mOverlay->setState(ovutils::OV_CLOSED);
}
-
- if(!ctx->overlayInUse)
- ctx->mOverlay->setState(ovutils::OV_CLOSED);
-
return ret;
}
@@ -205,13 +226,14 @@
initContext(dev);
//Setup HWC methods
- hwc_methods_t *methods;
- methods = (hwc_methods_t *)malloc(sizeof(*methods));
+ hwc_methods_1_t *methods;
+ methods = (hwc_methods_1_t *) malloc(sizeof(*methods));
memset(methods, 0, sizeof(*methods));
methods->eventControl = hwc_eventControl;
+ methods->blank = hwc_blank;
dev->device.common.tag = HARDWARE_DEVICE_TAG;
- dev->device.common.version = HWC_DEVICE_API_VERSION_0_3;
+ dev->device.common.version = HWC_DEVICE_API_VERSION_1_0;
dev->device.common.module = const_cast<hw_module_t*>(module);
dev->device.common.close = hwc_device_close;
dev->device.prepare = hwc_prepare;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index f14d00f..05b9997 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -113,7 +113,7 @@
return true;
}
-bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx, hwc_layer_list_t *list) {
+bool CopyBit::canUseCopybitForRGB(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
int compositionType =
qdutils::QCCompositionType::getInstance().getCompositionType();
@@ -154,7 +154,7 @@
return false;
}
-unsigned int CopyBit::getRGBRenderingArea(const hwc_layer_list_t *list) {
+unsigned int CopyBit::getRGBRenderingArea(const hwc_display_contents_1_t *list) {
//Calculates total rendering area for RGB layers
unsigned int renderArea = 0;
unsigned int w=0, h=0;
@@ -170,7 +170,7 @@
return renderArea;
}
-bool CopyBit::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
+bool CopyBit::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
int compositionType =
qdutils::QCCompositionType::getInstance().getCompositionType();
@@ -209,7 +209,7 @@
return true;
}
-bool CopyBit::draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy,
+bool CopyBit::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, EGLDisplay dpy,
EGLSurface sur){
// draw layers marked for COPYBIT
int retVal = true;
@@ -228,7 +228,7 @@
return true;
}
-int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer,
+int CopyBit::drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
EGLDisplay dpy,
EGLSurface surface,
functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID,
@@ -459,7 +459,7 @@
return err;
}
-void CopyBit::getLayerResolution(const hwc_layer_t* layer,
+void CopyBit::getLayerResolution(const hwc_layer_1_t* layer,
unsigned int& width, unsigned int& height)
{
hwc_rect_t displayFrame = layer->displayFrame;
@@ -468,7 +468,7 @@
height = displayFrame.bottom - displayFrame.top;
}
-bool CopyBit::validateParams(hwc_context_t *ctx, const hwc_layer_list_t *list) {
+bool CopyBit::validateParams(hwc_context_t *ctx, const hwc_display_contents_1_t *list) {
//Validate parameters
if (!ctx) {
ALOGE("%s:Invalid HWC context", __FUNCTION__);
diff --git a/libhwcomposer/hwc_copybit.h b/libhwcomposer/hwc_copybit.h
index 8390968..ae82b6c 100644
--- a/libhwcomposer/hwc_copybit.h
+++ b/libhwcomposer/hwc_copybit.h
@@ -39,28 +39,28 @@
class CopyBit {
public:
//Sets up members and prepares copybit if conditions are met
- static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Draws layer if the layer is set for copybit in prepare
- static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list, EGLDisplay dpy,
+ static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, EGLDisplay dpy,
EGLSurface sur);
//Receives data from hwc
static void setStats(int yuvCount, int yuvLayerIndex, bool isYuvLayerSkip);
static void updateEglHandles(void*);
- static int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_t *layer,
+ static int drawLayerUsingCopybit(hwc_context_t *dev, hwc_layer_1_t *layer,
EGLDisplay dpy, EGLSurface surface,
functype_eglGetRenderBufferANDROID& LINK_eglGetRenderBufferANDROID,
functype_eglGetCurrentSurface LINK_eglGetCurrentSurface);
static bool canUseCopybitForYUV (hwc_context_t *ctx);
static bool canUseCopybitForRGB (hwc_context_t *ctx,
- hwc_layer_list_t *list);
+ hwc_display_contents_1_t *list);
static bool validateParams (hwc_context_t *ctx,
- const hwc_layer_list_t *list);
+ const hwc_display_contents_1_t *list);
static void closeEglLib();
static void openEglLibAndGethandle();
private:
//Marks layer flags if this feature is used
- static void markFlags(hwc_layer_t *layer);
+ static void markFlags(hwc_layer_1_t *layer);
//returns yuv count
static int getYuvCount();
@@ -78,9 +78,9 @@
static functype_eglGetRenderBufferANDROID LINK_eglGetRenderBufferANDROID;
static functype_eglGetCurrentSurface LINK_eglGetCurrentSurface;
- static unsigned int getRGBRenderingArea (const hwc_layer_list_t *list);
+ static unsigned int getRGBRenderingArea (const hwc_display_contents_1_t *list);
- static void getLayerResolution(const hwc_layer_t* layer,
+ static void getLayerResolution(const hwc_layer_1_t* layer,
unsigned int &width, unsigned int& height);
};
diff --git a/libhwcomposer/hwc_extonly.cpp b/libhwcomposer/hwc_extonly.cpp
index 6793760..ab50972 100644
--- a/libhwcomposer/hwc_extonly.cpp
+++ b/libhwcomposer/hwc_extonly.cpp
@@ -31,7 +31,7 @@
bool ExtOnly::sIsModeOn = false;
//Cache stats, figure out the state, config overlay
-bool ExtOnly::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
+bool ExtOnly::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
sIsModeOn = false;
if(!ctx->mMDP.hasOverlay) {
ALOGD_IF(EXTONLY_DEBUG,"%s, this hw doesnt support overlay",
@@ -44,7 +44,7 @@
chooseState(ctx);
//if the state chosen above is CLOSED, skip this block.
if(sState != ovutils::OV_CLOSED) {
- hwc_layer_t *extLayer = &list->hwLayers[sExtIndex];
+ hwc_layer_1_t *extLayer = &list->hwLayers[sExtIndex];
if(configure(ctx, extLayer)) {
markFlags(extLayer);
sIsModeOn = true;
@@ -75,7 +75,7 @@
ovutils::getStateString(sState));
}
-void ExtOnly::markFlags(hwc_layer_t *layer) {
+void ExtOnly::markFlags(hwc_layer_1_t *layer) {
switch(sState) {
case ovutils::OV_DUAL_DISP:
layer->compositionType = HWC_OVERLAY;
@@ -85,7 +85,7 @@
}
}
-bool ExtOnly::configure(hwc_context_t *ctx, hwc_layer_t *layer) {
+bool ExtOnly::configure(hwc_context_t *ctx, hwc_layer_1_t *layer) {
overlay::Overlay& ov = *(ctx->mOverlay);
ov.setState(sState);
@@ -121,7 +121,7 @@
return true;
}
-bool ExtOnly::draw(hwc_context_t *ctx, hwc_layer_list_t *list)
+bool ExtOnly::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list)
{
if(!sIsModeOn || sExtIndex == -1) {
return true;
diff --git a/libhwcomposer/hwc_extonly.h b/libhwcomposer/hwc_extonly.h
index 26d5fb9..dccd065 100644
--- a/libhwcomposer/hwc_extonly.h
+++ b/libhwcomposer/hwc_extonly.h
@@ -28,9 +28,9 @@
class ExtOnly {
public:
//Sets up members and prepares overlay if conditions are met
- static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Draws layer if this feature is on
- static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Receives data from hwc
static void setStats(int extCount, int extIndex, bool isExtBlock);
//resets values
@@ -39,9 +39,9 @@
//Choose an appropriate overlay state based on conditions
static void chooseState(hwc_context_t *ctx);
//Configures overlay
- static bool configure(hwc_context_t *ctx, hwc_layer_t *layer);
+ static bool configure(hwc_context_t *ctx, hwc_layer_1_t *layer);
//Marks layer flags if this feature is used
- static void markFlags(hwc_layer_t *layer);
+ static void markFlags(hwc_layer_1_t *layer);
//returns ext-only count
static int getExtCount();
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 135d651..787ba9b 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -125,7 +125,7 @@
proc->invalidate(proc);
}
-void MDPComp::reset( hwc_context_t *ctx, hwc_layer_list_t* list ) {
+void MDPComp::reset( hwc_context_t *ctx, hwc_display_contents_1_t* list ) {
sCurrentFrame.count = 0;
free(sCurrentFrame.pipe_layer);
sCurrentFrame.pipe_layer = NULL;
@@ -145,13 +145,13 @@
}
}
-void MDPComp::setLayerIndex(hwc_layer_t* layer, const int pipe_index)
+void MDPComp::setLayerIndex(hwc_layer_1_t* layer, const int pipe_index)
{
layer->flags &= ~HWC_MDPCOMP_INDEX_MASK;
layer->flags |= pipe_index << MDPCOMP_INDEX_OFFSET;
}
-int MDPComp::getLayerIndex(hwc_layer_t* layer)
+int MDPComp::getLayerIndex(hwc_layer_1_t* layer)
{
int byp_index = -1;
@@ -162,7 +162,7 @@
}
return byp_index;
}
-void MDPComp::print_info(hwc_layer_t* layer)
+void MDPComp::print_info(hwc_layer_1_t* layer)
{
hwc_rect_t sourceCrop = layer->sourceCrop;
hwc_rect_t displayFrame = layer->displayFrame;
@@ -185,7 +185,7 @@
/*
* Configures pipe(s) for MDP composition
*/
-int MDPComp::prepare(hwc_context_t *ctx, hwc_layer_t *layer,
+int MDPComp::prepare(hwc_context_t *ctx, hwc_layer_1_t *layer,
mdp_pipe_info& mdp_info) {
int nPipeIndex = mdp_info.index;
@@ -333,8 +333,8 @@
* 5. Overlay in use
*/
-bool MDPComp::is_doable(hwc_composer_device_t *dev,
- const hwc_layer_list_t* list) {
+bool MDPComp::is_doable(hwc_composer_device_1_t *dev,
+ const hwc_display_contents_1_t* list) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
if(!ctx) {
@@ -370,13 +370,13 @@
return true;
}
-void MDPComp::setMDPCompLayerFlags(hwc_layer_list_t* list) {
+void MDPComp::setMDPCompLayerFlags(hwc_display_contents_1_t* list) {
for(int index = 0 ; index < sCurrentFrame.count; index++ )
{
int layer_index = sCurrentFrame.pipe_layer[index].layer_index;
if(layer_index >= 0) {
- hwc_layer_t* layer = &(list->hwLayers[layer_index]);
+ hwc_layer_1_t* layer = &(list->hwLayers[layer_index]);
layer->flags |= HWC_MDPCOMP;
layer->compositionType = HWC_OVERLAY;
@@ -385,7 +385,7 @@
}
}
-void MDPComp::get_layer_info(hwc_layer_t* layer, int& flags) {
+void MDPComp::get_layer_info(hwc_layer_1_t* layer, int& flags) {
private_handle_t* hnd = (private_handle_t*)layer->handle;
@@ -410,7 +410,7 @@
}
}
-int MDPComp::mark_layers(hwc_layer_list_t* list, layer_mdp_info* layer_info,
+int MDPComp::mark_layers(hwc_display_contents_1_t* list, layer_mdp_info* layer_info,
frame_info& current_frame) {
int layer_count = list->numHwLayers;
@@ -424,7 +424,7 @@
//Parse layers from higher z-order
for(int index = layer_count - 1 ; index >= 0; index-- ) {
- hwc_layer_t* layer = &list->hwLayers[index];
+ hwc_layer_1_t* layer = &list->hwLayers[index];
int layer_prop = 0;
get_layer_info(layer, layer_prop);
@@ -476,7 +476,7 @@
}
}
-bool MDPComp::alloc_layer_pipes(hwc_layer_list_t* list,
+bool MDPComp::alloc_layer_pipes(hwc_display_contents_1_t* list,
layer_mdp_info* layer_info, frame_info& current_frame) {
int layer_count = list->numHwLayers;
@@ -490,7 +490,7 @@
layer_count, mdp_count, fallback_count);
for(int index = 0 ; index < layer_count ; index++ ) {
- hwc_layer_t* layer = &list->hwLayers[index];
+ hwc_layer_1_t* layer = &list->hwLayers[index];
if(layer_info[index].can_use_mdp) {
pipe_layer_pair& info = current_frame.pipe_layer[frame_pipe_count];
@@ -518,7 +518,7 @@
}
//returns array of layers and their allocated pipes
-bool MDPComp::parse_and_allocate(hwc_context_t* ctx, hwc_layer_list_t* list,
+bool MDPComp::parse_and_allocate(hwc_context_t* ctx, hwc_display_contents_1_t* list,
frame_info& current_frame ) {
int layer_count = list->numHwLayers;
@@ -584,7 +584,7 @@
}
#endif
-bool MDPComp::setup(hwc_context_t* ctx, hwc_layer_list_t* list) {
+bool MDPComp::setup(hwc_context_t* ctx, hwc_display_contents_1_t* list) {
int nPipeIndex, vsync_wait, isFG;
int numHwLayers = list->numHwLayers;
@@ -632,7 +632,7 @@
for (int index = 0 ; index < current_frame.count; index++) {
int layer_index = current_frame.pipe_layer[index].layer_index;
- hwc_layer_t* layer = &list->hwLayers[layer_index];
+ hwc_layer_1_t* layer = &list->hwLayers[layer_index];
mdp_pipe_info& cur_pipe = current_frame.pipe_layer[index].pipe_index;
if( prepare(ctx, layer, cur_pipe) != 0 ) {
@@ -647,7 +647,7 @@
return true;
}
-void MDPComp::unsetMDPCompLayerFlags(hwc_context_t* ctx, hwc_layer_list_t* list)
+void MDPComp::unsetMDPCompLayerFlags(hwc_context_t* ctx, hwc_display_contents_1_t* list)
{
if (!list)
return;
@@ -660,7 +660,7 @@
}
}
-int MDPComp::draw(hwc_context_t *ctx, hwc_layer_list_t* list) {
+int MDPComp::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
if(!isEnabled()) {
ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled",__FUNCTION__);
@@ -676,7 +676,7 @@
for(unsigned int i = 0; i < list->numHwLayers; i++ )
{
- hwc_layer_t *layer = &list->hwLayers[i];
+ hwc_layer_1_t *layer = &list->hwLayers[i];
if(!(layer->flags & HWC_MDPCOMP)) {
ALOGD_IF(isDebug(), "%s: Layer Not flagged for MDP comp",
@@ -789,7 +789,7 @@
return true;
}
-bool MDPComp::configure(hwc_composer_device_t *dev, hwc_layer_list_t* list) {
+bool MDPComp::configure(hwc_composer_device_1_t *dev, hwc_display_contents_1_t* list) {
if(!isEnabled()) {
ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__);
diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h
index 199204c..5cb2476 100644
--- a/libhwcomposer/hwc_mdpcomp.h
+++ b/libhwcomposer/hwc_mdpcomp.h
@@ -154,10 +154,10 @@
static bool deinit();
/*sets up mdp comp for the current frame */
- static bool configure(hwc_composer_device_t *ctx, hwc_layer_list_t* list);
+ static bool configure(hwc_composer_device_1_t *ctx, hwc_display_contents_1_t* list);
/* draw */
- static int draw(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static int draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
/* store frame stats */
static void setStats(int skipCt) { sSkipCount = skipCt;};
@@ -165,40 +165,40 @@
private:
/* get/set pipe index associated with overlay layers */
- static void setLayerIndex(hwc_layer_t* layer, const int pipe_index);
- static int getLayerIndex(hwc_layer_t* layer);
+ static void setLayerIndex(hwc_layer_1_t* layer, const int pipe_index);
+ static int getLayerIndex(hwc_layer_1_t* layer);
/* set/reset flags for MDPComp */
- static void setMDPCompLayerFlags(hwc_layer_list_t* list);
+ static void setMDPCompLayerFlags(hwc_display_contents_1_t* list);
static void unsetMDPCompLayerFlags(hwc_context_t* ctx,
- hwc_layer_list_t* list);
+ hwc_display_contents_1_t* list);
- static void print_info(hwc_layer_t* layer);
+ static void print_info(hwc_layer_1_t* layer);
/* configure's overlay pipes for the frame */
- static int prepare(hwc_context_t *ctx, hwc_layer_t *layer,
+ static int prepare(hwc_context_t *ctx, hwc_layer_1_t *layer,
mdp_pipe_info& mdp_info);
/* checks for conditions where mdpcomp is not possible */
- static bool is_doable(hwc_composer_device_t *dev,
- const hwc_layer_list_t* list);
+ static bool is_doable(hwc_composer_device_1_t *dev,
+ const hwc_display_contents_1_t* list);
- static bool setup(hwc_context_t* ctx, hwc_layer_list_t* list);
+ static bool setup(hwc_context_t* ctx, hwc_display_contents_1_t* list);
/* parses layer for properties affecting mdp comp */
- static void get_layer_info(hwc_layer_t* layer, int& flags);
+ static void get_layer_info(hwc_layer_1_t* layer, int& flags);
/* iterates through layer list to choose candidate to use overlay */
- static int mark_layers(hwc_layer_list_t* list, layer_mdp_info* layer_info,
+ static int mark_layers(hwc_display_contents_1_t* list, layer_mdp_info* layer_info,
frame_info& current_frame);
- static bool parse_and_allocate(hwc_context_t* ctx, hwc_layer_list_t* list,
+ static bool parse_and_allocate(hwc_context_t* ctx, hwc_display_contents_1_t* list,
frame_info& current_frame );
/* clears layer info struct */
static void reset_layer_mdp_info(layer_mdp_info* layer_mdp_info,int count);
/* allocates pipes to selected candidates */
- static bool alloc_layer_pipes(hwc_layer_list_t* list,
+ static bool alloc_layer_pipes(hwc_display_contents_1_t* list,
layer_mdp_info* layer_info,
frame_info& current_frame);
/* updates variable pipe mode for the current frame */
@@ -209,7 +209,7 @@
static void set_state(State state) { sMDPCompState = state; };
/* reset state */
- static void reset( hwc_context_t *ctx, hwc_layer_list_t* list );
+ static void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list );
/* Is feature enabled */
static bool isEnabled() { return sMaxLayers ? true : false; };
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index 1953c8a..e7ab629 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -59,7 +59,8 @@
while(*str) {
if (!strncmp(str, "VSYNC=", strlen("VSYNC="))) {
timestamp = strtoull(str + strlen("VSYNC="), NULL, 0);
- proc->vsync(proc, 0, timestamp);
+ //XXX: Handle vsync from multiple displays
+ proc->vsync(proc, (int)ctx->dpys[0], timestamp);
}
str += strlen(str) + 1;
if(str - udata >= len)
diff --git a/libhwcomposer/hwc_uimirror.cpp b/libhwcomposer/hwc_uimirror.cpp
index d2b766d..019b1ec 100644
--- a/libhwcomposer/hwc_uimirror.cpp
+++ b/libhwcomposer/hwc_uimirror.cpp
@@ -30,7 +30,7 @@
// Function to get the primary device orientation
// Loops thru the hardware layers and returns the orientation of the max.
// number of layers
-int getDeviceOrientation(hwc_context_t* ctx, hwc_layer_list_t *list) {
+int getDeviceOrientation(hwc_context_t* ctx, hwc_display_contents_1_t *list) {
int orientation = list->hwLayers[0].transform;
if(!ctx) {
ALOGE("In %s: ctx is NULL!!", __FUNCTION__);
@@ -57,7 +57,7 @@
//Prepare the overlay for the UI mirroring
-bool UIMirrorOverlay::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
+bool UIMirrorOverlay::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
sState = ovutils::OV_CLOSED;
sIsUiMirroringOn = false;
@@ -75,7 +75,7 @@
}
// Configure
-bool UIMirrorOverlay::configure(hwc_context_t *ctx, hwc_layer_list_t *list)
+bool UIMirrorOverlay::configure(hwc_context_t *ctx, hwc_display_contents_1_t *list)
{
if (LIKELY(ctx->mOverlay)) {
overlay::Overlay& ov = *(ctx->mOverlay);
diff --git a/libhwcomposer/hwc_uimirror.h b/libhwcomposer/hwc_uimirror.h
index 98f7896..da03c5f 100644
--- a/libhwcomposer/hwc_uimirror.h
+++ b/libhwcomposer/hwc_uimirror.h
@@ -30,12 +30,12 @@
class UIMirrorOverlay {
public:
// Sets up members and prepares overlay if conditions are met
- static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
// Draws layer if this feature is on
static bool draw(hwc_context_t *ctx);
private:
//Configures overlay
- static bool configure(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool configure(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//The chosen overlay state.
static ovutils::eOverlayState sState;
//Flags if this feature is on.
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 8bc8bfc..a2ba499 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#include <EGL/egl.h>
#include <overlay.h>
#include "hwc_utils.h"
#include "mdp_version.h"
@@ -46,6 +47,7 @@
ctx->mMDP.panel = qdutils::MDPVersion::getInstance().getPanelType();
ctx->mCopybitEngine = CopybitEngine::getInstance();
ctx->mExtDisplay = new ExternalDisplay(ctx);
+ memset(ctx->dpys,(int)EGL_NO_DISPLAY, MAX_NUM_DISPLAYS);
MDPComp::init(ctx);
init_uevent_thread(ctx);
@@ -82,11 +84,11 @@
}
- free(const_cast<hwc_methods_t *>(ctx->device.methods));
+ free(const_cast<hwc_methods_1_t *>(ctx->device.methods));
}
-void dumpLayer(hwc_layer_t const* l)
+void dumpLayer(hwc_layer_1_t const* l)
{
ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}"
", {%d,%d,%d,%d}",
@@ -101,7 +103,7 @@
l->displayFrame.bottom);
}
-void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list)
+void getLayerStats(hwc_context_t *ctx, const hwc_display_contents_1_t *list)
{
//Video specific stats
int yuvCount = 0;
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 71c1f73..84309ac 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -18,6 +18,7 @@
#ifndef HWC_UTILS_H
#define HWC_UTILS_H
+#define HWC_REMOVE_DEPRECATED_VERSIONS 1
#include <hardware/hwcomposer.h>
#include <gralloc_priv.h>
@@ -25,6 +26,7 @@
#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
#define FINAL_TRANSFORM_MASK 0x000F
+#define MAX_NUM_DISPLAYS 4 //Yes, this is ambitious
//Fwrd decls
struct hwc_context_t;
@@ -67,8 +69,8 @@
// -----------------------------------------------------------------------------
// Utility functions - implemented in hwc_utils.cpp
-void dumpLayer(hwc_layer_t const* l);
-void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list);
+void dumpLayer(hwc_layer_1_t const* l);
+void getLayerStats(hwc_context_t *ctx, const hwc_display_contents_1_t *list);
void initContext(hwc_context_t *ctx);
void closeContext(hwc_context_t *ctx);
//Crops source buffer against destination and FB boundaries
@@ -76,7 +78,7 @@
const int fbWidth, const int fbHeight);
// Inline utility functions
-static inline bool isSkipLayer(const hwc_layer_t* l) {
+static inline bool isSkipLayer(const hwc_layer_1_t* l) {
return (UNLIKELY(l && (l->flags & HWC_SKIP_LAYER)));
}
@@ -108,7 +110,7 @@
// Initialize uevent thread
void init_uevent_thread(hwc_context_t* ctx);
-inline void getLayerResolution(const hwc_layer_t* layer,
+inline void getLayerResolution(const hwc_layer_1_t* layer,
int& width, int& height)
{
hwc_rect_t displayFrame = layer->displayFrame;
@@ -121,9 +123,10 @@
// HWC context
// This structure contains overall state
struct hwc_context_t {
- hwc_composer_device_t device;
+ hwc_composer_device_1_t device;
int numHwLayers;
int overlayInUse;
+ hwc_display_t dpys[MAX_NUM_DISPLAYS];
//Framebuffer device
framebuffer_device_t *mFbDev;
diff --git a/libhwcomposer/hwc_video.cpp b/libhwcomposer/hwc_video.cpp
index 4e7bc5f..38ac695 100644
--- a/libhwcomposer/hwc_video.cpp
+++ b/libhwcomposer/hwc_video.cpp
@@ -34,7 +34,7 @@
bool VideoOverlay::sIsModeOn = false;
//Cache stats, figure out the state, config overlay
-bool VideoOverlay::prepare(hwc_context_t *ctx, hwc_layer_list_t *list) {
+bool VideoOverlay::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
sIsModeOn = false;
if(!ctx->mMDP.hasOverlay) {
ALOGD_IF(VIDEO_DEBUG,"%s, this hw doesnt support overlay", __FUNCTION__);
@@ -46,8 +46,8 @@
chooseState(ctx);
//if the state chosen above is CLOSED, skip this block.
if(sState != ovutils::OV_CLOSED) {
- hwc_layer_t *yuvLayer = &list->hwLayers[sYuvLayerIndex];
- hwc_layer_t *ccLayer = NULL;
+ hwc_layer_1_t *yuvLayer = &list->hwLayers[sYuvLayerIndex];
+ hwc_layer_1_t *ccLayer = NULL;
if(sCCLayerIndex != -1)
ccLayer = &list->hwLayers[sCCLayerIndex];
@@ -90,7 +90,7 @@
ovutils::getStateString(sState));
}
-void VideoOverlay::markFlags(hwc_layer_t *layer) {
+void VideoOverlay::markFlags(hwc_layer_1_t *layer) {
switch(sState) {
case ovutils::OV_2D_VIDEO_ON_PANEL:
case ovutils::OV_2D_VIDEO_ON_PANEL_TV:
@@ -105,7 +105,7 @@
}
/* Helpers */
-bool configPrimVid(hwc_context_t *ctx, hwc_layer_t *layer) {
+bool configPrimVid(hwc_context_t *ctx, hwc_layer_1_t *layer) {
overlay::Overlay& ov = *(ctx->mOverlay);
private_handle_t *hnd = (private_handle_t *)layer->handle;
ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size);
@@ -183,7 +183,7 @@
return true;
}
-bool configExtVid(hwc_context_t *ctx, hwc_layer_t *layer) {
+bool configExtVid(hwc_context_t *ctx, hwc_layer_1_t *layer) {
overlay::Overlay& ov = *(ctx->mOverlay);
private_handle_t *hnd = (private_handle_t *)layer->handle;
ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size);
@@ -236,7 +236,7 @@
return true;
}
-bool configExtCC(hwc_context_t *ctx, hwc_layer_t *layer) {
+bool configExtCC(hwc_context_t *ctx, hwc_layer_1_t *layer) {
if(layer == NULL)
return true;
@@ -276,8 +276,8 @@
return true;
}
-bool VideoOverlay::configure(hwc_context_t *ctx, hwc_layer_t *yuvLayer,
- hwc_layer_t *ccLayer) {
+bool VideoOverlay::configure(hwc_context_t *ctx, hwc_layer_1_t *yuvLayer,
+ hwc_layer_1_t *ccLayer) {
bool ret = true;
if (LIKELY(ctx->mOverlay)) {
@@ -307,7 +307,7 @@
return ret;
}
-bool VideoOverlay::draw(hwc_context_t *ctx, hwc_layer_list_t *list)
+bool VideoOverlay::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list)
{
if(!sIsModeOn || sYuvLayerIndex == -1) {
return true;
diff --git a/libhwcomposer/hwc_video.h b/libhwcomposer/hwc_video.h
index 62a32a9..40a7c14 100644
--- a/libhwcomposer/hwc_video.h
+++ b/libhwcomposer/hwc_video.h
@@ -26,9 +26,9 @@
class VideoOverlay {
public:
//Sets up members and prepares overlay if conditions are met
- static bool prepare(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Draws layer if this feature is on
- static bool draw(hwc_context_t *ctx, hwc_layer_list_t *list);
+ static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
//Receives data from hwc
static void setStats(int yuvCount, int yuvLayerIndex, bool isYuvLayerSkip,
int ccLayerIndex);
@@ -38,10 +38,10 @@
//Choose an appropriate overlay state based on conditions
static void chooseState(hwc_context_t *ctx);
//Configures overlay for video prim and ext
- static bool configure(hwc_context_t *ctx, hwc_layer_t *yuvlayer,
- hwc_layer_t *ccLayer);
+ static bool configure(hwc_context_t *ctx, hwc_layer_1_t *yuvlayer,
+ hwc_layer_1_t *ccLayer);
//Marks layer flags if this feature is used
- static void markFlags(hwc_layer_t *layer);
+ static void markFlags(hwc_layer_1_t *layer);
//returns yuv count
static int getYuvCount();
diff --git a/libqdutils/qcom_ui.cpp b/libqdutils/qcom_ui.cpp
deleted file mode 100644
index d060439..0000000
--- a/libqdutils/qcom_ui.cpp
+++ /dev/null
@@ -1,863 +0,0 @@
-/*
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
-
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of Code Aurora Forum, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cutils/log.h>
-#include <cutils/memory.h>
-#include <qcom_ui.h>
-#include <utils/comptype.h>
-#include <gralloc_priv.h>
-#include <alloc_controller.h>
-#include <memalloc.h>
-#include <errno.h>
-#include <EGL/eglext.h>
-#include <sys/stat.h>
-#include <SkBitmap.h>
-#include <SkImageEncoder.h>
-#include <Transform.h>
-
-using gralloc::IMemAlloc;
-using gralloc::IonController;
-using gralloc::alloc_data;
-using android::sp;
-namespace {
-
-static android::sp<gralloc::IAllocController> sAlloc = 0;
-
-int reallocate_memory(native_handle_t *buffer_handle, int mReqSize, int usage)
-{
- int ret = 0;
-
-#ifndef NON_QCOM_TARGET
- if (sAlloc == 0) {
- sAlloc = gralloc::IAllocController::getInstance(true);
- }
- if (sAlloc == 0) {
- LOGE("sAlloc is still NULL");
- return -EINVAL;
- }
-
- // Dealloc the old memory
- private_handle_t *hnd = (private_handle_t *)buffer_handle;
- sp<IMemAlloc> memalloc = sAlloc->getAllocator(hnd->flags);
- ret = memalloc->free_buffer((void*)hnd->base, hnd->size, hnd->offset, hnd->fd);
-
- if (ret) {
- LOGE("%s: free_buffer failed", __FUNCTION__);
- return -1;
- }
-
- // Realloc new memory
- alloc_data data;
- data.base = 0;
- data.fd = -1;
- data.offset = 0;
- data.size = mReqSize;
- data.align = getpagesize();
- data.uncached = true;
- int allocFlags = usage;
-
- switch (hnd->format) {
- case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
- case (HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED^HAL_PIXEL_FORMAT_INTERLACE): {
- data.align = 8192;
- } break;
- default: break;
- }
- ret = sAlloc->allocate(data, allocFlags, 0);
- if (ret == 0) {
- hnd->fd = data.fd;
- hnd->base = (int)data.base;
- hnd->offset = data.offset;
- hnd->size = data.size;
- } else {
- LOGE("%s: allocate failed", __FUNCTION__);
- return -EINVAL;
- }
-#endif
- return ret;
-}
-}; // ANONYNMOUS NAMESPACE
-
-/*
- * Gets the number of arguments required for this operation.
- *
- * @param: operation whose argument count is required.
- *
- * @return -EINVAL if the operation is invalid.
- */
-int getNumberOfArgsForOperation(int operation) {
- int num_args = -EINVAL;
- switch(operation) {
- case NATIVE_WINDOW_SET_BUFFERS_SIZE:
- num_args = 1;
- break;
- case NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY:
- num_args = 3;
- break;
- case NATIVE_WINDOW_SET_PIXEL_ASPECT_RATIO:
- num_args = 2;
- break;
- default: LOGE("%s: invalid operation(0x%x)", __FUNCTION__, operation);
- break;
- };
- return num_args;
-}
-
-/*
- * Checks if the format is supported by the GPU.
- *
- * @param: format to check
- *
- * @return true if the format is supported by the GPU.
- */
-bool isGPUSupportedFormat(int format) {
- if (format == HAL_PIXEL_FORMAT_YV12) {
- // We check the YV12 formats, since some Qcom specific formats
- // could have the bits set.
- return true;
- } else if ((format == HAL_PIXEL_FORMAT_RGB_888) ||
- (format == HAL_PIXEL_FORMAT_YCrCb_422_SP) ||
- (format == HAL_PIXEL_FORMAT_YCbCr_422_SP)){
- return false;
- } else if (format & INTERLACE_MASK) {
- // Interlaced content
- return false;
- } else if (format & S3D_FORMAT_MASK) {
- // S3D Formats are not supported by the GPU
- return false;
- }
- return true;
-}
-
-/*
- * Function to check if the allocated buffer is of the correct size.
- * Reallocate the buffer with the correct size, if the size doesn't
- * match
- *
- * @param: handle of the allocated buffer
- * @param: requested size for the buffer
- * @param: usage flags
- *
- * return 0 on success
- */
-int checkBuffer(native_handle_t *buffer_handle, int size, int usage)
-{
- // If the client hasn't set a size, return
- if (0 >= size) {
- return 0;
- }
-
- // Validate the handle
- if (private_handle_t::validate(buffer_handle)) {
- LOGE("%s: handle is invalid", __FUNCTION__);
- return -EINVAL;
- }
-
- // Obtain the private_handle from the native handle
- private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
- if (hnd->size != size) {
- return reallocate_memory(hnd, size, usage);
- }
- return 0;
-}
-
-/*
- * Checks if memory needs to be reallocated for this buffer.
- *
- * @param: Geometry of the current buffer.
- * @param: Required Geometry.
- * @param: Geometry of the updated buffer.
- *
- * @return True if a memory reallocation is required.
- */
-bool needNewBuffer(const qBufGeometry currentGeometry,
- const qBufGeometry requiredGeometry,
- const qBufGeometry updatedGeometry)
-{
- // If the current buffer info matches the updated info,
- // we do not require any memory allocation.
- if (updatedGeometry.width && updatedGeometry.height &&
- updatedGeometry.format) {
- return false;
- }
- if (currentGeometry.width != requiredGeometry.width ||
- currentGeometry.height != requiredGeometry.height ||
- currentGeometry.format != requiredGeometry.format) {
- // Current and required geometry do not match. Allocation
- // required.
- return true;
- }
- return false;
-}
-
-/*
- * Update the geometry of this buffer without reallocation.
- *
- * @param: buffer whose geometry needs to be updated.
- * @param: Updated width
- * @param: Updated height
- * @param: Updated format
- */
-int updateBufferGeometry(sp<GraphicBuffer> buffer, const qBufGeometry updatedGeometry)
-{
- if (buffer == 0) {
- LOGE("%s: graphic buffer is NULL", __FUNCTION__);
- return -EINVAL;
- }
-
- if (!updatedGeometry.width || !updatedGeometry.height ||
- !updatedGeometry.format) {
- // No update required. Return.
- return 0;
- }
- if (buffer->width == updatedGeometry.width &&
- buffer->height == updatedGeometry.height &&
- buffer->format == updatedGeometry.format) {
- // The buffer has already been updated. Return.
- return 0;
- }
-
- // Validate the handle
- if (private_handle_t::validate(buffer->handle)) {
- LOGE("%s: handle is invalid", __FUNCTION__);
- return -EINVAL;
- }
- buffer->width = updatedGeometry.width;
- buffer->height = updatedGeometry.height;
- buffer->format = updatedGeometry.format;
- private_handle_t *hnd = (private_handle_t*)(buffer->handle);
- if (hnd) {
- hnd->width = updatedGeometry.width;
- hnd->height = updatedGeometry.height;
- hnd->format = updatedGeometry.format;
- } else {
- LOGE("%s: hnd is NULL", __FUNCTION__);
- return -EINVAL;
- }
-
- return 0;
-}
-
-/* Update the S3D format of this buffer.
- *
- * @param: buffer whosei S3D format needs to be updated.
- * @param: Updated buffer S3D format
- */
-int updateBufferS3DFormat(sp<GraphicBuffer> buffer, const int s3dFormat)
-{
- if (buffer == 0) {
- LOGE("%s: graphic buffer is NULL", __FUNCTION__);
- return -EINVAL;
- }
-
- buffer->format |= s3dFormat;
- return 0;
-}
-/*
- * Updates the flags for the layer
- *
- * @param: Attribute
- * @param: Identifies if the attribute was enabled or disabled.
- *
- * @return: -EINVAL if the attribute is invalid
- */
-int updateLayerQcomFlags(eLayerAttrib attribute, bool enable, int& currentFlags)
-{
- int ret = 0;
- switch (attribute) {
- case LAYER_UPDATE_STATUS: {
- if (enable)
- currentFlags |= LAYER_UPDATING;
- else
- currentFlags &= ~LAYER_UPDATING;
- } break;
- case LAYER_ASYNCHRONOUS_STATUS: {
- if (enable)
- currentFlags |= LAYER_ASYNCHRONOUS;
- else
- currentFlags &= ~LAYER_ASYNCHRONOUS;
- } break;
- default: LOGE("%s: invalid attribute(0x%x)", __FUNCTION__, attribute);
- break;
- }
- return ret;
-}
-
-/*
- * Gets the per frame HWC flags for this layer.
- *
- * @param: current hwcl flags
- * @param: current layerFlags
- *
- * @return: the per frame flags.
- */
-int getPerFrameFlags(int hwclFlags, int layerFlags) {
- int flags = hwclFlags;
- if (layerFlags & LAYER_UPDATING)
- flags &= ~HWC_LAYER_NOT_UPDATING;
- else
- flags |= HWC_LAYER_NOT_UPDATING;
-
- if (layerFlags & LAYER_ASYNCHRONOUS)
- flags |= HWC_LAYER_ASYNCHRONOUS;
- else
- flags &= ~HWC_LAYER_ASYNCHRONOUS;
-
- return flags;
-}
-
-
-/*
- * Checks if FB is updated by this composition type
- *
- * @param: composition type
- * @return: true if FB is updated, false if not
- */
-
-bool isUpdatingFB(HWCCompositionType compositionType)
-{
- switch(compositionType)
- {
- case HWC_USE_COPYBIT:
- return true;
- default:
- LOGE("%s: invalid composition type(%d)", __FUNCTION__, compositionType);
- return false;
- };
-}
-
-/*
- * Clear Region implementation for C2D/MDP versions.
- *
- * @param: region to be cleared
- * @param: EGL Display
- * @param: EGL Surface
- *
- * @return 0 on success
- */
-int qcomuiClearRegion(Region region, EGLDisplay dpy, EGLSurface sur)
-{
- int ret = 0;
- int compositionType = QCCompositionType::getInstance().getCompositionType();
-
- if (compositionType & COMPOSITION_TYPE_GPU ||
- (compositionType == COMPOSITION_TYPE_DYN|COMPOSITION_TYPE_C2D))
- {
- // For GPU or DYN comp. with C2D, return an error, so that SF can use
- // the GPU to draw the wormhole.
- return -1;
- }
-
- android_native_buffer_t *renderBuffer = (android_native_buffer_t *)
- eglGetRenderBufferANDROID(dpy, sur);
- if (!renderBuffer) {
- LOGE("%s: eglGetRenderBufferANDROID returned NULL buffer",
- __FUNCTION__);
- return -1;
- }
- private_handle_t *fbHandle = (private_handle_t *)renderBuffer->handle;
- if(!fbHandle) {
- LOGE("%s: Framebuffer handle is NULL", __FUNCTION__);
- return -1;
- }
-
- int bytesPerPixel = 4;
- if (HAL_PIXEL_FORMAT_RGB_565 == fbHandle->format) {
- bytesPerPixel = 2;
- }
-
- Region::const_iterator it = region.begin();
- Region::const_iterator const end = region.end();
- const int32_t stride = renderBuffer->stride*bytesPerPixel;
- while (it != end) {
- const Rect& r = *it++;
- uint8_t* dst = (uint8_t*) fbHandle->base +
- (r.left + r.top*renderBuffer->stride)*bytesPerPixel;
- int w = r.width()*bytesPerPixel;
- int h = r.height();
- do {
- if(4 == bytesPerPixel)
- android_memset32((uint32_t*)dst, 0, w);
- else
- android_memset16((uint16_t*)dst, 0, w);
- dst += stride;
- } while(--h);
- }
- return 0;
-}
-
-/*
- * Handles the externalDisplay event
- * HDMI has highest priority compared to WifiDisplay
- * Based on the current and the new display type, decides the
- * external display to be enabled
- *
- * @param: disp - external display type(wfd/hdmi)
- * @param: value - external event(0/1)
- * @param: currdispType - Current enabled external display Type
- * @return: external display type to be enabled
- *
- */
-external_display_type handleEventHDMI(external_display_type disp, int value,
- external_display_type currDispType)
-{
- external_display_type retDispType = currDispType;
- switch(disp) {
- case EXT_TYPE_HDMI:
- if(value)
- retDispType = EXT_TYPE_HDMI;
- else
- retDispType = EXT_TYPE_NONE;
- break;
- case EXT_TYPE_WIFI:
- if(currDispType != EXT_TYPE_HDMI) {
- if(value)
- retDispType = EXT_TYPE_WIFI;
- else
- retDispType = EXT_TYPE_NONE;
- }
- break;
- default:
- LOGE("%s: Unknown External Display Type!!");
- break;
- }
- return retDispType;
-}
-
-// Using global variables for layer dumping since "property_set("debug.sf.dump",
-// property)" does not work.
-int sfdump_countlimit_raw = 0;
-int sfdump_counter_raw = 1;
-char sfdump_propstr_persist_raw[PROPERTY_VALUE_MAX] = "";
-char sfdumpdir_raw[256] = "";
-int sfdump_countlimit_png = 0;
-int sfdump_counter_png = 1;
-char sfdump_propstr_persist_png[PROPERTY_VALUE_MAX] = "";
-char sfdumpdir_png[256] = "";
-
-bool needToDumpLayers()
-{
- bool bDumpLayer = false;
- char sfdump_propstr[PROPERTY_VALUE_MAX];
- time_t timenow;
- tm sfdump_time;
-
- time(&timenow);
- localtime_r(&timenow, &sfdump_time);
-
- if ((property_get("debug.sf.dump.png", sfdump_propstr, NULL) > 0) &&
- (strncmp(sfdump_propstr, sfdump_propstr_persist_png,
- PROPERTY_VALUE_MAX - 1))) {
- // Strings exist & not equal implies it has changed, so trigger a dump
- strncpy(sfdump_propstr_persist_png, sfdump_propstr,
- PROPERTY_VALUE_MAX - 1);
- sfdump_countlimit_png = atoi(sfdump_propstr);
- sfdump_countlimit_png = (sfdump_countlimit_png < 0) ? 0:
- (sfdump_countlimit_png >= LONG_MAX) ? (LONG_MAX - 1):
- sfdump_countlimit_png;
- if (sfdump_countlimit_png) {
- sprintf(sfdumpdir_png,"/data/sfdump.png%04d%02d%02d.%02d%02d%02d",
- sfdump_time.tm_year + 1900, sfdump_time.tm_mon + 1,
- sfdump_time.tm_mday, sfdump_time.tm_hour,
- sfdump_time.tm_min, sfdump_time.tm_sec);
- if (0 == mkdir(sfdumpdir_png, 0777))
- sfdump_counter_png = 0;
- else
- LOGE("sfdump: Error: %s. Failed to create sfdump directory"
- ": %s", strerror(errno), sfdumpdir_png);
- }
- }
-
- if (sfdump_counter_png <= sfdump_countlimit_png)
- sfdump_counter_png++;
-
- if ((property_get("debug.sf.dump", sfdump_propstr, NULL) > 0) &&
- (strncmp(sfdump_propstr, sfdump_propstr_persist_raw,
- PROPERTY_VALUE_MAX - 1))) {
- // Strings exist & not equal implies it has changed, so trigger a dump
- strncpy(sfdump_propstr_persist_raw, sfdump_propstr,
- PROPERTY_VALUE_MAX - 1);
- sfdump_countlimit_raw = atoi(sfdump_propstr);
- sfdump_countlimit_raw = (sfdump_countlimit_raw < 0) ? 0:
- (sfdump_countlimit_raw >= LONG_MAX) ? (LONG_MAX - 1):
- sfdump_countlimit_raw;
- if (sfdump_countlimit_raw) {
- sprintf(sfdumpdir_raw,"/data/sfdump.raw%04d%02d%02d.%02d%02d%02d",
- sfdump_time.tm_year + 1900, sfdump_time.tm_mon + 1,
- sfdump_time.tm_mday, sfdump_time.tm_hour,
- sfdump_time.tm_min, sfdump_time.tm_sec);
- if (0 == mkdir(sfdumpdir_raw, 0777))
- sfdump_counter_raw = 0;
- else
- LOGE("sfdump: Error: %s. Failed to create sfdump directory"
- ": %s", strerror(errno), sfdumpdir_raw);
- }
- }
-
- if (sfdump_counter_raw <= sfdump_countlimit_raw)
- sfdump_counter_raw++;
-
- bDumpLayer = (sfdump_countlimit_png || sfdump_countlimit_raw)? true : false;
- return bDumpLayer;
-}
-
-inline void getHalPixelFormatStr(int format, char pixelformatstr[])
-{
- if (!pixelformatstr)
- return;
-
- switch(format) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- strcpy(pixelformatstr, "RGBA_8888");
- break;
- case HAL_PIXEL_FORMAT_RGBX_8888:
- strcpy(pixelformatstr, "RGBX_8888");
- break;
- case HAL_PIXEL_FORMAT_RGB_888:
- strcpy(pixelformatstr, "RGB_888");
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
- strcpy(pixelformatstr, "RGB_565");
- break;
- case HAL_PIXEL_FORMAT_BGRA_8888:
- strcpy(pixelformatstr, "BGRA_8888");
- break;
- case HAL_PIXEL_FORMAT_RGBA_5551:
- strcpy(pixelformatstr, "RGBA_5551");
- break;
- case HAL_PIXEL_FORMAT_RGBA_4444:
- strcpy(pixelformatstr, "RGBA_4444");
- break;
- case HAL_PIXEL_FORMAT_YV12:
- strcpy(pixelformatstr, "YV12");
- break;
- case HAL_PIXEL_FORMAT_YCbCr_422_SP:
- strcpy(pixelformatstr, "YCbCr_422_SP_NV16");
- break;
- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
- strcpy(pixelformatstr, "YCrCb_420_SP_NV21");
- break;
- case HAL_PIXEL_FORMAT_YCbCr_422_I:
- strcpy(pixelformatstr, "YCbCr_422_I_YUY2");
- break;
- case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
- strcpy(pixelformatstr, "NV12_ENCODEABLE");
- break;
- case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
- strcpy(pixelformatstr, "YCbCr_420_SP_TILED_TILE_4x2");
- break;
- case HAL_PIXEL_FORMAT_YCbCr_420_SP:
- strcpy(pixelformatstr, "YCbCr_420_SP");
- break;
- case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
- strcpy(pixelformatstr, "YCrCb_420_SP_ADRENO");
- break;
- case HAL_PIXEL_FORMAT_YCrCb_422_SP:
- strcpy(pixelformatstr, "YCrCb_422_SP");
- break;
- case HAL_PIXEL_FORMAT_R_8:
- strcpy(pixelformatstr, "R_8");
- break;
- case HAL_PIXEL_FORMAT_RG_88:
- strcpy(pixelformatstr, "RG_88");
- break;
- case HAL_PIXEL_FORMAT_INTERLACE:
- strcpy(pixelformatstr, "INTERLACE");
- break;
- default:
- sprintf(pixelformatstr, "Unknown0x%X", format);
- break;
- }
-}
-
-void dumpLayer(int moduleCompositionType, int listFlags, size_t layerIndex,
- hwc_layer_t hwLayers[])
-{
- char dumplogstr_png[128] = "";
- char dumplogstr_raw[128] = "";
- if (sfdump_counter_png <= sfdump_countlimit_png) {
- sprintf(dumplogstr_png, "[png-dump-frame: %03d of %03d] ",
- sfdump_counter_png, sfdump_countlimit_png);
- }
- if (sfdump_counter_raw <= sfdump_countlimit_raw) {
- sprintf(dumplogstr_raw, "[raw-dump-frame: %03d of %03d]",
- sfdump_counter_raw, sfdump_countlimit_raw);
- }
- if (NULL == hwLayers) {
- LOGE("sfdump: Error.%s%sLayer[%d] No hwLayers to dump.",
- dumplogstr_raw, dumplogstr_png, layerIndex);
- return;
- }
- hwc_layer *layer = &hwLayers[layerIndex];
- hwc_rect_t sourceCrop = layer->sourceCrop;
- hwc_rect_t displayFrame = layer->displayFrame;
- private_handle_t *hnd = (private_handle_t *)layer->handle;
- char pixelformatstr[32] = "None";
- uint32_t transform = layer->transform & FINAL_TRANSFORM_MASK;
-
- if (hnd)
- getHalPixelFormatStr(hnd->format, pixelformatstr);
-
- LOGE("sfdump: %s%s[%s]-Composition, Layer[%d] SrcBuff[%dx%d] "
- "SrcCrop[%dl, %dt, %dr, %db] "
- "DispFrame[%dl, %dt, %dr, %db] Composition-type = %s, Format = %s, "
- "Orientation = %s, Flags = %s%s%s%s%s%s%s%s%s%s",
- dumplogstr_raw, dumplogstr_png,
- (moduleCompositionType == COMPOSITION_TYPE_GPU)? "GPU":
- (moduleCompositionType == COMPOSITION_TYPE_MDP)? "MDP":
- (moduleCompositionType == COMPOSITION_TYPE_C2D)? "C2D":
- (moduleCompositionType == COMPOSITION_TYPE_CPU)? "CPU":
- (moduleCompositionType == COMPOSITION_TYPE_DYN)? "DYN": "???",
- layerIndex,
- (hnd)? hnd->width : -1, (hnd)? hnd->height : -1,
- sourceCrop.left, sourceCrop.top,
- sourceCrop.right, sourceCrop.bottom,
- displayFrame.left, displayFrame.top,
- displayFrame.right, displayFrame.bottom,
- (layer->compositionType == HWC_FRAMEBUFFER)? "Framebuffer (OpenGL ES)":
- (layer->compositionType == HWC_OVERLAY)? "Overlay":
- (layer->compositionType == HWC_USE_COPYBIT)? "Copybit": "???",
- pixelformatstr,
- (transform == Transform::ROT_0)? "ROT_0":
- (transform == Transform::FLIP_H)? "FLIP_H":
- (transform == Transform::FLIP_V)? "FLIP_V":
- (transform == Transform::ROT_90)? "ROT_90":
- (transform == Transform::ROT_180)? "ROT_180":
- (transform == Transform::ROT_270)? "ROT_270":
- (transform == Transform::ROT_INVALID)? "ROT_INVALID":"???",
- (layer->flags == 0)? "[None]":"",
- (layer->flags & HWC_SKIP_LAYER)? "[Skip layer]":"",
- (layer->flags & HWC_LAYER_NOT_UPDATING)? "[Layer not updating]":"",
- (layer->flags & HWC_COMP_BYPASS)? "[Bypass]":"",
- (layer->flags & HWC_BYPASS_RESERVE_0)? "[Bypass Reserve 0]":"",
- (layer->flags & HWC_BYPASS_RESERVE_1)? "[Bypass Reserve 1]":"",
- (listFlags & HWC_GEOMETRY_CHANGED)? "[List: Geometry Changed]":"",
- (listFlags & HWC_SKIP_COMPOSITION)? "[List: Skip Composition]":"");
-
- if (NULL == hnd) {
- LOGE("sfdump: %s%sLayer[%d] private-handle is invalid.",
- dumplogstr_raw, dumplogstr_png, layerIndex);
- return;
- }
-
- if ((sfdump_counter_png <= sfdump_countlimit_png) && hnd->base) {
- bool bResult = false;
- char sfdumpfile_name[256];
- SkBitmap *tempSkBmp = new SkBitmap();
- SkBitmap::Config tempSkBmpConfig = SkBitmap::kNo_Config;
- sprintf(sfdumpfile_name, "%s/sfdump%03d_layer%d.png", sfdumpdir_png,
- sfdump_counter_png, layerIndex);
-
- switch (hnd->format) {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- tempSkBmpConfig = SkBitmap::kARGB_8888_Config;
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
- case HAL_PIXEL_FORMAT_RGBA_5551:
- case HAL_PIXEL_FORMAT_RGBA_4444:
- tempSkBmpConfig = SkBitmap::kRGB_565_Config;
- break;
- case HAL_PIXEL_FORMAT_RGB_888:
- default:
- tempSkBmpConfig = SkBitmap::kNo_Config;
- break;
- }
- if (SkBitmap::kNo_Config != tempSkBmpConfig) {
- tempSkBmp->setConfig(tempSkBmpConfig, hnd->width, hnd->height);
- tempSkBmp->setPixels((void*)hnd->base);
- bResult = SkImageEncoder::EncodeFile(sfdumpfile_name,
- *tempSkBmp, SkImageEncoder::kPNG_Type, 100);
- LOGE("sfdump: %sDumped Layer[%d] to %s: %s", dumplogstr_png,
- layerIndex, sfdumpfile_name, bResult ? "Success" : "Fail");
- }
- else {
- LOGE("sfdump: %sSkipping Layer[%d] dump: Unsupported layer "
- "format %s for png encoder.", dumplogstr_png, layerIndex,
- pixelformatstr);
- }
- delete tempSkBmp; // Calls SkBitmap::freePixels() internally.
- }
-
- if ((sfdump_counter_raw <= sfdump_countlimit_raw) && hnd->base) {
- char sfdumpfile_name[256];
- bool bResult = false;
- sprintf(sfdumpfile_name, "%s/sfdump%03d_layer%d_%dx%d_%s.raw",
- sfdumpdir_raw,
- sfdump_counter_raw, layerIndex, hnd->width, hnd->height,
- pixelformatstr);
- FILE* fp = fopen(sfdumpfile_name, "w+");
- if (fp != NULL) {
- bResult = (bool) fwrite((void*)hnd->base, hnd->size, 1, fp);
- fclose(fp);
- }
- LOGE("sfdump: %s Dumped Layer[%d] to %s: %s", dumplogstr_raw,
- layerIndex, sfdumpfile_name, bResult ? "Success" : "Fail");
- }
-}
-
-bool needsAspectRatio (int wRatio, int hRatio) {
- return ((wRatio != DEFAULT_WIDTH_RATIO) || (hRatio != DEFAULT_HEIGHT_RATIO));
-}
-
-void applyPixelAspectRatio (int wRatio, int hRatio, int orientation, int maxWidth,
- int maxHeight, Rect& visibleRect, GLfloat mVertices[][2]) {
-
- if ((wRatio == 0) || (hRatio == 0))
- return;
-
- float wDelta = 0;
- float hDelta = 0;
- float aspectRatio;
- float displayRatio;
- float new_width, new_height;
- float old_width = abs(visibleRect.right - visibleRect.left);
- float old_height = abs(visibleRect.bottom - visibleRect.top);
-
- if (orientation == Transform::ROT_INVALID) {
- // During animation, no defined orientation, rely on mTransformedBounds
- if (old_width >= old_height)
- orientation = Transform::ROT_0;
- else
- orientation = Transform::ROT_90;
- }
-
- switch (orientation) {
-
- case Transform::ROT_0:
- case Transform::ROT_180:
-
- // Calculated Aspect Ratio = Original Aspect Ratio x Pixel Aspect Ratio
- aspectRatio = (old_width * wRatio) / (old_height * hRatio);
- displayRatio = (float)maxWidth / (float)maxHeight;
-
- if (aspectRatio >= displayRatio) {
- new_height = old_width / aspectRatio;
- if (new_height > maxHeight) {
- new_height = maxHeight;
- new_width = new_height * aspectRatio;
- wDelta = (new_width - old_width) / 2;
- }
- hDelta = (new_height - old_height) / 2;
- } else {
- new_width = old_height * aspectRatio;
- if (new_width > maxWidth) {
- new_width = maxWidth;
- new_height = new_width / aspectRatio;
- hDelta = (new_height - old_height) / 2;
- }
- wDelta = (new_width - old_width) / 2;
- }
-
- if (hDelta != 0) {
- visibleRect.top -= hDelta;
- visibleRect.bottom += hDelta;
-
- // Set mVertices for GPU fallback (During rotation)
- if (orientation == Transform::ROT_0) {
- mVertices[1][1] = mVertices[2][1] = visibleRect.top;
- mVertices[0][1] = mVertices[3][1] = visibleRect.bottom;
- } else {
- mVertices[0][1] = mVertices[3][1] = visibleRect.top;
- mVertices[1][1] = mVertices[2][1] = visibleRect.bottom;
- }
- }
-
- if (wDelta != 0) {
- visibleRect.left -= wDelta;
- visibleRect.right += wDelta;
-
- // Set mVertices for GPU fallback (During rotation)
- mVertices[0][0] = mVertices[1][0] = visibleRect.left;
- mVertices[2][0] = mVertices[3][0] = visibleRect.right;
- }
- break;
-
- case Transform::ROT_90:
- case Transform::ROT_270:
-
- // Calculated Aspect Ratio = Original Aspect Ratio x Pixel Aspect Ratio
- aspectRatio = (old_height * wRatio) / (old_width * hRatio);
- displayRatio = (float)maxHeight / (float)maxWidth;
-
- if (aspectRatio >= displayRatio) {
- new_height = old_width * aspectRatio;
- if (new_height > maxHeight) {
- new_height = maxHeight;
- new_width = new_height / aspectRatio;
- wDelta = (new_width - old_width) / 2;
- }
- hDelta = (new_height - old_height) / 2;
- } else {
- new_width = old_height / aspectRatio;
- if (new_width > maxWidth) {
- new_width = maxWidth;
- new_height = new_width * aspectRatio;
- hDelta = (new_height - old_height) / 2;
- }
- wDelta = (new_width - old_width) / 2;
- }
-
- if (hDelta != 0) {
- visibleRect.top -= hDelta;
- visibleRect.bottom += hDelta;
-
- // Set mVertices for GPU fallback (During rotation)
- if (orientation == Transform::ROT_90) {
- mVertices[2][1] = mVertices[3][1] = visibleRect.top;
- mVertices[0][1] = mVertices[1][1] = visibleRect.bottom;
- } else {
- mVertices[0][1] = mVertices[1][1] = visibleRect.top;
- mVertices[2][1] = mVertices[3][1] = visibleRect.bottom;
- }
- }
-
- if (wDelta != 0) {
- visibleRect.left -= wDelta;
- visibleRect.right += wDelta;
-
- // Set mVertices for GPU fallback (During rotation)
- if (orientation == Transform::ROT_90) {
- mVertices[1][0] = mVertices[2][0] = visibleRect.left;
- mVertices[0][0] = mVertices[3][0] = visibleRect.right;
- } else {
- mVertices[0][0] = mVertices[3][0] = visibleRect.left;
- mVertices[1][0] = mVertices[2][0] = visibleRect.right;
- }
- }
- break;
-
- default: // Handled above.
- break;
-
- }
-}
-
-
diff --git a/libqdutils/qcom_ui.h b/libqdutils/qcom_ui.h
deleted file mode 100644
index 6a96978..0000000
--- a/libqdutils/qcom_ui.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
-
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of Code Aurora Forum, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INCLUDE_LIBQCOM_UI
-#define INCLUDE_LIBQCOM_UI
-
-#include <cutils/native_handle.h>
-#include <ui/GraphicBuffer.h>
-#include <hardware/hwcomposer.h>
-#include <ui/Region.h>
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-#include <utils/Singleton.h>
-#include <cutils/properties.h>
-
-using namespace android;
-using android::sp;
-using android::GraphicBuffer;
-
-#define HWC_BYPASS_INDEX_MASK 0x00000030
-#define DEFAULT_WIDTH_RATIO 1
-#define DEFAULT_HEIGHT_RATIO 1
-
-/*
- * Qcom specific Native Window perform operations
- */
-enum {
- NATIVE_WINDOW_SET_BUFFERS_SIZE = 0x10000000,
- NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY = 0x20000000,
- NATIVE_WINDOW_SET_S3D_FORMAT = 0x40000000,
- NATIVE_WINDOW_SET_PIXEL_ASPECT_RATIO = 0x80000000,
-};
-
-/*
- * Layer Attributes
- */
-enum eLayerAttrib {
- LAYER_UPDATE_STATUS,
- LAYER_ASYNCHRONOUS_STATUS,
-};
-
-/*
- * Layer Flags
- */
-enum {
- LAYER_UPDATING = 1<<0,
- LAYER_ASYNCHRONOUS = 1<<1,
-};
-
-/*
- * Layer Transformation - refers to Layer::setGeometry()
- */
-#define SHIFT_SRC_TRANSFORM 4
-#define SRC_TRANSFORM_MASK 0x00F0
-#define FINAL_TRANSFORM_MASK 0x000F
-
-/*
- * Flags set by the layer and sent to HWC
- */
-enum {
- HWC_LAYER_NOT_UPDATING = 0x00000002,
- HWC_LAYER_ASYNCHRONOUS = 0x00000004,
- HWC_COMP_BYPASS = 0x10000000,
- HWC_USE_EXT_ONLY = 0x20000000, //Layer displayed on external only
- HWC_USE_EXT_BLOCK = 0x40000000, //Layer displayed on external only
- HWC_BYPASS_RESERVE_0 = 0x00000010,
- HWC_BYPASS_RESERVE_1 = 0x00000020,
-};
-
-/* Events to the Display HAL perform function
- As of now used for external display related such as
- connect, disconnect, orientation, video started etc.,
- */
-enum {
- EVENT_EXTERNAL_DISPLAY, // External display on/off Event
- EVENT_VIDEO_OVERLAY, // Video Overlay start/stop Event
- EVENT_ORIENTATION_CHANGE, // Orientation Change Event
- EVENT_OVERLAY_STATE_CHANGE, // Overlay State Change Event
- EVENT_OPEN_SECURE_START, // Start of secure session setup config by stagefright
- EVENT_OPEN_SECURE_END, // End of secure session setup config by stagefright
- EVENT_CLOSE_SECURE_START, // Start of secure session teardown config
- EVENT_CLOSE_SECURE_END, // End of secure session teardown config
- EVENT_RESET_POSTBUFFER, // Reset post framebuffer mutex
- EVENT_WAIT_POSTBUFFER, // Wait until post framebuffer returns
-};
-
-// Video information sent to framebuffer HAl
-// used for handling UI mirroring.
-enum {
- VIDEO_OVERLAY_ENDED = 0,
- VIDEO_2D_OVERLAY_STARTED,
- VIDEO_3D_OVERLAY_STARTED
-};
-
-// Information about overlay state change
-enum {
- OVERLAY_STATE_CHANGE_START = 0,
- OVERLAY_STATE_CHANGE_END
-};
-
-/*
- * Structure to hold the buffer geometry
- */
-struct qBufGeometry {
- int width;
- int height;
- int format;
- void set(int w, int h, int f) {
- width = w;
- height = h;
- format = f;
- }
-};
-
-#if 0
-class QCBaseLayer
-{
- // int mS3DFormat;
- int32_t mComposeS3DFormat;
- public:
- QCBaseLayer()
- {
- mComposeS3DFormat = 0;
- }
- enum { // S3D formats
- eS3D_SIDE_BY_SIDE = 0x10000,
- eS3D_TOP_BOTTOM = 0x20000
- };
- /*
- virtual status_t setStereoscopic3DFormat(int format) { mS3DFormat = format; return 0; }
- virtual int getStereoscopic3DFormat() const { return mS3DFormat; }
- */
- void setS3DComposeFormat (int32_t hints)
- {
- if (hints & HWC_HINT_DRAW_S3D_SIDE_BY_SIDE)
- mComposeS3DFormat = eS3D_SIDE_BY_SIDE;
- else if (hints & HWC_HINT_DRAW_S3D_TOP_BOTTOM)
- mComposeS3DFormat = eS3D_TOP_BOTTOM;
- else
- mComposeS3DFormat = 0;
- }
- int32_t needsS3DCompose () const { return mComposeS3DFormat; }
-};
-#endif
-
-/*
- * Function to check if the allocated buffer is of the correct size.
- * Reallocate the buffer with the correct size, if the size doesn't
- * match
- *
- * @param: handle of the allocated buffer
- * @param: requested size for the buffer
- * @param: usage flags
- *
- * return 0 on success
- */
-int checkBuffer(native_handle_t *buffer_handle, int size, int usage);
-
-/*
- * Checks if the format is supported by the GPU.
- *
- * @param: format to check
- *
- * @return true if the format is supported by the GPU.
- */
-bool isGPUSupportedFormat(int format);
-
-
-/*
- * Gets the number of arguments required for this operation.
- *
- * @param: operation whose argument count is required.
- *
- * @return -EINVAL if the operation is invalid.
- */
-int getNumberOfArgsForOperation(int operation);
-
-/*
- * Checks if memory needs to be reallocated for this buffer.
- *
- * @param: Geometry of the current buffer.
- * @param: Required Geometry.
- * @param: Geometry of the updated buffer.
- *
- * @return True if a memory reallocation is required.
- */
-bool needNewBuffer(const qBufGeometry currentGeometry,
- const qBufGeometry requiredGeometry,
- const qBufGeometry updatedGeometry);
-
-/*
- * Update the geometry of this buffer without reallocation.
- *
- * @param: buffer whose geometry needs to be updated.
- * @param: Updated buffer geometry
- */
-int updateBufferGeometry(sp<GraphicBuffer> buffer, const qBufGeometry bufGeometry);
-
-/*
- * Update the S3D format of this buffer.
- *
- * @param: buffer whosei S3D format needs to be updated.
- * @param: Updated buffer S3D format
- */
-int updateBufferS3DFormat(sp<GraphicBuffer> buffer, const int s3dFormat);
-
-/*
- * Updates the flags for the layer
- *
- * @param: Attribute
- * @param: Identifies if the attribute was enabled or disabled.
- * @param: current Layer flags.
- *
- * @return: Flags for the layer
- */
-int updateLayerQcomFlags(eLayerAttrib attribute, bool enable, int& currentFlags);
-
-/*
- * Gets the per frame HWC flags for this layer.
- *
- * @param: current hwcl flags
- * @param: current layerFlags
- *
- * @return: the per frame flags.
- */
-int getPerFrameFlags(int hwclFlags, int layerFlags);
-
-/*
- * Checks if FB is updated by this composition type
- *
- * @param: composition type
- * @return: true if FB is updated, false if not
- */
-
-bool isUpdatingFB(HWCCompositionType compositionType);
-
-/*
- * Clear region implementation for C2D/MDP versions.
- *
- * @param: region to be cleared
- * @param: EGL Display
- * @param: EGL Surface
- *
- * @return 0 on success
- */
-int qcomuiClearRegion(Region region, EGLDisplay dpy, EGLSurface sur);
-
-/*
- * Handles the externalDisplay event
- * HDMI has highest priority compared to WifiDisplay
- * Based on the current and the new display event, decides the
- * external display to be enabled
- *
- * @param: newEvent - new external event
- * @param: currEvent - currently enabled external event
- * @return: external display to be enabled
- *
- */
-external_display_type handleEventHDMI(external_display_type disp, int value,
- external_display_type currDispType);
-/*
- * Checks if layers need to be dumped based on system property "debug.sf.dump"
- * for raw dumps and "debug.sf.dump.png" for png dumps.
- *
- * For example, to dump 25 frames in raw format, do,
- * adb shell setprop debug.sf.dump 25
- * Layers are dumped in a time-stamped location: /data/sfdump*.
- *
- * To dump 10 frames in png format, do,
- * adb shell setprop debug.sf.dump.png 10
- * To dump another 25 or so frames in raw format, do,
- * adb shell setprop debug.sf.dump 26
- *
- * To turn off logcat logging of layer-info, set both properties to 0,
- * adb shell setprop debug.sf.dump.png 0
- * adb shell setprop debug.sf.dump 0
- *
- * @return: true if layers need to be dumped (or logcat-ed).
- */
-bool needToDumpLayers();
-
-/*
- * Dumps a layer's info into logcat and its buffer into raw/png files.
- *
- * @param: moduleCompositionType - Composition type set in hwcomposer module.
- * @param: listFlags - Flags used in hwcomposer's list.
- * @param: layerIndex - Index of layer being dumped.
- * @param: hwLayers - Address of hwc_layer_t to log and dump.
- *
- */
-void dumpLayer(int moduleCompositionType, int listFlags, size_t layerIndex,
- hwc_layer_t hwLayers[]);
-
-bool needsAspectRatio (int wRatio, int hRatio);
-void applyPixelAspectRatio (int wRatio, int hRatio, int orientation, int fbWidth,
- int fbHeight, Rect& visibleRect, GLfloat vertices[][2]);
-
-#endif // INCLUDE_LIBQCOM_UI