Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /* cairo - a vector graphics library with display and print output
  2.  *
  3.  * Copyright © 2011 Intel Corporation.
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it either under the terms of the GNU Lesser General Public
  7.  * License version 2.1 as published by the Free Software Foundation
  8.  * (the "LGPL") or, at your option, under the terms of the Mozilla
  9.  * Public License Version 1.1 (the "MPL"). If you do not alter this
  10.  * notice, a recipient may use your version of this file under either
  11.  * the MPL or the LGPL.
  12.  *
  13.  * You should have received a copy of the LGPL along with this library
  14.  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  15.  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  16.  * You should have received a copy of the MPL along with this library
  17.  * in the file COPYING-MPL-1.1
  18.  *
  19.  * The contents of this file are subject to the Mozilla Public License
  20.  * Version 1.1 (the "License"); you may not use this file except in
  21.  * compliance with the License. You may obtain a copy of the License at
  22.  * http://www.mozilla.og/MPL/
  23.  *
  24.  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  25.  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  26.  * the specific language governing rights and limitations.
  27.  *
  28.  * Contributor(s):
  29.  *      Robert Bragg <robert@linux.intel.com>
  30.  */
  31.  
  32. #ifndef CAIRO_COGL_PRIVATE_H
  33. #define CAIRO_COGL_PRIVATE_H
  34.  
  35. #include "cairo-device-private.h"
  36. #include "cairo-cache-private.h"
  37. #include "cairo-backend-private.h"
  38. #include "cairo-default-context-private.h"
  39. #include "cairo-surface-private.h"
  40.  
  41. #include <cogl/cogl2-experimental.h>
  42.  
  43. typedef enum _cairo_cogl_template_type {
  44.     CAIRO_COGL_TEMPLATE_TYPE_SOLID,
  45.     CAIRO_COGL_TEMPLATE_TYPE_TEXTURE,
  46.     CAIRO_COGL_TEMPLATE_TYPE_MASK_SOLID,
  47.     CAIRO_COGL_TEMPLATE_TYPE_MASK_TEXTURE,
  48.     CAIRO_COGL_TEMPLATE_TYPE_COUNT
  49. } cairo_cogl_template_type;
  50.  
  51. typedef struct _cairo_cogl_device {
  52.     cairo_device_t base;
  53.  
  54.     cairo_bool_t backend_vtable_initialized;
  55.     cairo_backend_t backend;
  56.  
  57.     /* We save a copy of all the original backend methods that we override so
  58.      * we can chain up...
  59.      */
  60.     cairo_backend_t backend_parent;
  61.  
  62.     CoglContext *cogl_context;
  63.  
  64.     CoglTexture *dummy_texture;
  65.  
  66.     /* This is a sparsely filled set of templates because we don't support
  67.      * the full range of operators that cairo has. All entries corresponding
  68.      * to unsupported operators are NULL.
  69.      *
  70.      * The CAIRO_OPERATOR_ADD is the operator enum with the highest value that
  71.      * we support so we at least cap the size of the array by that.
  72.      *
  73.      * For each operator we have a template for when we have a solid source
  74.      * and another for each texture format that could be used as a source.
  75.      */
  76.     CoglPipeline *template_pipelines[CAIRO_OPERATOR_ADD + 1][CAIRO_COGL_TEMPLATE_TYPE_COUNT];
  77.  
  78.     CoglMatrix identity;
  79.  
  80.     /* Caches 1d linear gradient textures */
  81.     cairo_cache_t linear_cache;
  82.  
  83.     cairo_cache_t path_fill_staging_cache;
  84.     cairo_cache_t path_fill_prim_cache;
  85.     cairo_cache_t path_stroke_staging_cache;
  86.     cairo_cache_t path_stroke_prim_cache;
  87. } cairo_cogl_device_t;
  88.  
  89. typedef struct _cairo_cogl_clip_primitives {
  90.     cairo_t *clip;
  91.     CoglPrimitive **primitives;
  92. } cairo_cogl_clip_primitives_t;
  93.  
  94. typedef struct _cairo_cogl_surface {
  95.     cairo_surface_t base;
  96.  
  97.     CoglPixelFormat cogl_format;
  98.     cairo_bool_t ignore_alpha;
  99.  
  100.     /* We currently have 3 basic kinds of Cogl surfaces:
  101.      * 1) A light surface simply wrapping a CoglTexture
  102.      * 2) A CoglOffscreen framebuffer that implicitly also wraps a CoglTexture
  103.      * 3) A CoglOnscreen framebuffer which could potentially be mapped to
  104.      *    a CoglTexture (e.g. via tfp on X11) but we don't currently do
  105.      *    that.
  106.      */
  107.  
  108.     CoglTexture *texture;
  109.     CoglFramebuffer *framebuffer;
  110.  
  111.     int width;
  112.     int height;
  113.  
  114.     GQueue *journal;
  115.  
  116.     CoglAttributeBuffer *buffer_stack;
  117.     size_t buffer_stack_size;
  118.     size_t buffer_stack_offset;
  119.     guint8 *buffer_stack_pointer;
  120.  
  121.     cairo_clip_t *last_clip;
  122.  
  123.     /* A small fifo of recently used cairo_clip_ts paired with CoglPrimitives
  124.      * that can be used to mask the stencil buffer. */
  125.     GList *clips_fifo;
  126.  
  127.     int n_clip_updates_per_frame;
  128.  
  129.     /* Since the surface backend drawing operator functions don't get
  130.      * passed the current cairo_t context we don't have a good way
  131.      * to get our user-coordinates path into our surface_fill function.
  132.      *
  133.      * For now we use our _cairo_cogl_context_fill() wrapper to set this
  134.      * side band data on the surface...
  135.      */
  136.     cairo_path_fixed_t *user_path;
  137.     cairo_matrix_t *ctm;
  138.     cairo_matrix_t *ctm_inverse;
  139.     cairo_bool_t path_is_rectangle;
  140.     double path_rectangle_x;
  141.     double path_rectangle_y;
  142.     double path_rectangle_width;
  143.     double path_rectangle_height;
  144. } cairo_cogl_surface_t;
  145.  
  146. cairo_status_t
  147. _cairo_cogl_path_fixed_rectangle (cairo_path_fixed_t *path,
  148.                                   cairo_fixed_t x,
  149.                                   cairo_fixed_t y,
  150.                                   cairo_fixed_t width,
  151.                                   cairo_fixed_t height);
  152.  
  153. cairo_int_status_t
  154. _cairo_cogl_surface_fill_rectangle (void                     *abstract_surface,
  155.                                     cairo_operator_t          op,
  156.                                     const cairo_pattern_t    *source,
  157.                                     double                    x,
  158.                                     double                    y,
  159.                                     double                    width,
  160.                                     double                    height,
  161.                                     cairo_matrix_t           *ctm,
  162.                                     const cairo_clip_t       *clip);
  163.  
  164. #endif /* CAIRO_COGL_PRIVATE_H */
  165.