Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2009 VMware, Inc.  All Rights Reserved.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the
  7.  * "Software"), to deal in the Software without restriction, including
  8.  * without limitation the rights to use, copy, modify, merge, publish,
  9.  * distribute, sub license, and/or sell copies of the Software, and to
  10.  * permit persons to whom the Software is furnished to do so, subject to
  11.  * the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the
  14.  * next paragraph) shall be included in all copies or substantial portions
  15.  * of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  21.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  *
  25.  **************************************************************************/
  26.  
  27. #include "vg_state.h"
  28.  
  29. #include <string.h>
  30.  
  31. void vg_init_state(struct vg_state *state)
  32. {
  33.    state->matrix_mode = VG_MATRIX_PATH_USER_TO_SURFACE;
  34.    state->fill_rule = VG_EVEN_ODD;
  35.    state->image_quality = VG_IMAGE_QUALITY_FASTER;
  36.    state->rendering_quality = VG_RENDERING_QUALITY_BETTER;
  37.    state->blend_mode = VG_BLEND_SRC_OVER;
  38.    state->image_mode = VG_DRAW_IMAGE_NORMAL;
  39.  
  40.    memset(state->scissor_rects, 0, sizeof(state->scissor_rects));
  41.    state->scissor_rects_num = 0;
  42.  
  43.    state->color_transform = VG_FALSE;
  44.    state->color_transform_values[0] = 1.0f;
  45.    state->color_transform_values[1] = 1.0f;
  46.    state->color_transform_values[2] = 1.0f;
  47.    state->color_transform_values[3] = 1.0f;
  48.    state->color_transform_values[4] = 0.0f;
  49.    state->color_transform_values[5] = 0.0f;
  50.    state->color_transform_values[6] = 0.0f;
  51.    state->color_transform_values[7] = 0.0f;
  52.  
  53.    /* Stroke parameters */
  54.    state->stroke.line_width.f       = 1.0f;
  55.    state->stroke.line_width.i       = 1;
  56.    state->stroke.cap_style        = VG_CAP_BUTT;
  57.    state->stroke.join_style       = VG_JOIN_MITER;
  58.    state->stroke.miter_limit.f      = 4.0f;
  59.    state->stroke.miter_limit.i      = 4;
  60.    state->stroke.dash_pattern_num = 0;
  61.    state->stroke.dash_phase.f       = 0.0f;
  62.    state->stroke.dash_phase.i       = 0;
  63.    state->stroke.dash_phase_reset = VG_FALSE;
  64.  
  65.    /* Edge fill color for VG_TILE_FILL tiling mode */
  66.    state->tile_fill_color[0] = 0.0f;
  67.    state->tile_fill_color[1] = 0.0f;
  68.    state->tile_fill_color[2] = 0.0f;
  69.    state->tile_fill_color[3] = 0.0f;
  70.  
  71.    /* Color for vgClear */
  72.    state->clear_color[0] = 0.0f;
  73.    state->clear_color[1] = 0.0f;
  74.    state->clear_color[2] = 0.0f;
  75.    state->clear_color[3] = 0.0f;
  76.  
  77.    /* Glyph origin */
  78.    state->glyph_origin[0].f = 0.0f;
  79.    state->glyph_origin[1].f = 0.0f;
  80.    state->glyph_origin[0].i = 0;
  81.    state->glyph_origin[1].i = 0;
  82.  
  83.    /* Enable/disable alpha masking and scissoring */
  84.    state->masking = VG_FALSE;
  85.    state->scissoring = VG_FALSE;
  86.  
  87.    /* Pixel layout information */
  88.    state->pixel_layout = VG_PIXEL_LAYOUT_UNKNOWN;
  89.    state->screen_layout = VG_PIXEL_LAYOUT_UNKNOWN;
  90.  
  91.    /* Source format selection for image filters */
  92.    state->filter_format_linear = VG_FALSE;
  93.    state->filter_format_premultiplied = VG_FALSE;
  94.  
  95.    /* Destination write enable mask for image filters */
  96.    state->filter_channel_mask = (VG_RED | VG_GREEN | VG_BLUE | VG_ALPHA);
  97.  
  98.    matrix_load_identity(&state->path_user_to_surface_matrix);
  99.    matrix_load_identity(&state->image_user_to_surface_matrix);
  100.    matrix_load_identity(&state->fill_paint_to_user_matrix);
  101.    matrix_load_identity(&state->stroke_paint_to_user_matrix);
  102.    matrix_load_identity(&state->glyph_user_to_surface_matrix);
  103. }
  104.  
  105. struct matrix *vg_state_matrix(struct vg_state *state)
  106. {
  107.     switch(state->matrix_mode) {
  108.     case VG_MATRIX_PATH_USER_TO_SURFACE:
  109.        return &state->path_user_to_surface_matrix;
  110.     case VG_MATRIX_IMAGE_USER_TO_SURFACE:
  111.        return &state->image_user_to_surface_matrix;
  112.     case VG_MATRIX_FILL_PAINT_TO_USER:
  113.        return &state->fill_paint_to_user_matrix;
  114.     case VG_MATRIX_STROKE_PAINT_TO_USER:
  115.        return &state->stroke_paint_to_user_matrix;
  116. #ifdef OPENVG_VERSION_1_1
  117.     case VG_MATRIX_GLYPH_USER_TO_SURFACE:
  118.        return &state->glyph_user_to_surface_matrix;
  119. #endif
  120.     default:
  121.        break;
  122.     }
  123.     return NULL;
  124. }
  125.