From 5d3de309f44f6a72f2a46db792f3865088897039 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 5 Aug 2010 15:24:35 -0700 Subject: first stab at hwcomposer HAL and default implementation. Change-Id: I7ff47b94a6b34a8f61031bd94e936a088dcea6ab --- modules/hwcomposer/hwcomposer.cpp | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 modules/hwcomposer/hwcomposer.cpp (limited to 'modules/hwcomposer/hwcomposer.cpp') diff --git a/modules/hwcomposer/hwcomposer.cpp b/modules/hwcomposer/hwcomposer.cpp new file mode 100644 index 0000000..4cc050c --- /dev/null +++ b/modules/hwcomposer/hwcomposer.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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. + */ + +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +/*****************************************************************************/ + +struct hwc_context_t { + hwc_composer_device_t device; + /* our private state goes below here */ +}; + +static int hwc_device_open(const struct hw_module_t* module, const char* name, + struct hw_device_t** device); + +static struct hw_module_methods_t hwc_module_methods = { + open: hwc_device_open +}; + +hwc_module_t HAL_MODULE_INFO_SYM = { + common: { + tag: HARDWARE_MODULE_TAG, + version_major: 1, + version_minor: 0, + id: HWC_HARDWARE_MODULE_ID, + name: "Sample hwcomposer module", + author: "The Android Open Source Project", + methods: &hwc_module_methods, + } +}; + +/*****************************************************************************/ + +static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) { + if (list && (list->flags & HWC_GEOMETRY_CHANGED)) { + for (size_t i=0 ; inumHwLayers ; i++) { + list->hwLayers[i].compositionType = HWC_FRAMEBUFFER; + } + } + return 0; +} + +static int hwc_set(hwc_composer_device_t *dev, + hwc_display_t dpy, + hwc_surface_t sur, + hwc_layer_list_t* list) +{ + EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur); + if (!sucess) { + return HWC_EGL_ERROR; + } + return 0; +} + +static int hwc_device_close(struct hw_device_t *dev) +{ + struct hwc_context_t* ctx = (struct hwc_context_t*)dev; + if (ctx) { + free(ctx); + } + return 0; +} + +/*****************************************************************************/ + +static int hwc_device_open(const struct hw_module_t* module, const char* name, + struct hw_device_t** device) +{ + int status = -EINVAL; + if (!strcmp(name, HWC_HARDWARE_COMPOSER)) { + struct hwc_context_t *dev; + dev = (hwc_context_t*)malloc(sizeof(*dev)); + + /* initialize our state here */ + memset(dev, 0, sizeof(*dev)); + + /* initialize the procs */ + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = hwc_device_close; + + dev->device.prepare = hwc_prepare; + dev->device.set = hwc_set; + + *device = &dev->device.common; + status = 0; + } + return status; +} -- cgit v1.1