|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "assert.h" |
|
7 #include "ANPBase.h" |
|
8 #include <android/log.h> |
|
9 |
|
10 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) |
|
11 #define ASSIGN(obj, name) (obj)->name = anp_bitmap_##name |
|
12 |
|
13 |
|
14 #define SK_A32_BITS 8 |
|
15 #define SK_R32_BITS 8 |
|
16 #define SK_G32_BITS 8 |
|
17 #define SK_B32_BITS 8 |
|
18 |
|
19 #ifdef IS_BIG_ENDIAN |
|
20 #define SK_R32_SHIFT 24 |
|
21 #define SK_G32_SHIFT 16 |
|
22 #define SK_B32_SHIFT 8 |
|
23 #define SK_A32_SHIFT 0 |
|
24 #else |
|
25 #define SK_R32_SHIFT 0 |
|
26 #define SK_G32_SHIFT 8 |
|
27 #define SK_B32_SHIFT 16 |
|
28 #define SK_A32_SHIFT 24 |
|
29 #endif |
|
30 |
|
31 #define SK_A32_MASK ((1 << SK_A32_BITS) - 1) |
|
32 #define SK_R32_MASK ((1 << SK_R32_BITS) - 1) |
|
33 #define SK_G32_MASK ((1 << SK_G32_BITS) - 1) |
|
34 #define SK_B32_MASK ((1 << SK_B32_BITS) - 1) |
|
35 |
|
36 #define SK_R16_BITS 5 |
|
37 #define SK_G16_BITS 6 |
|
38 #define SK_B16_BITS 5 |
|
39 |
|
40 #define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS) |
|
41 #define SK_G16_SHIFT (SK_B16_BITS) |
|
42 #define SK_B16_SHIFT 0 |
|
43 |
|
44 #define SK_R16_MASK ((1 << SK_R16_BITS) - 1) |
|
45 #define SK_G16_MASK ((1 << SK_G16_BITS) - 1) |
|
46 #define SK_B16_MASK ((1 << SK_B16_BITS) - 1) |
|
47 |
|
48 bool |
|
49 anp_bitmap_getPixelPacking(ANPBitmapFormat fmt, ANPPixelPacking* packing) { |
|
50 LOG("%s", __PRETTY_FUNCTION__); |
|
51 switch (fmt) { |
|
52 case kRGBA_8888_ANPBitmapFormat: |
|
53 if (packing) { |
|
54 packing->AShift = SK_A32_SHIFT; |
|
55 packing->ABits = SK_A32_BITS; |
|
56 packing->RShift = SK_R32_SHIFT; |
|
57 packing->RBits = SK_R32_BITS; |
|
58 packing->GShift = SK_G32_SHIFT; |
|
59 packing->GBits = SK_G32_BITS; |
|
60 packing->BShift = SK_B32_SHIFT; |
|
61 packing->BBits = SK_B32_BITS; |
|
62 } |
|
63 return true; |
|
64 case kRGB_565_ANPBitmapFormat: |
|
65 if (packing) { |
|
66 packing->AShift = 0; |
|
67 packing->ABits = 0; |
|
68 packing->RShift = SK_R16_SHIFT; |
|
69 packing->RBits = SK_R16_BITS; |
|
70 packing->GShift = SK_G16_SHIFT; |
|
71 packing->GBits = SK_G16_BITS; |
|
72 packing->BShift = SK_B16_SHIFT; |
|
73 packing->BBits = SK_B16_BITS; |
|
74 } |
|
75 return true; |
|
76 default: |
|
77 break; |
|
78 } |
|
79 return false; |
|
80 } |
|
81 |
|
82 void InitBitmapInterface(ANPBitmapInterfaceV0 *i) { |
|
83 _assert(i->inSize == sizeof(*i)); |
|
84 ASSIGN(i, getPixelPacking); |
|
85 } |