1 /* 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * 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. 8 * 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. 13 * 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. 18 */ 19 20 #ifndef VGUtils_h 21 #define VGUtils_h 22 23 #include <openvg.h> 24 #include <wtf/Assertions.h> 25 26 static inline const char* toVGErrorConstant(VGErrorCode error) 27 { 28 switch (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"; 45 default: 46 return "UNKNOWN_ERROR"; 47 } 48 } 49 50 #if ASSERT_DISABLED 51 #define ASSERT_VG_NO_ERROR() ((void)0) 52 #else 53 #define ASSERT_VG_NO_ERROR() do { \ 54 VGErrorCode vgErrorCode = vgGetError(); \ 55 ASSERT_WITH_MESSAGE(vgErrorCode == VG_NO_ERROR, "Found %s", toVGErrorConstant(vgErrorCode)); \ 56 } while (0) 57 #endif 58 59 60 namespace WebCore { 61 62 class FloatRect; 63 class TransformationMatrix; 64 65 class VGMatrix { 66 public: 67 VGMatrix(const VGfloat data[9]); 68 VGMatrix(const TransformationMatrix&); 69 const VGfloat* toVGfloat() const { return m_data; } 70 operator TransformationMatrix() const; 71 private: 72 VGfloat m_data[9]; 73 }; 74 75 class VGRect { 76 public: 77 VGRect(const VGfloat data[4]); 78 VGRect(const FloatRect&); 79 const VGfloat* toVGfloat() const { return m_data; } 80 operator FloatRect() const; 81 private: 82 VGfloat m_data[4]; 83 }; 84 85 } 86 87 #endif 88