2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #include <wtf/Assertions.h>
26 static inline const char* toVGErrorConstant(VGErrorCode error)
29 case VG_BAD_HANDLE_ERROR:
30 return "VG_BAD_HANDLE_ERROR";
31 case VG_ILLEGAL_ARGUMENT_ERROR:
32 return "VG_ILLEGAL_ARGUMENT_ERROR";
33 case VG_OUT_OF_MEMORY_ERROR:
34 return "VG_OUT_OF_MEMORY_ERROR";
35 case VG_PATH_CAPABILITY_ERROR:
36 return "VG_PATH_CAPABILITY_ERROR";
37 case VG_UNSUPPORTED_IMAGE_FORMAT_ERROR:
38 return "VG_UNSUPPORTED_IMAGE_FORMAT_ERROR";
39 case VG_UNSUPPORTED_PATH_FORMAT_ERROR:
40 return "VG_UNSUPPORTED_PATH_FORMAT_ERROR";
41 case VG_IMAGE_IN_USE_ERROR:
42 return "VG_IMAGE_IN_USE_ERROR";
43 case VG_NO_CONTEXT_ERROR:
44 return "VG_NO_CONTEXT_ERROR";
46 return "UNKNOWN_ERROR";
51 #define ASSERT_VG_NO_ERROR() ((void)0)
53 #define ASSERT_VG_NO_ERROR() do { \
54 VGErrorCode vgErrorCode = vgGetError(); \
55 ASSERT_WITH_MESSAGE(vgErrorCode == VG_NO_ERROR, "Found %s", toVGErrorConstant(vgErrorCode)); \
62 class AffineTransform;
64 class TransformationMatrix;
68 VGMatrix(const VGfloat data[9]);
69 VGMatrix(const AffineTransform&);
70 VGMatrix(const TransformationMatrix&);
71 const VGfloat* toVGfloat() const { return m_data; }
72 operator AffineTransform() const;
73 operator TransformationMatrix() const;
80 VGRect(const VGfloat data[4]);
81 VGRect(const FloatRect&);
82 const VGfloat* toVGfloat() const { return m_data; }
83 operator FloatRect() const;
90 static int bytesForImage(VGImageFormat, VGint width, VGint height);
91 static int bytesForImageScanline(VGImageFormat, VGint width);
92 static int imageFormatBitsPerPixel(VGImageFormat);
95 * Return a flipped VGImageFormat if the platform is little endian
96 * (e.g. VG_ABGR_8888 for a given VG_RGBA_8888), or return the image format
97 * as is if the platform is big endian.
99 * OpenVG itself is indifferent to endianness, it will always work on a
100 * single machine word with the bytes going from left to right as specified
101 * in the image format, no matter which one of the bytes is most or least
104 * However, if you interface with vgImageSubData()/vgGetImageSubData()
105 * using a byte array then you want to make sure the byte order is
106 * appropriate for the given platform (otherwise the byte indexes need
107 * to be swapped depending on endianness). So, use this function when
108 * interfacing with byte arrays, and don't use it otherwise.
110 static VGImageFormat endianAwareImageFormat(VGImageFormat bigEndianFormat);