blob: 13873f8e80bb6de6911b051142f174379e65a4d8 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "hwc_utils.h"
19
20namespace qhwc {
21void initContext(hwc_context_t *ctx)
22{
23 //XXX: target specific initializations here
24 openFramebufferDevice(ctx);
25 ctx->mOverlay = overlay::Overlay::getInstance();
26 ctx->qbuf = new QueuedBufferStore();
27
28}
29
30void closeContext(hwc_context_t *ctx)
31{
32 if(ctx->mOverlay) {
33 delete ctx->mOverlay;
34 ctx->mOverlay = NULL;
35 }
36 if(ctx->fbDev) {
37 framebuffer_close(ctx->fbDev);
38 ctx->fbDev = NULL;
39 }
40
41 if(ctx->qbuf) {
42 delete ctx->qbuf;
43 ctx->qbuf = NULL;
44 }
45}
46
47// Opens Framebuffer device
48void openFramebufferDevice(hwc_context_t *ctx) {
49 hw_module_t const *module;
50 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
51 framebuffer_open(module, &(ctx->fbDev));
52 }
53}
54
55void dumpLayer(hwc_layer_t const* l)
56{
57 ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}"
58 ", {%d,%d,%d,%d}",
59 l->compositionType, l->flags, l->handle, l->transform, l->blending,
60 l->sourceCrop.left,
61 l->sourceCrop.top,
62 l->sourceCrop.right,
63 l->sourceCrop.bottom,
64 l->displayFrame.left,
65 l->displayFrame.top,
66 l->displayFrame.right,
67 l->displayFrame.bottom);
68}
69
70void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list)
71{
72 int yuvBufCount = 0;
73 int layersNotUpdatingCount = 0;
74 for (size_t i=0 ; i<list->numHwLayers; i++) {
75 private_handle_t *hnd = (private_handle_t *)list->hwLayers[i].handle;
76 if (isYuvBuffer(hnd)) {
77 yuvBufCount++;
78 }
79 }
80 // Number of video/camera layers drawable with overlay
81 ctx->yuvBufferCount = yuvBufCount;
82 ctx->numHwLayers = list->numHwLayers;
83 return;
84}
85
86void handleYUV(hwc_context_t *ctx, hwc_layer_t *layer)
87{
88 private_handle_t *hnd =
89 (private_handle_t *)layer->handle;
90 //XXX: Handle targets not using overlay
91 if(prepareOverlay(ctx, layer)) {
92 layer->compositionType = HWC_USE_OVERLAY;
93 layer->hints |= HWC_HINT_CLEAR_FB;
94 }
95}
96};//namespace