1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/base/android/ANPBitmap.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "assert.h" 1.10 +#include "ANPBase.h" 1.11 +#include <android/log.h> 1.12 + 1.13 +#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) 1.14 +#define ASSIGN(obj, name) (obj)->name = anp_bitmap_##name 1.15 + 1.16 + 1.17 +#define SK_A32_BITS 8 1.18 +#define SK_R32_BITS 8 1.19 +#define SK_G32_BITS 8 1.20 +#define SK_B32_BITS 8 1.21 + 1.22 +#ifdef IS_BIG_ENDIAN 1.23 +#define SK_R32_SHIFT 24 1.24 +#define SK_G32_SHIFT 16 1.25 +#define SK_B32_SHIFT 8 1.26 +#define SK_A32_SHIFT 0 1.27 +#else 1.28 +#define SK_R32_SHIFT 0 1.29 +#define SK_G32_SHIFT 8 1.30 +#define SK_B32_SHIFT 16 1.31 +#define SK_A32_SHIFT 24 1.32 +#endif 1.33 + 1.34 +#define SK_A32_MASK ((1 << SK_A32_BITS) - 1) 1.35 +#define SK_R32_MASK ((1 << SK_R32_BITS) - 1) 1.36 +#define SK_G32_MASK ((1 << SK_G32_BITS) - 1) 1.37 +#define SK_B32_MASK ((1 << SK_B32_BITS) - 1) 1.38 + 1.39 +#define SK_R16_BITS 5 1.40 +#define SK_G16_BITS 6 1.41 +#define SK_B16_BITS 5 1.42 + 1.43 +#define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS) 1.44 +#define SK_G16_SHIFT (SK_B16_BITS) 1.45 +#define SK_B16_SHIFT 0 1.46 + 1.47 +#define SK_R16_MASK ((1 << SK_R16_BITS) - 1) 1.48 +#define SK_G16_MASK ((1 << SK_G16_BITS) - 1) 1.49 +#define SK_B16_MASK ((1 << SK_B16_BITS) - 1) 1.50 + 1.51 +bool 1.52 +anp_bitmap_getPixelPacking(ANPBitmapFormat fmt, ANPPixelPacking* packing) { 1.53 + LOG("%s", __PRETTY_FUNCTION__); 1.54 + switch (fmt) { 1.55 + case kRGBA_8888_ANPBitmapFormat: 1.56 + if (packing) { 1.57 + packing->AShift = SK_A32_SHIFT; 1.58 + packing->ABits = SK_A32_BITS; 1.59 + packing->RShift = SK_R32_SHIFT; 1.60 + packing->RBits = SK_R32_BITS; 1.61 + packing->GShift = SK_G32_SHIFT; 1.62 + packing->GBits = SK_G32_BITS; 1.63 + packing->BShift = SK_B32_SHIFT; 1.64 + packing->BBits = SK_B32_BITS; 1.65 + } 1.66 + return true; 1.67 + case kRGB_565_ANPBitmapFormat: 1.68 + if (packing) { 1.69 + packing->AShift = 0; 1.70 + packing->ABits = 0; 1.71 + packing->RShift = SK_R16_SHIFT; 1.72 + packing->RBits = SK_R16_BITS; 1.73 + packing->GShift = SK_G16_SHIFT; 1.74 + packing->GBits = SK_G16_BITS; 1.75 + packing->BShift = SK_B16_SHIFT; 1.76 + packing->BBits = SK_B16_BITS; 1.77 + } 1.78 + return true; 1.79 + default: 1.80 + break; 1.81 + } 1.82 + return false; 1.83 +} 1.84 + 1.85 +void InitBitmapInterface(ANPBitmapInterfaceV0 *i) { 1.86 + _assert(i->inSize == sizeof(*i)); 1.87 + ASSIGN(i, getPixelPacking); 1.88 +}