diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-04-04 15:16:50 +0100 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-04-06 00:34:54 +0100 |
commit | c962bf8b8fa4d9a6400811296fb270f47db68cf4 (patch) | |
tree | f5e651935cbbf54e6d1488bbe19a6e2a4599a070 /libhwcomposer/hwc_fbupdate.cpp | |
parent | 7a8a513ac8a2b9a76b36cf1341d45b00d88ed45c (diff) | |
parent | 6445344dbaf08ec4d8fbf6aeeffdf29faed64e78 (diff) | |
download | android_hardware_qcom_display-cm-10.1.tar.gz android_hardware_qcom_display-cm-10.1.tar.bz2 android_hardware_qcom_display-cm-10.1.zip |
Merge remote-tracking branch 'aosp/jb-mr1.1-release' into cm-10.1cm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1.2cm-10.1.1cm-10.1.0-RC5cm-10.1.0-RC4cm-10.1.0-RC3cm-10.1.0-RC2cm-10.1.0-RC1cm-10.1.0cm-10.1-M3cm-10.1
Change-Id: I44a10eaa285d0521669781a4fafb7641df209186
Diffstat (limited to 'libhwcomposer/hwc_fbupdate.cpp')
-rw-r--r-- | libhwcomposer/hwc_fbupdate.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp new file mode 100644 index 000000000..0d0787ec5 --- /dev/null +++ b/libhwcomposer/hwc_fbupdate.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2012, The Linux Foundation. All rights reserved. + * + * Not a Contribution, Apache license notifications and license are + * retained for attribution purposes only. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define HWC_FB_UPDATE 0 +#include <gralloc_priv.h> +#include <fb_priv.h> +#include "hwc_fbupdate.h" +#include "external.h" + +namespace qhwc { + +namespace ovutils = overlay::utils; + +//Static Members +bool FBUpdate::sModeOn[] = {false}; +ovutils::eDest FBUpdate::sDest[] = {ovutils::OV_INVALID}; + +void FBUpdate::reset() { + sModeOn[HWC_DISPLAY_PRIMARY] = false; + sModeOn[HWC_DISPLAY_EXTERNAL] = false; + sDest[HWC_DISPLAY_PRIMARY] = ovutils::OV_INVALID; + sDest[HWC_DISPLAY_EXTERNAL] = ovutils::OV_INVALID; +} + +bool FBUpdate::prepare(hwc_context_t *ctx, hwc_layer_1_t *fblayer, int dpy) { + if(!ctx->mMDP.hasOverlay) { + ALOGD_IF(HWC_FB_UPDATE, "%s, this hw doesnt support mirroring", + __FUNCTION__); + return false; + } + + return (sModeOn[dpy] = configure(ctx, fblayer, dpy)); + +} + +// Configure +bool FBUpdate::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, int dpy) +{ + bool ret = false; + if (LIKELY(ctx->mOverlay)) { + overlay::Overlay& ov = *(ctx->mOverlay); + private_handle_t *hnd = (private_handle_t *)layer->handle; + if (!hnd) { + ALOGE("%s:NULL private handle for layer!", __FUNCTION__); + return false; + } + ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size); + + //Request an RGB pipe + ovutils::eDest dest = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, dpy); + if(dest == ovutils::OV_INVALID) { //None available + return false; + } + + sDest[dpy] = dest; + + ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; + if(ctx->mSecureMode) { + ovutils::setMdpFlags(mdpFlags, + ovutils::OV_MDP_SECURE_OVERLAY_SESSION); + } + + ovutils::PipeArgs parg(mdpFlags, + info, + ovutils::ZORDER_0, + ovutils::IS_FG_SET, + ovutils::ROT_FLAG_DISABLED); + ov.setSource(parg, dest); + + hwc_rect_t sourceCrop = layer->sourceCrop; + // x,y,w,h + ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top, + sourceCrop.right - sourceCrop.left, + sourceCrop.bottom - sourceCrop.top); + ov.setCrop(dcrop, dest); + + int transform = layer->transform; + ovutils::eTransform orient = + static_cast<ovutils::eTransform>(transform); + ov.setTransform(orient, dest); + + hwc_rect_t displayFrame = layer->displayFrame; + ovutils::Dim dpos(displayFrame.left, + displayFrame.top, + displayFrame.right - displayFrame.left, + displayFrame.bottom - displayFrame.top); + ov.setPosition(dpos, dest); + + ret = true; + if (!ov.commit(dest)) { + ALOGE("%s: commit fails", __FUNCTION__); + ret = false; + } + } + return ret; +} + +bool FBUpdate::draw(hwc_context_t *ctx, hwc_layer_1_t *layer, int dpy) +{ + if(!sModeOn[dpy]) { + return true; + } + bool ret = true; + overlay::Overlay& ov = *(ctx->mOverlay); + ovutils::eDest dest = sDest[dpy]; + private_handle_t *hnd = (private_handle_t *)layer->handle; + if (!ov.queueBuffer(hnd->fd, hnd->offset, dest)) { + ALOGE("%s: queueBuffer failed for external", __FUNCTION__); + ret = false; + } + return ret; +} + +//--------------------------------------------------------------------- +}; //namespace qhwc |