1/*
2// Copyright (c) 2014 Intel Corporation 
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#include <system/graphics.h>
17#include <common/utils/HwcTrace.h>
18#include <ips/common/PixelFormat.h>
19#include <hal_public.h>
20
21namespace android {
22namespace intel {
23
24bool PixelFormat::convertFormat(uint32_t grallocFormat, uint32_t& spriteFormat, int& bpp)
25{
26    switch (grallocFormat) {
27    case HAL_PIXEL_FORMAT_RGBA_8888:
28        spriteFormat = PLANE_PIXEL_FORMAT_RGBA8888;
29        bpp = 4;
30        break;
31    case HAL_PIXEL_FORMAT_RGBX_8888:
32        spriteFormat = PLANE_PIXEL_FORMAT_RGBX8888;
33        bpp = 4;
34        break;
35    case HAL_PIXEL_FORMAT_BGRX_8888:
36        spriteFormat = PLANE_PIXEL_FORMAT_BGRX8888;
37        bpp = 4;
38        break;
39    case HAL_PIXEL_FORMAT_BGRA_8888:
40        spriteFormat = PLANE_PIXEL_FORMAT_BGRA8888;
41        bpp = 4;
42        break;
43    case HAL_PIXEL_FORMAT_RGB_565:
44        spriteFormat = PLANE_PIXEL_FORMAT_BGRX565;
45        bpp = 2;
46        break;
47    default:
48        return false;
49    }
50
51    return true;
52}
53
54
55} // namespace intel
56} // namespace android
57