1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/gfx/CairoGLInfo.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- 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 +package org.mozilla.gecko.gfx; 1.10 + 1.11 +import javax.microedition.khronos.opengles.GL10; 1.12 + 1.13 +/** Information needed to render Cairo bitmaps using OpenGL ES. */ 1.14 +public class CairoGLInfo { 1.15 + public final int internalFormat; 1.16 + public final int format; 1.17 + public final int type; 1.18 + 1.19 + public CairoGLInfo(int cairoFormat) { 1.20 + switch (cairoFormat) { 1.21 + case CairoImage.FORMAT_ARGB32: 1.22 + internalFormat = format = GL10.GL_RGBA; type = GL10.GL_UNSIGNED_BYTE; 1.23 + break; 1.24 + case CairoImage.FORMAT_RGB24: 1.25 + internalFormat = format = GL10.GL_RGB; type = GL10.GL_UNSIGNED_BYTE; 1.26 + break; 1.27 + case CairoImage.FORMAT_RGB16_565: 1.28 + internalFormat = format = GL10.GL_RGB; type = GL10.GL_UNSIGNED_SHORT_5_6_5; 1.29 + break; 1.30 + case CairoImage.FORMAT_A8: 1.31 + case CairoImage.FORMAT_A1: 1.32 + throw new RuntimeException("Cairo FORMAT_A1 and FORMAT_A8 unsupported"); 1.33 + default: 1.34 + throw new RuntimeException("Unknown Cairo format"); 1.35 + } 1.36 + } 1.37 +} 1.38 +