1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2009 VMware, Inc.  All Rights Reserved.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "VG/openvg.h"
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "vg_context.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "api.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Hardware Queries */
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgVGHardwareQueryResult vegaHardwareQuery(VGHardwareQueryType key,
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                        VGint setting)
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct vg_context *ctx = vg_current_context();
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (key < VG_IMAGE_FORMAT_QUERY ||
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org       key > VG_PATH_DATATYPE_QUERY) {
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return VG_HARDWARE_UNACCELERATED;
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (key == VG_IMAGE_FORMAT_QUERY) {
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (setting < VG_sRGBX_8888 ||
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org          setting > VG_lABGR_8888_PRE) {
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         return VG_HARDWARE_UNACCELERATED;
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      }
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   } else if (key == VG_PATH_DATATYPE_QUERY) {
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      if (setting < VG_PATH_DATATYPE_S_8 ||
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org          setting > VG_PATH_DATATYPE_F) {
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         vg_set_error(ctx, VG_ILLEGAL_ARGUMENT_ERROR);
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org         return VG_HARDWARE_UNACCELERATED;
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      }
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* we're supposed to accelerate everything */
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return VG_HARDWARE_ACCELERATED;
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Renderer and Extension Information */
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgconst VGubyte *vegaGetString(VGStringID name)
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct vg_context *ctx = vg_current_context();
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   static const VGubyte *vendor = (VGubyte *)"Tungsten Graphics, Inc";
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   static const VGubyte *renderer = (VGubyte *)"Vega OpenVG 1.1";
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   static const VGubyte *version = (VGubyte *)"1.1";
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (!ctx)
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   switch(name) {
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case VG_VENDOR:
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return vendor;
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case VG_RENDERER:
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return renderer;
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case VG_VERSION:
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return version;
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case VG_EXTENSIONS:
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   default:
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
85