am d12780ed: Merge "Update for cleanups in hwc interface" into jb-mr1-dev

* commit 'd12780ed123b54687fea534b34f54ef9c678cdcd':
  Update for cleanups in hwc interface
This commit is contained in:
Jesse Hall 2012-08-23 09:16:49 -07:00 committed by Android Git Automerger
commit a6506488da
2 changed files with 35 additions and 18 deletions

View File

@ -89,7 +89,7 @@ static size_t sizeofHwcLayerList(const hwc_composer_device_1_t* hwc,
static int hwcEventControl(hwc_composer_device_1_t* hwc, int dpy, static int hwcEventControl(hwc_composer_device_1_t* hwc, int dpy,
int event, int enabled) { int event, int enabled) {
if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) { if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) {
return hwc->methods->eventControl(hwc, dpy, event, enabled); return hwc->eventControl(hwc, dpy, event, enabled);
} else { } else {
hwc_composer_device_t* hwc0 = reinterpret_cast<hwc_composer_device_t*>(hwc); hwc_composer_device_t* hwc0 = reinterpret_cast<hwc_composer_device_t*>(hwc);
return hwc0->methods->eventControl(hwc0, event, enabled); return hwc0->methods->eventControl(hwc0, event, enabled);
@ -98,7 +98,7 @@ static int hwcEventControl(hwc_composer_device_1_t* hwc, int dpy,
static int hwcBlank(hwc_composer_device_1_t* hwc, int dpy, int blank) { static int hwcBlank(hwc_composer_device_1_t* hwc, int dpy, int blank) {
if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) { if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) {
return hwc->methods->blank(hwc, dpy, blank); return hwc->blank(hwc, dpy, blank);
} else { } else {
if (blank) { if (blank) {
hwc_composer_device_t* hwc0 = reinterpret_cast<hwc_composer_device_t*>(hwc); hwc_composer_device_t* hwc0 = reinterpret_cast<hwc_composer_device_t*>(hwc);
@ -162,6 +162,17 @@ static size_t& hwcNumHwLayers(hwc_composer_device_1_t* hwc,
} }
} }
static void hwcDump(hwc_composer_device_1_t* hwc, char* buff, int buff_len) {
if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) {
if (hwc->dump)
hwc->dump(hwc, buff, buff_len);
} else if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_0_1)) {
hwc_composer_device_t* hwc0 = reinterpret_cast<hwc_composer_device_t*>(hwc);
if (hwc0->dump)
hwc0->dump(hwc0, buff, buff_len);
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
struct HWComposer::cb_context { struct HWComposer::cb_context {
@ -213,6 +224,14 @@ HWComposer::HWComposer(
} }
if (mHwc) { if (mHwc) {
if (mHwc->registerProcs) {
mCBContext->hwc = this;
mCBContext->procs.invalidate = &hook_invalidate;
mCBContext->procs.vsync = &hook_vsync;
memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero));
mHwc->registerProcs(mHwc, &mCBContext->procs);
}
// always turn vsync off when we start // always turn vsync off when we start
needVSyncThread = false; needVSyncThread = false;
if (hwcHasVsyncEvent(mHwc)) { if (hwcHasVsyncEvent(mHwc)) {
@ -226,14 +245,6 @@ HWComposer::HWComposer(
needVSyncThread = true; needVSyncThread = true;
} }
if (mHwc->registerProcs) {
mCBContext->hwc = this;
mCBContext->procs.invalidate = &hook_invalidate;
mCBContext->procs.vsync = &hook_vsync;
mHwc->registerProcs(mHwc, &mCBContext->procs);
memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero));
}
if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
mNumDisplays = HWC_NUM_DISPLAY_TYPES; mNumDisplays = HWC_NUM_DISPLAY_TYPES;
@ -280,12 +291,17 @@ status_t HWComposer::initCheck() const {
return mHwc ? NO_ERROR : NO_INIT; return mHwc ? NO_ERROR : NO_INIT;
} }
void HWComposer::hook_invalidate(struct hwc_procs* procs) { void HWComposer::hook_invalidate(const struct hwc_procs* procs) {
reinterpret_cast<cb_context *>(procs)->hwc->invalidate(); cb_context* ctx = reinterpret_cast<cb_context*>(
const_cast<hwc_procs_t*>(procs));
ctx->hwc->invalidate();
} }
void HWComposer::hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp) { void HWComposer::hook_vsync(const struct hwc_procs* procs, int dpy,
reinterpret_cast<cb_context *>(procs)->hwc->vsync(dpy, timestamp); int64_t timestamp) {
cb_context* ctx = reinterpret_cast<cb_context*>(
const_cast<hwc_procs_t*>(procs));
ctx->hwc->vsync(dpy, timestamp);
} }
void HWComposer::invalidate() { void HWComposer::invalidate() {
@ -714,8 +730,8 @@ void HWComposer::dump(String8& result, char* buffer, size_t SIZE,
layer->getName().string()); layer->getName().string());
} }
} }
if (mHwc && hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_1) && mHwc->dump) { if (mHwc) {
mHwc->dump(mHwc, buffer, SIZE); hwcDump(mHwc, buffer, SIZE);
result.append(buffer); result.append(buffer);
} }
} }

View File

@ -229,8 +229,9 @@ private:
struct cb_context; struct cb_context;
static void hook_invalidate(struct hwc_procs* procs); static void hook_invalidate(const struct hwc_procs* procs);
static void hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp); static void hook_vsync(const struct hwc_procs* procs, int dpy,
int64_t timestamp);
inline void invalidate(); inline void invalidate();
inline void vsync(int dpy, int64_t timestamp); inline void vsync(int dpy, int64_t timestamp);