Compare commits
	
		
			56 Commits
		
	
	
		
			gbsneto/ch
			...
			wip/nielsd
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					620a9f5193 | ||
| 
						 | 
					0d50a37091 | ||
| 
						 | 
					1ca0fdc928 | ||
| 
						 | 
					23a8ea2821 | ||
| 
						 | 
					ee4bb2240b | ||
| 
						 | 
					81ae886dda | ||
| 
						 | 
					63c40a9711 | ||
| 
						 | 
					8374be46d2 | ||
| 
						 | 
					5d1a87d355 | ||
| 
						 | 
					34312c272b | ||
| 
						 | 
					2b8f5e65b6 | ||
| 
						 | 
					a934fa07b8 | ||
| 
						 | 
					c6d1cf4af4 | ||
| 
						 | 
					8dbe4210b4 | ||
| 
						 | 
					02c99524bf | ||
| 
						 | 
					17d00d49d4 | ||
| 
						 | 
					634f512bb0 | ||
| 
						 | 
					5c009c20ab | ||
| 
						 | 
					535ce00abb | ||
| 
						 | 
					37144f0609 | ||
| 
						 | 
					ab76576340 | ||
| 
						 | 
					09aa82db49 | ||
| 
						 | 
					c95db7c542 | ||
| 
						 | 
					a984622cd1 | ||
| 
						 | 
					156980eff9 | ||
| 
						 | 
					736cac43e9 | ||
| 
						 | 
					3ba79961fe | ||
| 
						 | 
					7718e67f5c | ||
| 
						 | 
					ba8f5a1178 | ||
| 
						 | 
					502da973eb | ||
| 
						 | 
					eccf7b105c | ||
| 
						 | 
					bcee890434 | ||
| 
						 | 
					251fa024c4 | ||
| 
						 | 
					471b61bd14 | ||
| 
						 | 
					7df86fb246 | ||
| 
						 | 
					3f29b47809 | ||
| 
						 | 
					9ab3a02a8a | ||
| 
						 | 
					ca2be8ef5b | ||
| 
						 | 
					1783ea5af1 | ||
| 
						 | 
					862e56f01d | ||
| 
						 | 
					2b9cd50e84 | ||
| 
						 | 
					e71f44dbd6 | ||
| 
						 | 
					c881b4970d | ||
| 
						 | 
					d79f176142 | ||
| 
						 | 
					ce6acf9dca | ||
| 
						 | 
					2a15e5f16a | ||
| 
						 | 
					fb40e2eefb | ||
| 
						 | 
					fc09fa50a5 | ||
| 
						 | 
					48f04c7968 | ||
| 
						 | 
					007297f1a6 | ||
| 
						 | 
					302a171c08 | ||
| 
						 | 
					893e894fff | ||
| 
						 | 
					2aaed7bdfc | ||
| 
						 | 
					249f9a4a2e | ||
| 
						 | 
					68166f33d9 | ||
| 
						 | 
					28954e8271 | 
@@ -7,6 +7,8 @@ stages:
 | 
			
		||||
 | 
			
		||||
check-commit-log:
 | 
			
		||||
  stage: review
 | 
			
		||||
  variables:
 | 
			
		||||
    GIT_DEPTH: "100"
 | 
			
		||||
  script:
 | 
			
		||||
    - ./.gitlab-ci/check-commit-log.sh
 | 
			
		||||
  only:
 | 
			
		||||
@@ -34,11 +36,15 @@ test-mutter:
 | 
			
		||||
    XDG_RUNTIME_DIR: "$CI_PROJECT_DIR/runtime-dir"
 | 
			
		||||
    GSETTINGS_SCHEMA_DIR: "$CI_PROJECT_DIR/build/data"
 | 
			
		||||
  script:
 | 
			
		||||
    - mkdir -m 700 $XDG_RUNTIME_DIR
 | 
			
		||||
    - glib-compile-schemas $GSETTINGS_SCHEMA_DIR
 | 
			
		||||
    - >
 | 
			
		||||
      dbus-run-session -- xvfb-run -s '+iglx -noreset'
 | 
			
		||||
      meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --wrap catchsegv
 | 
			
		||||
    - bash -x ./.gitlab-ci/run-tests.sh
 | 
			
		||||
  only:
 | 
			
		||||
    - merge_requests
 | 
			
		||||
    - /^.*$/
 | 
			
		||||
  artifacts:
 | 
			
		||||
    reports:
 | 
			
		||||
      junit: "build/${CI_JOB_NAME}-report.xml"
 | 
			
		||||
    name: "mutter-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
 | 
			
		||||
    when: always
 | 
			
		||||
    paths:
 | 
			
		||||
      - "build/meson-logs"
 | 
			
		||||
      - "build/${CI_JOB_NAME}-report.xml"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										109
									
								
								.gitlab-ci/meson-junit-report.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										109
									
								
								.gitlab-ci/meson-junit-report.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,109 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
 | 
			
		||||
# Turns a Meson testlog.json file into a JUnit XML report
 | 
			
		||||
#
 | 
			
		||||
# Copyright 2019  GNOME Foundation
 | 
			
		||||
#
 | 
			
		||||
# SPDX-License-Identifier: LGPL-2.1-or-later
 | 
			
		||||
#
 | 
			
		||||
# Original author: Emmanuele Bassi
 | 
			
		||||
 | 
			
		||||
import argparse
 | 
			
		||||
import datetime
 | 
			
		||||
import json
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
import xml.etree.ElementTree as ET
 | 
			
		||||
 | 
			
		||||
aparser = argparse.ArgumentParser(description='Turns a Meson test log into a JUnit report')
 | 
			
		||||
aparser.add_argument('--project-name', metavar='NAME',
 | 
			
		||||
                     help='The project name',
 | 
			
		||||
                     default='unknown')
 | 
			
		||||
aparser.add_argument('--job-id', metavar='ID',
 | 
			
		||||
                     help='The job ID for the report',
 | 
			
		||||
                     default='Unknown')
 | 
			
		||||
aparser.add_argument('--branch', metavar='NAME',
 | 
			
		||||
                     help='Branch of the project being tested',
 | 
			
		||||
                     default='master')
 | 
			
		||||
aparser.add_argument('--output', metavar='FILE',
 | 
			
		||||
                     help='The output file, stdout by default',
 | 
			
		||||
                     type=argparse.FileType('w', encoding='UTF-8'),
 | 
			
		||||
                     default=sys.stdout)
 | 
			
		||||
aparser.add_argument('infile', metavar='FILE',
 | 
			
		||||
                     help='The input testlog.json, stdin by default',
 | 
			
		||||
                     type=argparse.FileType('r', encoding='UTF-8'),
 | 
			
		||||
                     default=sys.stdin)
 | 
			
		||||
 | 
			
		||||
args = aparser.parse_args()
 | 
			
		||||
 | 
			
		||||
outfile = args.output
 | 
			
		||||
 | 
			
		||||
testsuites = ET.Element('testsuites')
 | 
			
		||||
testsuites.set('id', '{}/{}'.format(args.job_id, args.branch))
 | 
			
		||||
testsuites.set('package', args.project_name)
 | 
			
		||||
testsuites.set('timestamp', datetime.datetime.utcnow().isoformat(timespec='minutes'))
 | 
			
		||||
 | 
			
		||||
suites = {}
 | 
			
		||||
for line in args.infile:
 | 
			
		||||
    data = json.loads(line)
 | 
			
		||||
    (full_suite, unit_name) = data['name'].split(' / ')
 | 
			
		||||
    (project_name, suite_name) = full_suite.split(':')
 | 
			
		||||
 | 
			
		||||
    duration = data['duration']
 | 
			
		||||
    return_code = data['returncode']
 | 
			
		||||
    log = data['stdout']
 | 
			
		||||
 | 
			
		||||
    unit = {
 | 
			
		||||
        'suite': suite_name,
 | 
			
		||||
        'name': unit_name,
 | 
			
		||||
        'duration': duration,
 | 
			
		||||
        'returncode': return_code,
 | 
			
		||||
        'stdout': log,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    units = suites.setdefault(suite_name, [])
 | 
			
		||||
    units.append(unit)
 | 
			
		||||
 | 
			
		||||
for name, units in suites.items():
 | 
			
		||||
    print('Processing suite {} (units: {})'.format(name, len(units)))
 | 
			
		||||
 | 
			
		||||
    def if_failed(unit):
 | 
			
		||||
        if unit['returncode'] != 0:
 | 
			
		||||
            return True
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    def if_succeded(unit):
 | 
			
		||||
        if unit['returncode'] == 0:
 | 
			
		||||
            return True
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    successes = list(filter(if_succeded, units))
 | 
			
		||||
    failures = list(filter(if_failed, units))
 | 
			
		||||
    print(' - {}: {} pass, {} fail'.format(name, len(successes), len(failures)))
 | 
			
		||||
 | 
			
		||||
    testsuite = ET.SubElement(testsuites, 'testsuite')
 | 
			
		||||
    testsuite.set('name', '{}/{}'.format(args.project_name, name))
 | 
			
		||||
    testsuite.set('tests', str(len(units)))
 | 
			
		||||
    testsuite.set('errors', str(len(failures)))
 | 
			
		||||
    testsuite.set('failures', str(len(failures)))
 | 
			
		||||
 | 
			
		||||
    for unit in successes:
 | 
			
		||||
        testcase = ET.SubElement(testsuite, 'testcase')
 | 
			
		||||
        testcase.set('classname', '{}/{}'.format(args.project_name, unit['suite']))
 | 
			
		||||
        testcase.set('name', unit['name'])
 | 
			
		||||
        testcase.set('time', str(unit['duration']))
 | 
			
		||||
 | 
			
		||||
    for unit in failures:
 | 
			
		||||
        testcase = ET.SubElement(testsuite, 'testcase')
 | 
			
		||||
        testcase.set('classname', '{}/{}'.format(args.project_name, unit['suite']))
 | 
			
		||||
        testcase.set('name', unit['name'])
 | 
			
		||||
        testcase.set('time', str(unit['duration']))
 | 
			
		||||
 | 
			
		||||
        failure = ET.SubElement(testcase, 'failure')
 | 
			
		||||
        failure.set('classname', '{}/{}'.format(args.project_name, unit['suite']))
 | 
			
		||||
        failure.set('name', unit['name'])
 | 
			
		||||
        failure.set('type', 'error')
 | 
			
		||||
        failure.text = unit['stdout']
 | 
			
		||||
 | 
			
		||||
output = ET.tostring(testsuites, encoding='unicode')
 | 
			
		||||
outfile.write(output)
 | 
			
		||||
							
								
								
									
										20
									
								
								.gitlab-ci/run-tests.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								.gitlab-ci/run-tests.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
#!/usr/bin/bash
 | 
			
		||||
 | 
			
		||||
set +e
 | 
			
		||||
 | 
			
		||||
mkdir -m 700 $XDG_RUNTIME_DIR
 | 
			
		||||
glib-compile-schemas $GSETTINGS_SCHEMA_DIR
 | 
			
		||||
 | 
			
		||||
dbus-run-session -- \
 | 
			
		||||
    xvfb-run -s '+iglx -noreset' \
 | 
			
		||||
        meson test -C build --no-rebuild -t 10 --wrap catchsegv
 | 
			
		||||
 | 
			
		||||
exit_code=$?
 | 
			
		||||
 | 
			
		||||
python3 .gitlab-ci/meson-junit-report.py \
 | 
			
		||||
        --project-name=mutter \
 | 
			
		||||
        --job-id "${CI_JOB_NAME}" \
 | 
			
		||||
        --output "build/${CI_JOB_NAME}-report.xml" \
 | 
			
		||||
        build/meson-logs/testlog-catchsegv.json
 | 
			
		||||
 | 
			
		||||
exit $exit_code
 | 
			
		||||
@@ -807,6 +807,9 @@ struct _ClutterActorPrivate
 | 
			
		||||
  gpointer create_child_data;
 | 
			
		||||
  GDestroyNotify create_child_notify;
 | 
			
		||||
 | 
			
		||||
  guint resolution_changed_id;
 | 
			
		||||
  guint font_changed_id;
 | 
			
		||||
 | 
			
		||||
  /* bitfields: KEEP AT THE END */
 | 
			
		||||
 | 
			
		||||
  /* fixed position and sizes */
 | 
			
		||||
@@ -5983,6 +5986,7 @@ clutter_actor_dispose (GObject *object)
 | 
			
		||||
{
 | 
			
		||||
  ClutterActor *self = CLUTTER_ACTOR (object);
 | 
			
		||||
  ClutterActorPrivate *priv = self->priv;
 | 
			
		||||
  ClutterBackend *backend = clutter_get_default_backend ();
 | 
			
		||||
 | 
			
		||||
  CLUTTER_NOTE (MISC, "Dispose actor (name='%s', ref_count:%d) of type '%s'",
 | 
			
		||||
		_clutter_actor_get_debug_name (self),
 | 
			
		||||
@@ -6019,6 +6023,18 @@ clutter_actor_dispose (GObject *object)
 | 
			
		||||
      g_assert (!CLUTTER_ACTOR_IS_REALIZED (self));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (priv->resolution_changed_id)
 | 
			
		||||
    {
 | 
			
		||||
      g_signal_handler_disconnect (backend, priv->resolution_changed_id);
 | 
			
		||||
      priv->resolution_changed_id = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (priv->font_changed_id)
 | 
			
		||||
    {
 | 
			
		||||
      g_signal_handler_disconnect (backend, priv->font_changed_id);
 | 
			
		||||
      priv->font_changed_id = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_clear_object (&priv->pango_context);
 | 
			
		||||
  g_clear_object (&priv->actions);
 | 
			
		||||
  g_clear_object (&priv->constraints);
 | 
			
		||||
@@ -15884,10 +15900,12 @@ clutter_actor_get_pango_context (ClutterActor *self)
 | 
			
		||||
    {
 | 
			
		||||
      priv->pango_context = clutter_actor_create_pango_context (self);
 | 
			
		||||
 | 
			
		||||
      g_signal_connect_object (backend, "resolution-changed",
 | 
			
		||||
                               G_CALLBACK (update_pango_context), priv->pango_context, 0);
 | 
			
		||||
      g_signal_connect_object (backend, "font-changed",
 | 
			
		||||
                               G_CALLBACK (update_pango_context), priv->pango_context, 0);
 | 
			
		||||
      priv->resolution_changed_id =
 | 
			
		||||
        g_signal_connect_object (backend, "resolution-changed",
 | 
			
		||||
                                 G_CALLBACK (update_pango_context), priv->pango_context, 0);
 | 
			
		||||
      priv->font_changed_id =
 | 
			
		||||
        g_signal_connect_object (backend, "font-changed",
 | 
			
		||||
                                 G_CALLBACK (update_pango_context), priv->pango_context, 0);
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    update_pango_context (backend, priv->pango_context);
 | 
			
		||||
 
 | 
			
		||||
@@ -249,9 +249,7 @@ clutter_blur_effect_init (ClutterBlurEffect *self)
 | 
			
		||||
      cogl_pipeline_add_layer_snippet (klass->base_pipeline, 0, snippet);
 | 
			
		||||
      cogl_object_unref (snippet);
 | 
			
		||||
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
 | 
			
		||||
                                            0, /* layer number */
 | 
			
		||||
                                            COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
 | 
			
		||||
 
 | 
			
		||||
@@ -438,9 +438,7 @@ clutter_brightness_contrast_effect_init (ClutterBrightnessContrastEffect *self)
 | 
			
		||||
      cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
 | 
			
		||||
      cogl_object_unref (snippet);
 | 
			
		||||
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
 | 
			
		||||
                                            0, /* layer number */
 | 
			
		||||
                                            COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
 | 
			
		||||
 
 | 
			
		||||
@@ -293,9 +293,7 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self)
 | 
			
		||||
      cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
 | 
			
		||||
      cogl_object_unref (snippet);
 | 
			
		||||
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
 | 
			
		||||
                                            0, /* layer number */
 | 
			
		||||
                                            COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
 | 
			
		||||
 
 | 
			
		||||
@@ -297,9 +297,7 @@ clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
 | 
			
		||||
      cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
 | 
			
		||||
      cogl_object_unref (snippet);
 | 
			
		||||
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
 | 
			
		||||
                                            0, /* layer number */
 | 
			
		||||
                                            COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  self->pipeline = cogl_pipeline_copy (klass->base_pipeline);
 | 
			
		||||
 
 | 
			
		||||
@@ -909,7 +909,6 @@ typedef enum
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClutterFeatureFlags:
 | 
			
		||||
 * @CLUTTER_FEATURE_TEXTURE_NPOT: Set if NPOTS textures supported.
 | 
			
		||||
 * @CLUTTER_FEATURE_SWAP_THROTTLE: Set if backend throttles buffer swaps.
 | 
			
		||||
 * @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
 | 
			
		||||
 * @CLUTTER_FEATURE_TEXTURE_READ_PIXELS: Set if texture pixels can be read.
 | 
			
		||||
@@ -928,7 +927,6 @@ typedef enum
 | 
			
		||||
 */
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  CLUTTER_FEATURE_TEXTURE_NPOT           = (1 << 2),
 | 
			
		||||
  CLUTTER_FEATURE_SWAP_THROTTLE          = (1 << 3),
 | 
			
		||||
  CLUTTER_FEATURE_TEXTURE_YUV            = (1 << 4),
 | 
			
		||||
  CLUTTER_FEATURE_TEXTURE_READ_PIXELS    = (1 << 5),
 | 
			
		||||
 
 | 
			
		||||
@@ -64,17 +64,13 @@ clutter_features_from_cogl (guint cogl_flags)
 | 
			
		||||
{
 | 
			
		||||
  ClutterFeatureFlags clutter_flags = 0;
 | 
			
		||||
  
 | 
			
		||||
  if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
 | 
			
		||||
    clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
 | 
			
		||||
 | 
			
		||||
  if (cogl_flags & COGL_FEATURE_TEXTURE_YUV)
 | 
			
		||||
    clutter_flags |= CLUTTER_FEATURE_TEXTURE_YUV;
 | 
			
		||||
  
 | 
			
		||||
  if (cogl_flags & COGL_FEATURE_TEXTURE_READ_PIXELS)
 | 
			
		||||
    clutter_flags |= CLUTTER_FEATURE_TEXTURE_READ_PIXELS;
 | 
			
		||||
  
 | 
			
		||||
  if (cogl_flags & COGL_FEATURE_SHADERS_GLSL)
 | 
			
		||||
    clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
 | 
			
		||||
  clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
 | 
			
		||||
  
 | 
			
		||||
  if (cogl_flags & COGL_FEATURE_OFFSCREEN)
 | 
			
		||||
    clutter_flags |= CLUTTER_FEATURE_OFFSCREEN;
 | 
			
		||||
 
 | 
			
		||||
@@ -75,8 +75,7 @@ _clutter_paint_node_init_types (void)
 | 
			
		||||
  cogl_pipeline_set_color (default_color_pipeline, &cogl_color);
 | 
			
		||||
 | 
			
		||||
  default_texture_pipeline = cogl_pipeline_new (ctx);
 | 
			
		||||
  cogl_pipeline_set_layer_null_texture (default_texture_pipeline, 0,
 | 
			
		||||
                                        COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
  cogl_pipeline_set_layer_null_texture (default_texture_pipeline, 0);
 | 
			
		||||
  cogl_pipeline_set_color (default_texture_pipeline, &cogl_color);
 | 
			
		||||
  cogl_pipeline_set_layer_wrap_mode (default_texture_pipeline, 0,
 | 
			
		||||
                                     COGL_PIPELINE_WRAP_MODE_AUTOMATIC);
 | 
			
		||||
 
 | 
			
		||||
@@ -1277,9 +1277,7 @@ clutter_texture_init (ClutterTexture *self)
 | 
			
		||||
 | 
			
		||||
      texture_template_pipeline = cogl_pipeline_new (ctx);
 | 
			
		||||
      pipeline = COGL_PIPELINE (texture_template_pipeline);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (pipeline,
 | 
			
		||||
                                            0, /* layer_index */
 | 
			
		||||
                                            COGL_TEXTURE_TYPE_2D);
 | 
			
		||||
      cogl_pipeline_set_layer_null_texture (pipeline, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_assert (texture_template_pipeline != NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -855,6 +855,14 @@ emulate_pointer_motion (ClutterInputDeviceEvdev *device,
 | 
			
		||||
  clutter_virtual_input_device_notify_relative_motion (device->mousekeys_virtual_device,
 | 
			
		||||
                                                       time_us, dx_motion, dy_motion);
 | 
			
		||||
}
 | 
			
		||||
static gboolean
 | 
			
		||||
is_numlock_active (ClutterInputDeviceEvdev *device)
 | 
			
		||||
{
 | 
			
		||||
  ClutterSeatEvdev *seat = device->seat;
 | 
			
		||||
  return xkb_state_mod_name_is_active (seat->xkb,
 | 
			
		||||
                                       "Mod2",
 | 
			
		||||
                                       XKB_STATE_MODS_LOCKED);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
enable_mousekeys (ClutterInputDeviceEvdev *device)
 | 
			
		||||
@@ -1013,6 +1021,10 @@ handle_mousekeys_press (ClutterEvent            *event,
 | 
			
		||||
  if (!(event->key.flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
 | 
			
		||||
    stop_mousekeys_move (device);
 | 
			
		||||
 | 
			
		||||
  /* Do not handle mousekeys if NumLock is ON */
 | 
			
		||||
  if (is_numlock_active (device))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  /* Button selection */
 | 
			
		||||
  switch (event->key.keyval)
 | 
			
		||||
    {
 | 
			
		||||
@@ -1084,6 +1096,10 @@ static gboolean
 | 
			
		||||
handle_mousekeys_release (ClutterEvent            *event,
 | 
			
		||||
                          ClutterInputDeviceEvdev *device)
 | 
			
		||||
{
 | 
			
		||||
  /* Do not handle mousekeys if NumLock is ON */
 | 
			
		||||
  if (is_numlock_active (device))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  switch (event->key.keyval)
 | 
			
		||||
    {
 | 
			
		||||
    case XKB_KEY_KP_0:
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,7 @@
 | 
			
		||||
#include "clutter-main.h"
 | 
			
		||||
#include "clutter-private.h"
 | 
			
		||||
#include "clutter-settings-private.h"
 | 
			
		||||
#include "clutter-xkb-a11y-x11.h"
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND)
 | 
			
		||||
 | 
			
		||||
@@ -276,6 +277,20 @@ clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
 | 
			
		||||
  _clutter_backend_add_event_translator (backend, translator);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_keymap_state_change (ClutterKeymapX11 *keymap_x11,
 | 
			
		||||
                        gpointer          data)
 | 
			
		||||
{
 | 
			
		||||
  ClutterDeviceManager *device_manager = CLUTTER_DEVICE_MANAGER (data);
 | 
			
		||||
  ClutterKbdA11ySettings kbd_a11y_settings;
 | 
			
		||||
 | 
			
		||||
  /* On keymaps state change, just reapply the current settings, it'll
 | 
			
		||||
   * take care of enabling/disabling mousekeys based on NumLock state.
 | 
			
		||||
   */
 | 
			
		||||
  clutter_device_manager_get_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
 | 
			
		||||
  clutter_device_manager_x11_apply_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
 | 
			
		||||
{
 | 
			
		||||
@@ -292,6 +307,11 @@ clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
 | 
			
		||||
      backend = CLUTTER_BACKEND (backend_x11);
 | 
			
		||||
      translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->keymap);
 | 
			
		||||
      _clutter_backend_add_event_translator (backend, translator);
 | 
			
		||||
 | 
			
		||||
      g_signal_connect (backend_x11->keymap,
 | 
			
		||||
                        "state-changed",
 | 
			
		||||
                        G_CALLBACK (on_keymap_state_change),
 | 
			
		||||
                        backend->device_manager);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -241,8 +241,13 @@ clutter_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager   *devi
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* mouse keys */
 | 
			
		||||
  if (set_xkb_ctrl (desc, kbd_a11y_settings->controls,
 | 
			
		||||
                    CLUTTER_A11Y_MOUSE_KEYS_ENABLED, XkbMouseKeysMask | XkbMouseKeysAccelMask))
 | 
			
		||||
  if (clutter_keymap_get_num_lock_state (CLUTTER_KEYMAP (backend_x11->keymap)))
 | 
			
		||||
    {
 | 
			
		||||
      /* Disable mousekeys when NumLock is ON */
 | 
			
		||||
      desc->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | XkbMouseKeysAccelMask);
 | 
			
		||||
    }
 | 
			
		||||
  else if (set_xkb_ctrl (desc, kbd_a11y_settings->controls,
 | 
			
		||||
                         CLUTTER_A11Y_MOUSE_KEYS_ENABLED, XkbMouseKeysMask | XkbMouseKeysAccelMask))
 | 
			
		||||
    {
 | 
			
		||||
      gint mk_max_speed;
 | 
			
		||||
      gint mk_accel_time;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
clutter_includesubdir = join_paths(pkgname, 'clutter')
 | 
			
		||||
clutter_includedir = join_paths(includedir, clutter_includesubdir)
 | 
			
		||||
clutter_srcdir = join_paths(top_srcdir, 'clutter')
 | 
			
		||||
clutter_builddir = join_paths(builddir, 'clutter')
 | 
			
		||||
 | 
			
		||||
clutter_includepath = include_directories('.', 'clutter')
 | 
			
		||||
clutter_includes = [clutter_includepath, cogl_includepath]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,3 @@
 | 
			
		||||
clutter_tests_conform_srcdir = join_paths(clutter_srcdir, 'tests/conform')
 | 
			
		||||
clutter_tests_conform_builddir = join_paths(clutter_builddir, 'tests/conform')
 | 
			
		||||
 | 
			
		||||
clutter_tests_conform_c_args = [
 | 
			
		||||
  '-DG_LOG_DOMAIN="Clutter-Conform"',
 | 
			
		||||
  '-DCOGL_DISABLE_DEPRECATION_WARNINGS',
 | 
			
		||||
@@ -52,8 +49,8 @@ clutter_conform_tests += clutter_conform_tests_general_tests
 | 
			
		||||
clutter_conform_tests += clutter_conform_tests_deprecated_tests
 | 
			
		||||
 | 
			
		||||
test_env = environment()
 | 
			
		||||
test_env.set('G_TEST_SRCDIR', clutter_tests_conform_srcdir)
 | 
			
		||||
test_env.set('G_TEST_BUILDDIR', clutter_tests_conform_builddir)
 | 
			
		||||
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
 | 
			
		||||
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
 | 
			
		||||
test_env.set('G_ENABLE_DIAGNOSTIC', '0')
 | 
			
		||||
test_env.set('CLUTTER_ENABLE_DIAGNOSTIC', '0')
 | 
			
		||||
test_env.set('CLUTTER_SCALE', '1')
 | 
			
		||||
@@ -74,7 +71,8 @@ foreach test : clutter_conform_tests
 | 
			
		||||
    install: false,
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  test('clutter/conform/@0@'.format(test), test_executable,
 | 
			
		||||
  test(test, test_executable,
 | 
			
		||||
    suite: ['clutter', 'clutter/conform'],
 | 
			
		||||
    env: test_env
 | 
			
		||||
  )
 | 
			
		||||
endforeach
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
clutter_tests_interactive_srcdir = join_paths(clutter_srcdir, 'tests/interactive')
 | 
			
		||||
 | 
			
		||||
clutter_tests_interactive_srcdir = meson.current_source_dir()
 | 
			
		||||
clutter_tests_interactive_includepath = include_directories('.')
 | 
			
		||||
#clutter_tests_interactive_builddir = join_paths(clutter_builddir, 'tests/interactive')
 | 
			
		||||
 | 
			
		||||
clutter_tests_interactive_c_args = [
 | 
			
		||||
  '-DTESTS_DATADIR="@0@"'.format(clutter_tests_interactive_srcdir),
 | 
			
		||||
@@ -31,7 +29,6 @@ clutter_tests_interactive_test_sources = [
 | 
			
		||||
  'test-fbo.c',
 | 
			
		||||
  'test-cogl-tex-tile.c',
 | 
			
		||||
  'test-cogl-tex-convert.c',
 | 
			
		||||
  'test-cogl-tex-foreign.c',
 | 
			
		||||
  'test-cogl-offscreen.c',
 | 
			
		||||
  'test-cogl-tex-polygon.c',
 | 
			
		||||
  'test-cogl-multitexture.c',
 | 
			
		||||
 
 | 
			
		||||
@@ -1,276 +0,0 @@
 | 
			
		||||
#include <glib.h>
 | 
			
		||||
#include <gmodule.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <clutter/clutter.h>
 | 
			
		||||
#include <cogl/cogl.h>
 | 
			
		||||
 | 
			
		||||
#ifndef GL_UNPACK_ALIGNMENT
 | 
			
		||||
#define GL_UNPACK_ALIGNMENT 0x0CF5
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_TEXTURE_BINDING_2D
 | 
			
		||||
#define GL_TEXTURE_BINDING_2D 0x8069
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_TEXTURE_2D
 | 
			
		||||
#define GL_TEXTURE_2D 0x0DE1
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_RGB
 | 
			
		||||
#define GL_RGB 0x1907
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_UNSIGNED_BYTE
 | 
			
		||||
#define GL_UNSIGNED_BYTE 0x1401
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_TEXTURE_MAG_FILTER
 | 
			
		||||
#define GL_TEXTURE_MAG_FILTER 0x2800
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_LINEAR
 | 
			
		||||
#define GL_LINEAR 0x1208
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_TEXTURE_MIN_FILTER
 | 
			
		||||
#define GL_TEXTURE_MIN_FILTER 0x2801
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Coglbox declaration
 | 
			
		||||
 *--------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
  
 | 
			
		||||
#define TEST_TYPE_COGLBOX test_coglbox_get_type()
 | 
			
		||||
 | 
			
		||||
#define TEST_COGLBOX(obj) \
 | 
			
		||||
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
 | 
			
		||||
  TEST_TYPE_COGLBOX, TestCoglboxClass))
 | 
			
		||||
 | 
			
		||||
#define TEST_COGLBOX_CLASS(klass) \
 | 
			
		||||
  (G_TYPE_CHECK_CLASS_CAST ((klass), \
 | 
			
		||||
  TEST_TYPE_COGLBOX, TestCoglboxClass))
 | 
			
		||||
 | 
			
		||||
#define TEST_IS_COGLBOX(obj) \
 | 
			
		||||
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
 | 
			
		||||
  TEST_TYPE_COGLBOX))
 | 
			
		||||
 | 
			
		||||
#define TEST_IS_COGLBOX_CLASS(klass) \
 | 
			
		||||
  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
 | 
			
		||||
  TEST_TYPE_COGLBOX))
 | 
			
		||||
 | 
			
		||||
#define TEST_COGLBOX_GET_CLASS(obj) \
 | 
			
		||||
  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
 | 
			
		||||
  TEST_TYPE_COGLBOX, TestCoglboxClass))
 | 
			
		||||
 | 
			
		||||
typedef struct _TestCoglbox        TestCoglbox;
 | 
			
		||||
typedef struct _TestCoglboxClass   TestCoglboxClass;
 | 
			
		||||
typedef struct _TestCoglboxPrivate TestCoglboxPrivate;
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
test_cogl_tex_foreign_describe (void);
 | 
			
		||||
 | 
			
		||||
struct _TestCoglbox
 | 
			
		||||
{
 | 
			
		||||
  ClutterActor           parent;
 | 
			
		||||
 | 
			
		||||
  /*< private >*/
 | 
			
		||||
  TestCoglboxPrivate *priv;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct _TestCoglboxClass 
 | 
			
		||||
{
 | 
			
		||||
  ClutterActorClass parent_class;
 | 
			
		||||
 | 
			
		||||
  /* padding for future expansion */
 | 
			
		||||
  void (*_test_coglbox1) (void);
 | 
			
		||||
  void (*_test_coglbox2) (void);
 | 
			
		||||
  void (*_test_coglbox3) (void);
 | 
			
		||||
  void (*_test_coglbox4) (void);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static GType test_coglbox_get_type (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
/* Coglbox private declaration
 | 
			
		||||
 *--------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
struct _TestCoglboxPrivate
 | 
			
		||||
{
 | 
			
		||||
  guint      gl_handle;
 | 
			
		||||
  CoglHandle cogl_handle;
 | 
			
		||||
 | 
			
		||||
  void
 | 
			
		||||
  (* glGetIntegerv) (guint pname, int *params);
 | 
			
		||||
  void
 | 
			
		||||
  (* glPixelStorei) (guint pname, int param);
 | 
			
		||||
  void
 | 
			
		||||
  (* glTexParameteri) (guint target, guint pname, int param);
 | 
			
		||||
  void
 | 
			
		||||
  (* glTexImage2D) (guint target, int level,
 | 
			
		||||
                    int internalFormat,
 | 
			
		||||
                    int width, int height,
 | 
			
		||||
                    int border, guint format, guint type,
 | 
			
		||||
                    const void *pixels);
 | 
			
		||||
  void
 | 
			
		||||
  (* glGenTextures) (int n, guint *textures);
 | 
			
		||||
  void
 | 
			
		||||
  (* glDeleteTextures) (int n, const guint *textures);
 | 
			
		||||
  void
 | 
			
		||||
  (* glBindTexture) (guint target, guint texture);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR);
 | 
			
		||||
 | 
			
		||||
#define TEST_COGLBOX_GET_PRIVATE(obj) \
 | 
			
		||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), TEST_TYPE_COGLBOX, TestCoglboxPrivate))
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
test_cogl_tex_foreign_main (int argc, char *argv[]);
 | 
			
		||||
 | 
			
		||||
/* Coglbox implementation
 | 
			
		||||
 *--------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_coglbox_paint(ClutterActor *self)
 | 
			
		||||
{
 | 
			
		||||
  TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
 | 
			
		||||
  gfloat texcoords[4] = { 0.3f, 0.3f, 0.7f, 0.7f };
 | 
			
		||||
  
 | 
			
		||||
  cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff);
 | 
			
		||||
  cogl_rectangle (0,0,400,400);
 | 
			
		||||
  
 | 
			
		||||
  cogl_push_matrix ();
 | 
			
		||||
  
 | 
			
		||||
  cogl_translate (100,100,0);
 | 
			
		||||
  cogl_set_source_texture (priv->cogl_handle);
 | 
			
		||||
  cogl_rectangle_with_texture_coords (0, 0, 200, 200,
 | 
			
		||||
                                      texcoords[0], texcoords[1],
 | 
			
		||||
                                      texcoords[2], texcoords[3]);
 | 
			
		||||
  
 | 
			
		||||
  cogl_pop_matrix();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_coglbox_finalize (GObject *object)
 | 
			
		||||
{
 | 
			
		||||
  G_OBJECT_CLASS (test_coglbox_parent_class)->finalize (object);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_coglbox_dispose (GObject *object)
 | 
			
		||||
{
 | 
			
		||||
  TestCoglboxPrivate *priv;
 | 
			
		||||
  
 | 
			
		||||
  priv = TEST_COGLBOX_GET_PRIVATE (object);
 | 
			
		||||
  
 | 
			
		||||
  cogl_handle_unref (priv->cogl_handle);
 | 
			
		||||
  priv->glDeleteTextures (1, &priv->gl_handle);
 | 
			
		||||
  
 | 
			
		||||
  G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_coglbox_init (TestCoglbox *self)
 | 
			
		||||
{
 | 
			
		||||
  TestCoglboxPrivate *priv;
 | 
			
		||||
  guchar              data[12];
 | 
			
		||||
  int prev_unpack_alignment;
 | 
			
		||||
  int prev_2d_texture_binding;
 | 
			
		||||
  
 | 
			
		||||
  self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
 | 
			
		||||
  
 | 
			
		||||
  /* Prepare a 2x2 pixels texture */
 | 
			
		||||
  
 | 
			
		||||
  data[0] = 255; data[1]  =   0; data[2]  =   0;
 | 
			
		||||
  data[3] =   0; data[4]  = 255; data[5]  =   0;
 | 
			
		||||
  data[6] =   0; data[7]  =   0; data[8]  = 255;
 | 
			
		||||
  data[9] =   0; data[10] =   0; data[11] =   0;
 | 
			
		||||
 | 
			
		||||
  priv->glGetIntegerv = (void *) cogl_get_proc_address ("glGetIntegerv");
 | 
			
		||||
  priv->glPixelStorei = (void *) cogl_get_proc_address ("glPixelStorei");
 | 
			
		||||
  priv->glTexParameteri = (void *) cogl_get_proc_address ("glTexParameteri");
 | 
			
		||||
  priv->glTexImage2D = (void *) cogl_get_proc_address ("glTexImage2D");
 | 
			
		||||
  priv->glGenTextures = (void *) cogl_get_proc_address ("glGenTextures");
 | 
			
		||||
  priv->glDeleteTextures = (void *) cogl_get_proc_address ("glDeleteTextures");
 | 
			
		||||
  priv->glBindTexture = (void *) cogl_get_proc_address ("glBindTexture");
 | 
			
		||||
 | 
			
		||||
  /* We are about to use OpenGL directly to create a TEXTURE_2D
 | 
			
		||||
   * texture so we need to save the state that we modify so we can
 | 
			
		||||
   * restore it afterwards and be sure not to interfere with any state
 | 
			
		||||
   * caching that Cogl may do internally.
 | 
			
		||||
   */
 | 
			
		||||
  priv->glGetIntegerv (GL_UNPACK_ALIGNMENT, &prev_unpack_alignment);
 | 
			
		||||
  priv->glGetIntegerv (GL_TEXTURE_BINDING_2D, &prev_2d_texture_binding);
 | 
			
		||||
 | 
			
		||||
  priv->glGenTextures (1, &priv->gl_handle);
 | 
			
		||||
  priv->glBindTexture (GL_TEXTURE_2D, priv->gl_handle);
 | 
			
		||||
  
 | 
			
		||||
  priv->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
 | 
			
		||||
  priv->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB,
 | 
			
		||||
		2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
 | 
			
		||||
 | 
			
		||||
  /* Now restore the original GL state as Cogl had left it */
 | 
			
		||||
  priv->glPixelStorei (GL_UNPACK_ALIGNMENT, prev_unpack_alignment);
 | 
			
		||||
  priv->glBindTexture (GL_TEXTURE_2D, prev_2d_texture_binding);
 | 
			
		||||
  
 | 
			
		||||
  priv->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 | 
			
		||||
  priv->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 | 
			
		||||
  
 | 
			
		||||
  /* Create texture from foreign */
 | 
			
		||||
  
 | 
			
		||||
  priv->cogl_handle =
 | 
			
		||||
    cogl_texture_new_from_foreign (priv->gl_handle,
 | 
			
		||||
				   GL_TEXTURE_2D,
 | 
			
		||||
				   2, 2, 0, 0,
 | 
			
		||||
				   COGL_PIXEL_FORMAT_RGB_888);
 | 
			
		||||
  
 | 
			
		||||
  if (priv->cogl_handle == COGL_INVALID_HANDLE)
 | 
			
		||||
    {
 | 
			
		||||
      printf ("Failed creating texture from foreign!\n");
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_coglbox_class_init (TestCoglboxClass *klass)
 | 
			
		||||
{
 | 
			
		||||
  GObjectClass      *gobject_class = G_OBJECT_CLASS (klass);
 | 
			
		||||
  ClutterActorClass *actor_class   = CLUTTER_ACTOR_CLASS (klass);
 | 
			
		||||
 | 
			
		||||
  gobject_class->finalize     = test_coglbox_finalize;
 | 
			
		||||
  gobject_class->dispose      = test_coglbox_dispose;  
 | 
			
		||||
  actor_class->paint          = test_coglbox_paint;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ClutterActor*
 | 
			
		||||
test_coglbox_new (void)
 | 
			
		||||
{
 | 
			
		||||
  return g_object_new (TEST_TYPE_COGLBOX, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
G_MODULE_EXPORT int
 | 
			
		||||
test_cogl_tex_foreign_main (int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
  ClutterActor     *stage;
 | 
			
		||||
  ClutterActor     *coglbox;
 | 
			
		||||
  
 | 
			
		||||
  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
 | 
			
		||||
    return 1;
 | 
			
		||||
  
 | 
			
		||||
  /* Stage */
 | 
			
		||||
  stage = clutter_stage_new ();
 | 
			
		||||
  clutter_actor_set_size (stage, 400, 400);
 | 
			
		||||
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Foreign Textures");
 | 
			
		||||
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
 | 
			
		||||
 | 
			
		||||
  /* Cogl Box */
 | 
			
		||||
  coglbox = test_coglbox_new ();
 | 
			
		||||
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
 | 
			
		||||
  
 | 
			
		||||
  clutter_actor_show_all (stage);
 | 
			
		||||
  
 | 
			
		||||
  clutter_main ();
 | 
			
		||||
  
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
G_MODULE_EXPORT const char *
 | 
			
		||||
test_cogl_tex_foreign_describe (void)
 | 
			
		||||
{
 | 
			
		||||
  return "Foreign textures support in Cogl.";
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
clutter_tests_performance_c_args = [
 | 
			
		||||
  '-DTESTS_DATA_DIR="@0@"'.format(join_paths(clutter_srcdir, 'tests/interactive')),
 | 
			
		||||
  '-DTESTS_DATA_DIR="@0@"'.format(clutter_tests_interactive_srcdir),
 | 
			
		||||
  '-DG_DISABLE_SINGLE_INCLUDES',
 | 
			
		||||
  '-DGLIB_DISABLE_DEPRECATION_WARNINGS',
 | 
			
		||||
  '-DCOGL_DISABLE_DEPRECATION_WARNINGS',
 | 
			
		||||
 
 | 
			
		||||
@@ -1013,12 +1013,6 @@ _cogl_atlas_texture_remove_reorganize_callback (CoglContext *ctx,
 | 
			
		||||
    g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_atlas_texture_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_atlas_texture_vtable =
 | 
			
		||||
  {
 | 
			
		||||
@@ -1040,7 +1034,6 @@ cogl_atlas_texture_vtable =
 | 
			
		||||
    _cogl_atlas_texture_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_atlas_texture_get_format,
 | 
			
		||||
    _cogl_atlas_texture_get_gl_format,
 | 
			
		||||
    _cogl_atlas_texture_get_type,
 | 
			
		||||
    NULL, /* is_foreign */
 | 
			
		||||
    NULL /* set_auto_mipmap */
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -562,29 +562,21 @@ create_migration_texture (CoglContext *ctx,
 | 
			
		||||
  CoglTexture *tex;
 | 
			
		||||
  CoglError *skip_error = NULL;
 | 
			
		||||
 | 
			
		||||
  if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
 | 
			
		||||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
  tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
  /* TODO: instead of allocating storage here it would be better
 | 
			
		||||
   * if we had some api that let us just check that the size is
 | 
			
		||||
   * supported by the hardware so storage could be allocated
 | 
			
		||||
   * lazily when uploading data. */
 | 
			
		||||
  if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
    {
 | 
			
		||||
      /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
 | 
			
		||||
                                                         width, height));
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
      /* TODO: instead of allocating storage here it would be better
 | 
			
		||||
       * if we had some api that let us just check that the size is
 | 
			
		||||
       * supported by the hardware so storage could be allocated
 | 
			
		||||
       * lazily when uploading data. */
 | 
			
		||||
      if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (skip_error);
 | 
			
		||||
          cogl_object_unref (tex);
 | 
			
		||||
          tex = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      cogl_error_free (skip_error);
 | 
			
		||||
      cogl_object_unref (tex);
 | 
			
		||||
      tex = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -50,8 +50,6 @@
 | 
			
		||||
#include "cogl-texture-driver.h"
 | 
			
		||||
#include "cogl-pipeline-cache.h"
 | 
			
		||||
#include "cogl-texture-2d.h"
 | 
			
		||||
#include "cogl-texture-3d.h"
 | 
			
		||||
#include "cogl-texture-rectangle.h"
 | 
			
		||||
#include "cogl-sampler-cache-private.h"
 | 
			
		||||
#include "cogl-gpu-info-private.h"
 | 
			
		||||
#include "cogl-gl-header.h"
 | 
			
		||||
@@ -166,8 +164,6 @@ struct _CoglContext
 | 
			
		||||
 | 
			
		||||
  /* Textures */
 | 
			
		||||
  CoglTexture2D *default_gl_texture_2d_tex;
 | 
			
		||||
  CoglTexture3D *default_gl_texture_3d_tex;
 | 
			
		||||
  CoglTextureRectangle *default_gl_texture_rect_tex;
 | 
			
		||||
 | 
			
		||||
  /* Central list of all framebuffers so all journals can be flushed
 | 
			
		||||
   * at any time. */
 | 
			
		||||
@@ -297,8 +293,6 @@ struct _CoglContext
 | 
			
		||||
  gboolean          buffer_map_fallback_in_use;
 | 
			
		||||
  size_t            buffer_map_fallback_offset;
 | 
			
		||||
 | 
			
		||||
  CoglWinsysRectangleState rectangle_state;
 | 
			
		||||
 | 
			
		||||
  CoglSamplerCache *sampler_cache;
 | 
			
		||||
 | 
			
		||||
  /* FIXME: remove these when we remove the last xlib based clutter
 | 
			
		||||
 
 | 
			
		||||
@@ -40,8 +40,6 @@
 | 
			
		||||
#include "cogl-journal-private.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
#include "cogl-texture-2d-private.h"
 | 
			
		||||
#include "cogl-texture-3d-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-pipeline-private.h"
 | 
			
		||||
#include "cogl-framebuffer-private.h"
 | 
			
		||||
#include "cogl-onscreen-private.h"
 | 
			
		||||
@@ -106,30 +104,6 @@ _cogl_init_feature_overrides (CoglContext *ctx)
 | 
			
		||||
 | 
			
		||||
  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PBOS)))
 | 
			
		||||
    COGL_FLAGS_SET (ctx->private_features, COGL_PRIVATE_FEATURE_PBOS, FALSE);
 | 
			
		||||
 | 
			
		||||
  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_GLSL)))
 | 
			
		||||
    {
 | 
			
		||||
      ctx->feature_flags &= ~COGL_FEATURE_SHADERS_GLSL;
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_GLSL, FALSE);
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features,
 | 
			
		||||
                      COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE,
 | 
			
		||||
                      FALSE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_NPOT_TEXTURES)))
 | 
			
		||||
    {
 | 
			
		||||
      ctx->feature_flags &= ~(COGL_FEATURE_TEXTURE_NPOT |
 | 
			
		||||
                              COGL_FEATURE_TEXTURE_NPOT_BASIC |
 | 
			
		||||
                              COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
 | 
			
		||||
                              COGL_FEATURE_TEXTURE_NPOT_REPEAT);
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT, FALSE);
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features,
 | 
			
		||||
                      COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, FALSE);
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features,
 | 
			
		||||
                      COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP, FALSE);
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features,
 | 
			
		||||
                      COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, FALSE);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const CoglWinsysVtable *
 | 
			
		||||
@@ -153,10 +127,8 @@ cogl_context_new (CoglDisplay *display,
 | 
			
		||||
{
 | 
			
		||||
  CoglContext *context;
 | 
			
		||||
  uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
 | 
			
		||||
  CoglBitmap *white_pixel_bitmap;
 | 
			
		||||
  const CoglWinsysVtable *winsys;
 | 
			
		||||
  int i;
 | 
			
		||||
  CoglError *internal_error = NULL;
 | 
			
		||||
 | 
			
		||||
  _cogl_init ();
 | 
			
		||||
 | 
			
		||||
@@ -197,9 +169,6 @@ cogl_context_new (CoglDisplay *display,
 | 
			
		||||
  memset (context->features, 0, sizeof (context->features));
 | 
			
		||||
  context->feature_flags = 0;
 | 
			
		||||
  memset (context->private_features, 0, sizeof (context->private_features));
 | 
			
		||||
 | 
			
		||||
  context->rectangle_state = COGL_WINSYS_RECTANGLE_STATE_UNKNOWN;
 | 
			
		||||
 | 
			
		||||
  memset (context->winsys_features, 0, sizeof (context->winsys_features));
 | 
			
		||||
 | 
			
		||||
  if (!display)
 | 
			
		||||
@@ -307,8 +276,6 @@ cogl_context_new (CoglDisplay *display,
 | 
			
		||||
  context->legacy_state_set = 0;
 | 
			
		||||
 | 
			
		||||
  context->default_gl_texture_2d_tex = NULL;
 | 
			
		||||
  context->default_gl_texture_3d_tex = NULL;
 | 
			
		||||
  context->default_gl_texture_rect_tex = NULL;
 | 
			
		||||
 | 
			
		||||
  context->framebuffers = NULL;
 | 
			
		||||
  context->current_draw_buffer = NULL;
 | 
			
		||||
@@ -436,41 +403,6 @@ cogl_context_new (CoglDisplay *display,
 | 
			
		||||
                                   white_pixel,
 | 
			
		||||
                                   NULL); /* abort on error */
 | 
			
		||||
 | 
			
		||||
  /* If 3D or rectangle textures aren't supported then these will
 | 
			
		||||
   * return errors that we can simply ignore. */
 | 
			
		||||
  internal_error = NULL;
 | 
			
		||||
  context->default_gl_texture_3d_tex =
 | 
			
		||||
    cogl_texture_3d_new_from_data (context,
 | 
			
		||||
                                   1, 1, 1, /* width, height, depth */
 | 
			
		||||
                                   COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                                   0, /* rowstride */
 | 
			
		||||
                                   0, /* image stride */
 | 
			
		||||
                                   white_pixel,
 | 
			
		||||
                                   &internal_error);
 | 
			
		||||
  if (internal_error)
 | 
			
		||||
    cogl_error_free (internal_error);
 | 
			
		||||
 | 
			
		||||
  /* TODO: add cogl_texture_rectangle_new_from_data() */
 | 
			
		||||
  white_pixel_bitmap =
 | 
			
		||||
    cogl_bitmap_new_for_data (context,
 | 
			
		||||
                              1, 1, /* width/height */
 | 
			
		||||
                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                              4, /* rowstride */
 | 
			
		||||
                              white_pixel);
 | 
			
		||||
 | 
			
		||||
  internal_error = NULL;
 | 
			
		||||
  context->default_gl_texture_rect_tex =
 | 
			
		||||
    cogl_texture_rectangle_new_from_bitmap (white_pixel_bitmap);
 | 
			
		||||
 | 
			
		||||
  /* XXX: we need to allocate the texture now because the white_pixel
 | 
			
		||||
   * data is on the stack */
 | 
			
		||||
  cogl_texture_allocate (COGL_TEXTURE (context->default_gl_texture_rect_tex),
 | 
			
		||||
                         &internal_error);
 | 
			
		||||
  if (internal_error)
 | 
			
		||||
    cogl_error_free (internal_error);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (white_pixel_bitmap);
 | 
			
		||||
 | 
			
		||||
  cogl_push_source (context->opaque_color_pipeline);
 | 
			
		||||
 | 
			
		||||
  context->atlases = NULL;
 | 
			
		||||
@@ -509,10 +441,6 @@ _cogl_context_free (CoglContext *context)
 | 
			
		||||
 | 
			
		||||
  if (context->default_gl_texture_2d_tex)
 | 
			
		||||
    cogl_object_unref (context->default_gl_texture_2d_tex);
 | 
			
		||||
  if (context->default_gl_texture_3d_tex)
 | 
			
		||||
    cogl_object_unref (context->default_gl_texture_3d_tex);
 | 
			
		||||
  if (context->default_gl_texture_rect_tex)
 | 
			
		||||
    cogl_object_unref (context->default_gl_texture_rect_tex);
 | 
			
		||||
 | 
			
		||||
  if (context->opaque_color_pipeline)
 | 
			
		||||
    cogl_object_unref (context->opaque_color_pipeline);
 | 
			
		||||
 
 | 
			
		||||
@@ -174,33 +174,14 @@ cogl_is_context (void *object);
 | 
			
		||||
 * experimental since it's only useable with experimental API... */
 | 
			
		||||
/**
 | 
			
		||||
 * CoglFeatureID:
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_NPOT_BASIC: The hardware supports non power
 | 
			
		||||
 *     of two textures, but you also need to check the
 | 
			
		||||
 *     %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT
 | 
			
		||||
 *     features to know if the hardware supports npot texture mipmaps
 | 
			
		||||
 *     or repeat modes other than
 | 
			
		||||
 *     %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
 | 
			
		||||
 *     conjuntion with non power of two textures.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT: Repeat modes other than
 | 
			
		||||
 *     %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the
 | 
			
		||||
 *     hardware.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_NPOT: Non power of two textures are supported
 | 
			
		||||
 *    by the hardware. This is a equivalent to the
 | 
			
		||||
 *    %COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP
 | 
			
		||||
 *    and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features combined.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_RECTANGLE: Support for rectangular
 | 
			
		||||
 *    textures with non-normalized texture coordinates.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_RG: Support for
 | 
			
		||||
 *    %COGL_TEXTURE_COMPONENTS_RG as the internal components of a
 | 
			
		||||
 *    texture.
 | 
			
		||||
 * @COGL_FEATURE_ID_TEXTURE_3D: 3D texture support
 | 
			
		||||
 * @COGL_FEATURE_ID_OFFSCREEN: Offscreen rendering support
 | 
			
		||||
 * @COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE: Multisample support for
 | 
			
		||||
 *    offscreen framebuffers
 | 
			
		||||
 * @COGL_FEATURE_ID_ONSCREEN_MULTIPLE: Multiple onscreen framebuffers
 | 
			
		||||
 *    supported.
 | 
			
		||||
 * @COGL_FEATURE_ID_GLSL: GLSL support
 | 
			
		||||
 * @COGL_FEATURE_ID_UNSIGNED_INT_INDICES: Set if
 | 
			
		||||
 *     %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
 | 
			
		||||
 *     cogl_indices_new().
 | 
			
		||||
@@ -236,13 +217,6 @@ cogl_is_context (void *object);
 | 
			
		||||
 */
 | 
			
		||||
typedef enum _CoglFeatureID
 | 
			
		||||
{
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_NPOT_BASIC = 1,
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP,
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT,
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_NPOT,
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_RECTANGLE,
 | 
			
		||||
  COGL_FEATURE_ID_TEXTURE_3D,
 | 
			
		||||
  COGL_FEATURE_ID_GLSL,
 | 
			
		||||
  COGL_FEATURE_ID_OFFSCREEN,
 | 
			
		||||
  COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
 | 
			
		||||
  COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
 | 
			
		||||
 
 | 
			
		||||
@@ -130,22 +130,11 @@ OPT (DISABLE_TEXTURING,
 | 
			
		||||
     "disable-texturing",
 | 
			
		||||
     N_("Disable texturing"),
 | 
			
		||||
     N_("Disable texturing any primitives"))
 | 
			
		||||
OPT (DISABLE_GLSL,
 | 
			
		||||
     N_("Root Cause"),
 | 
			
		||||
     "disable-glsl",
 | 
			
		||||
     N_("Disable GLSL"),
 | 
			
		||||
     N_("Disable use of GLSL"))
 | 
			
		||||
OPT (DISABLE_BLENDING,
 | 
			
		||||
     N_("Root Cause"),
 | 
			
		||||
     "disable-blending",
 | 
			
		||||
     N_("Disable blending"),
 | 
			
		||||
     N_("Disable use of blending"))
 | 
			
		||||
OPT (DISABLE_NPOT_TEXTURES,
 | 
			
		||||
     N_("Root Cause"),
 | 
			
		||||
     "disable-npot-textures",
 | 
			
		||||
     N_("Disable non-power-of-two textures"),
 | 
			
		||||
     N_("Makes Cogl think that the GL driver doesn't support NPOT textures "
 | 
			
		||||
        "so that it will create sliced textures or textures with waste instead."))
 | 
			
		||||
OPT (DISABLE_SOFTWARE_CLIP,
 | 
			
		||||
     N_("Root Cause"),
 | 
			
		||||
     "disable-software-clip",
 | 
			
		||||
 
 | 
			
		||||
@@ -77,9 +77,7 @@ static const GDebugKey cogl_behavioural_debug_keys[] = {
 | 
			
		||||
  { "disable-atlas", COGL_DEBUG_DISABLE_ATLAS },
 | 
			
		||||
  { "disable-shared-atlas", COGL_DEBUG_DISABLE_SHARED_ATLAS },
 | 
			
		||||
  { "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
 | 
			
		||||
  { "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
 | 
			
		||||
  { "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
 | 
			
		||||
  { "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES},
 | 
			
		||||
  { "wireframe", COGL_DEBUG_WIREFRAME},
 | 
			
		||||
  { "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP},
 | 
			
		||||
  { "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES},
 | 
			
		||||
 
 | 
			
		||||
@@ -61,12 +61,10 @@ typedef enum
 | 
			
		||||
  COGL_DEBUG_DISABLE_SHARED_ATLAS,
 | 
			
		||||
  COGL_DEBUG_OPENGL,
 | 
			
		||||
  COGL_DEBUG_DISABLE_TEXTURING,
 | 
			
		||||
  COGL_DEBUG_DISABLE_GLSL,
 | 
			
		||||
  COGL_DEBUG_SHOW_SOURCE,
 | 
			
		||||
  COGL_DEBUG_DISABLE_BLENDING,
 | 
			
		||||
  COGL_DEBUG_TEXTURE_PIXMAP,
 | 
			
		||||
  COGL_DEBUG_BITMAP,
 | 
			
		||||
  COGL_DEBUG_DISABLE_NPOT_TEXTURES,
 | 
			
		||||
  COGL_DEBUG_WIREFRAME,
 | 
			
		||||
  COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
 | 
			
		||||
  COGL_DEBUG_DISABLE_PROGRAM_CACHES,
 | 
			
		||||
 
 | 
			
		||||
@@ -1992,15 +1992,6 @@ get_wire_line_indices (CoglContext *ctx,
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
remove_layer_cb (CoglPipeline *pipeline,
 | 
			
		||||
                 int layer_index,
 | 
			
		||||
                 void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  cogl_pipeline_remove_layer (pipeline, layer_index);
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
pipeline_destroyed_cb (CoglPipeline *weak_pipeline, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
@@ -2052,6 +2043,8 @@ draw_wireframe (CoglContext *ctx,
 | 
			
		||||
 | 
			
		||||
  if (!wire_pipeline)
 | 
			
		||||
    {
 | 
			
		||||
      static CoglSnippet *snippet = NULL;
 | 
			
		||||
 | 
			
		||||
      wire_pipeline =
 | 
			
		||||
        _cogl_pipeline_weak_copy (pipeline, pipeline_destroyed_cb, NULL);
 | 
			
		||||
 | 
			
		||||
@@ -2063,29 +2056,20 @@ draw_wireframe (CoglContext *ctx,
 | 
			
		||||
       * vertex program and since we'd like to see the results of the
 | 
			
		||||
       * vertex program in the wireframe we just add a final clobber
 | 
			
		||||
       * of the wire color leaving the rest of the state untouched. */
 | 
			
		||||
      if (cogl_has_feature (framebuffer->context, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
        {
 | 
			
		||||
          static CoglSnippet *snippet = NULL;
 | 
			
		||||
 | 
			
		||||
          /* The snippet is cached so that it will reuse the program
 | 
			
		||||
           * from the pipeline cache if possible */
 | 
			
		||||
          if (snippet == NULL)
 | 
			
		||||
            {
 | 
			
		||||
              snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
 | 
			
		||||
                                          NULL,
 | 
			
		||||
                                          NULL);
 | 
			
		||||
              cogl_snippet_set_replace (snippet,
 | 
			
		||||
                                        "cogl_color_out = "
 | 
			
		||||
                                        "vec4 (0.0, 1.0, 0.0, 1.0);\n");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          cogl_pipeline_add_snippet (wire_pipeline, snippet);
 | 
			
		||||
        }
 | 
			
		||||
      else
 | 
			
		||||
      /* The snippet is cached so that it will reuse the program
 | 
			
		||||
       * from the pipeline cache if possible */
 | 
			
		||||
      if (snippet == NULL)
 | 
			
		||||
        {
 | 
			
		||||
          cogl_pipeline_foreach_layer (wire_pipeline, remove_layer_cb, NULL);
 | 
			
		||||
          cogl_pipeline_set_color4f (wire_pipeline, 0, 1, 0, 1);
 | 
			
		||||
          snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
 | 
			
		||||
                                      NULL,
 | 
			
		||||
                                      NULL);
 | 
			
		||||
          cogl_snippet_set_replace (snippet,
 | 
			
		||||
                                    "cogl_color_out = "
 | 
			
		||||
                                    "vec4 (0.0, 1.0, 0.0, 1.0);\n");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      cogl_pipeline_add_snippet (wire_pipeline, snippet);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* temporarily disable the wireframe to avoid recursion! */
 | 
			
		||||
 
 | 
			
		||||
@@ -1129,8 +1129,8 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
 | 
			
		||||
 * are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api doesn't support any of the legacy global state options such
 | 
			
		||||
 * as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
 | 
			
		||||
@@ -1171,8 +1171,8 @@ cogl_framebuffer_draw_primitive (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
 | 
			
		||||
 * are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
@@ -1214,8 +1214,8 @@ cogl_framebuffer_vdraw_attributes (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
 | 
			
		||||
 * are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api doesn't support any of the legacy global state options such
 | 
			
		||||
 * as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
 | 
			
		||||
@@ -1280,8 +1280,8 @@ cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or
 | 
			
		||||
 * #CoglTexture3D are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api doesn't support any of the legacy global state
 | 
			
		||||
 * options such as cogl_set_depth_test_enabled(),
 | 
			
		||||
@@ -1348,8 +1348,8 @@ cogl_framebuffer_vdraw_indexed_attributes (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or
 | 
			
		||||
 * #CoglTexture3D are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api doesn't support any of the legacy global state
 | 
			
		||||
 * options such as cogl_set_depth_test_enabled(),
 | 
			
		||||
@@ -1443,11 +1443,6 @@ cogl_framebuffer_draw_rectangle (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * bottom right. To map an entire texture across the rectangle pass
 | 
			
		||||
 * in @s_1=0, @t_1=0, @s_2=1, @t_2=1.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Even if you have associated a #CoglTextureRectangle texture
 | 
			
		||||
 * with one of your @pipeline layers which normally implies working
 | 
			
		||||
 * with non-normalized texture coordinates this api should still be
 | 
			
		||||
 * passed normalized texture coordinates.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 */
 | 
			
		||||
@@ -1500,9 +1495,7 @@ cogl_framebuffer_draw_textured_rectangle (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * <note>This api can not currently handle multiple high-level meta
 | 
			
		||||
 * texture layers. The first layer may be a high level meta texture
 | 
			
		||||
 * such as #CoglTexture2DSliced but all other layers much be low
 | 
			
		||||
 * level textures such as #CoglTexture2D and additionally they
 | 
			
		||||
 * should be textures that can be sampled using normalized coordinates
 | 
			
		||||
 * (so not #CoglTextureRectangle textures).</note>
 | 
			
		||||
 * level textures such as #CoglTexture2D.
 | 
			
		||||
 *
 | 
			
		||||
 * The top left texture coordinate for layer 0 of any pipeline will be
 | 
			
		||||
 * (tex_coords[0], tex_coords[1]) and the bottom right coordinate will
 | 
			
		||||
@@ -1516,11 +1509,6 @@ cogl_framebuffer_draw_textured_rectangle (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * in tex_coords[0]=0, tex_coords[1]=0, tex_coords[2]=1,
 | 
			
		||||
 * tex_coords[3]=1.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Even if you have associated a #CoglTextureRectangle texture
 | 
			
		||||
 * which normally implies working with non-normalized texture
 | 
			
		||||
 * coordinates this api should still be passed normalized texture
 | 
			
		||||
 * coordinates.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * The first pair of coordinates are for the first layer (with the
 | 
			
		||||
 * smallest layer index) and if you supply less texture coordinates
 | 
			
		||||
 * than there are layers in the current source material then default
 | 
			
		||||
@@ -1624,11 +1612,6 @@ cogl_framebuffer_draw_rectangles (CoglFramebuffer *framebuffer,
 | 
			
		||||
 * in tex_coords[0]=0, tex_coords[1]=0, tex_coords[2]=1,
 | 
			
		||||
 * tex_coords[3]=1.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Even if you have associated a #CoglTextureRectangle texture
 | 
			
		||||
 * which normally implies working with non-normalized texture
 | 
			
		||||
 * coordinates this api should still be passed normalized texture
 | 
			
		||||
 * coordinates.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -366,9 +366,8 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
 | 
			
		||||
 * GLES2 context.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This function will only return %TRUE for low-level
 | 
			
		||||
 * #CoglTexture<!-- -->s such as #CoglTexture2D or #CoglTexture3D but
 | 
			
		||||
 * not for high level meta textures such as
 | 
			
		||||
 * #CoglTexture2DSliced</note>
 | 
			
		||||
 * #CoglTexture<!-- -->s such as #CoglTexture2D but not for high level
 | 
			
		||||
 * meta textures such as #CoglTexture2DSliced</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>The handle returned should not be passed directly to a system
 | 
			
		||||
 * OpenGL ES 2.0 library, the handle is only intended to be used via
 | 
			
		||||
 
 | 
			
		||||
@@ -100,21 +100,12 @@ _cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx,
 | 
			
		||||
  strings[count] = version_string;
 | 
			
		||||
  lengths[count++] = -1;
 | 
			
		||||
 | 
			
		||||
  if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED) &&
 | 
			
		||||
      cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    {
 | 
			
		||||
      static const char texture_3d_extension[] =
 | 
			
		||||
        "#extension GL_OES_texture_3D : enable\n";
 | 
			
		||||
      strings[count] = texture_3d_extension;
 | 
			
		||||
      lengths[count++] = sizeof (texture_3d_extension) - 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL))
 | 
			
		||||
    {
 | 
			
		||||
      static const char texture_3d_extension[] =
 | 
			
		||||
      static const char image_external_extension[] =
 | 
			
		||||
        "#extension GL_OES_EGL_image_external : require\n";
 | 
			
		||||
      strings[count] = texture_3d_extension;
 | 
			
		||||
      lengths[count++] = sizeof (texture_3d_extension) - 1;
 | 
			
		||||
      strings[count] = image_external_extension;
 | 
			
		||||
      lengths[count++] = sizeof (image_external_extension) - 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (shader_gl_type == GL_VERTEX_SHADER)
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@
 | 
			
		||||
#include "cogl-matrix.h"
 | 
			
		||||
#include "cogl-spans.h"
 | 
			
		||||
#include "cogl-meta-texture.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
@@ -316,16 +316,9 @@ foreach_clamped_region (CoglMetaTexture *meta_texture,
 | 
			
		||||
 | 
			
		||||
  if (wrap_s == COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE)
 | 
			
		||||
    {
 | 
			
		||||
      float max_s_coord;
 | 
			
		||||
      float max_s_coord = 1.0;
 | 
			
		||||
      float half_texel_width;
 | 
			
		||||
 | 
			
		||||
      /* Consider that rectangle textures have non-normalized
 | 
			
		||||
       * coordinates... */
 | 
			
		||||
      if (cogl_is_texture_rectangle (meta_texture))
 | 
			
		||||
        max_s_coord = width;
 | 
			
		||||
      else
 | 
			
		||||
        max_s_coord = 1.0;
 | 
			
		||||
 | 
			
		||||
      half_texel_width = max_s_coord / (width * 2);
 | 
			
		||||
 | 
			
		||||
      /* Handle any left clamped region */
 | 
			
		||||
@@ -375,16 +368,9 @@ foreach_clamped_region (CoglMetaTexture *meta_texture,
 | 
			
		||||
  if (wrap_t == COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE)
 | 
			
		||||
    {
 | 
			
		||||
      float height = cogl_texture_get_height (COGL_TEXTURE (meta_texture));
 | 
			
		||||
      float max_t_coord;
 | 
			
		||||
      float max_t_coord = 1.0;
 | 
			
		||||
      float half_texel_height;
 | 
			
		||||
 | 
			
		||||
      /* Consider that rectangle textures have non-normalized
 | 
			
		||||
       * coordinates... */
 | 
			
		||||
      if (cogl_is_texture_rectangle (meta_texture))
 | 
			
		||||
        max_t_coord = height;
 | 
			
		||||
      else
 | 
			
		||||
        max_t_coord = 1.0;
 | 
			
		||||
 | 
			
		||||
      half_texel_height = max_t_coord / (height * 2);
 | 
			
		||||
 | 
			
		||||
      /* Handle any top clamped region */
 | 
			
		||||
@@ -466,33 +452,6 @@ normalize_meta_coords_cb (CoglTexture *slice_texture,
 | 
			
		||||
                  data->user_data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef struct _UnNormalizeData
 | 
			
		||||
{
 | 
			
		||||
  CoglMetaTextureCallback callback;
 | 
			
		||||
  void *user_data;
 | 
			
		||||
  float width;
 | 
			
		||||
  float height;
 | 
			
		||||
} UnNormalizeData;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
un_normalize_slice_coords_cb (CoglTexture *slice_texture,
 | 
			
		||||
                              const float *slice_coords,
 | 
			
		||||
                              const float *meta_coords,
 | 
			
		||||
                              void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  UnNormalizeData *data = user_data;
 | 
			
		||||
  float un_normalized_slice_coords[4] = {
 | 
			
		||||
    slice_coords[0] * data->width,
 | 
			
		||||
    slice_coords[1] * data->height,
 | 
			
		||||
    slice_coords[2] * data->width,
 | 
			
		||||
    slice_coords[3] * data->height
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  data->callback (slice_texture,
 | 
			
		||||
                  un_normalized_slice_coords, meta_coords,
 | 
			
		||||
                  data->user_data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
 | 
			
		||||
                                     float tx_1,
 | 
			
		||||
@@ -539,19 +498,16 @@ cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
 | 
			
		||||
   * coordinates beyond this point and only re-normalize just before
 | 
			
		||||
   * calling the user's callback... */
 | 
			
		||||
 | 
			
		||||
  if (!cogl_is_texture_rectangle (COGL_TEXTURE (meta_texture)))
 | 
			
		||||
    {
 | 
			
		||||
      normalize_data.callback = callback;
 | 
			
		||||
      normalize_data.user_data = user_data;
 | 
			
		||||
      normalize_data.s_normalize_factor = 1.0f / width;
 | 
			
		||||
      normalize_data.t_normalize_factor = 1.0f / height;
 | 
			
		||||
      callback = normalize_meta_coords_cb;
 | 
			
		||||
      user_data = &normalize_data;
 | 
			
		||||
      tx_1 *= width;
 | 
			
		||||
      ty_1 *= height;
 | 
			
		||||
      tx_2 *= width;
 | 
			
		||||
      ty_2 *= height;
 | 
			
		||||
    }
 | 
			
		||||
  normalize_data.callback = callback;
 | 
			
		||||
  normalize_data.user_data = user_data;
 | 
			
		||||
  normalize_data.s_normalize_factor = 1.0f / width;
 | 
			
		||||
  normalize_data.t_normalize_factor = 1.0f / height;
 | 
			
		||||
  callback = normalize_meta_coords_cb;
 | 
			
		||||
  user_data = &normalize_data;
 | 
			
		||||
  tx_1 *= width;
 | 
			
		||||
  ty_1 *= height;
 | 
			
		||||
  tx_2 *= width;
 | 
			
		||||
  ty_2 *= height;
 | 
			
		||||
 | 
			
		||||
  /* XXX: at some point this wont be routed through the CoglTexture
 | 
			
		||||
   * vtable, instead there will be a separate CoglMetaTexture
 | 
			
		||||
@@ -609,21 +565,6 @@ cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
 | 
			
		||||
      CoglSpan x_span = { 0, width, 0 };
 | 
			
		||||
      CoglSpan y_span = { 0, height, 0 };
 | 
			
		||||
      float meta_region_coords[4] = { tx_1, ty_1, tx_2, ty_2 };
 | 
			
		||||
      UnNormalizeData un_normalize_data;
 | 
			
		||||
 | 
			
		||||
      /* If we are dealing with a CoglTextureRectangle then we need a shim
 | 
			
		||||
       * callback that un_normalizes the slice coordinates we get from
 | 
			
		||||
       * _cogl_texture_spans_foreach_in_region before passing them to
 | 
			
		||||
       * the user's callback. */
 | 
			
		||||
      if (cogl_is_texture_rectangle (meta_texture))
 | 
			
		||||
        {
 | 
			
		||||
          un_normalize_data.callback = callback;
 | 
			
		||||
          un_normalize_data.user_data = user_data;
 | 
			
		||||
          un_normalize_data.width = width;
 | 
			
		||||
          un_normalize_data.height = height;
 | 
			
		||||
          callback = un_normalize_slice_coords_cb;
 | 
			
		||||
          user_data = &un_normalize_data;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_spans_foreach_in_region (&x_span, 1,
 | 
			
		||||
                                             &y_span, 1,
 | 
			
		||||
 
 | 
			
		||||
@@ -42,8 +42,7 @@ G_BEGIN_DECLS
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:cogl-meta-texture
 | 
			
		||||
 * @short_description: Interface for high-level textures built from
 | 
			
		||||
 *                     low-level textures like #CoglTexture2D and
 | 
			
		||||
 *                     #CoglTexture3D.
 | 
			
		||||
 *                     low-level textures like #CoglTexture2D.
 | 
			
		||||
 *
 | 
			
		||||
 * Cogl helps to make it easy to deal with high level textures such
 | 
			
		||||
 * as #CoglAtlasTexture<!-- -->s, #CoglSubTexture<!-- -->s,
 | 
			
		||||
@@ -52,12 +51,11 @@ G_BEGIN_DECLS
 | 
			
		||||
 *
 | 
			
		||||
 * A #CoglMetaTexture is a texture that might internally be
 | 
			
		||||
 * represented by one or more low-level #CoglTexture<!-- -->s
 | 
			
		||||
 * such as #CoglTexture2D or #CoglTexture3D. These low-level textures
 | 
			
		||||
 * are the only ones that a GPU really understands but because
 | 
			
		||||
 * applications often want more high-level texture abstractions
 | 
			
		||||
 * (such as storing multiple textures inside one larger "atlas"
 | 
			
		||||
 * texture) it's desirable to be able to deal with these
 | 
			
		||||
 * using a common interface.
 | 
			
		||||
 * such as #CoglTexture2D. These low-level textures are the only ones
 | 
			
		||||
 * that a GPU really understands but because applications often want
 | 
			
		||||
 * more high-level texture abstractions (such as storing multiple
 | 
			
		||||
 * textures inside one larger "atlas" texture) it's desirable to be
 | 
			
		||||
 * able to deal with these using a common interface.
 | 
			
		||||
 *
 | 
			
		||||
 * For example the GPU is not able to automatically handle repeating a
 | 
			
		||||
 * texture that is part of a larger atlas texture but if you use
 | 
			
		||||
 
 | 
			
		||||
@@ -75,8 +75,8 @@ GType cogl_offscreen_get_gtype (void);
 | 
			
		||||
 * destroy the offscreen buffer before you can use the @texture again.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api only works with low-level #CoglTexture types such as
 | 
			
		||||
 * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
 | 
			
		||||
 * with meta-texture types such as #CoglTexture2DSliced.</note>
 | 
			
		||||
 * #CoglTexture2D and not with meta-texture types such as
 | 
			
		||||
 * #CoglTexture2DSliced.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * The storage for the framebuffer is actually allocated lazily
 | 
			
		||||
 * so this function will never return %NULL to indicate a runtime
 | 
			
		||||
@@ -110,8 +110,8 @@ cogl_offscreen_new_with_texture (CoglTexture *texture);
 | 
			
		||||
 * you can use the @texture again.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This only works with low-level #CoglTexture types such as
 | 
			
		||||
 * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
 | 
			
		||||
 * with meta-texture types such as #CoglTexture2DSliced.</note>
 | 
			
		||||
 * #CoglTexture2D and not with meta-texture types such as
 | 
			
		||||
 * #CoglTexture2DSliced.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): a newly instantiated #CoglOffscreen
 | 
			
		||||
 *   framebuffer or %NULL if it wasn't possible to create the
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,6 @@ typedef enum
 | 
			
		||||
{
 | 
			
		||||
  /* sparse state */
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_COMBINE_INDEX,
 | 
			
		||||
@@ -82,8 +81,6 @@ typedef enum
 | 
			
		||||
{
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_UNIT =
 | 
			
		||||
    1L<<COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE =
 | 
			
		||||
    1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA =
 | 
			
		||||
    1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
 | 
			
		||||
  COGL_PIPELINE_LAYER_STATE_SAMPLER =
 | 
			
		||||
@@ -237,11 +234,6 @@ struct _CoglPipelineLayer
 | 
			
		||||
  /* Each layer is directly associated with a single texture unit */
 | 
			
		||||
  int                        unit_index;
 | 
			
		||||
 | 
			
		||||
  /* The type of the texture. This is always set even if the texture
 | 
			
		||||
     is NULL and it will be used to determine what type of texture
 | 
			
		||||
     lookups to use in any shaders generated by the pipeline
 | 
			
		||||
     backends. */
 | 
			
		||||
  CoglTextureType            texture_type;
 | 
			
		||||
  /* The texture for this layer, or NULL for an empty
 | 
			
		||||
   * layer */
 | 
			
		||||
  CoglTexture               *texture;
 | 
			
		||||
@@ -347,9 +339,6 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
 | 
			
		||||
CoglTexture *
 | 
			
		||||
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
 | 
			
		||||
 | 
			
		||||
CoglTextureType
 | 
			
		||||
_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer);
 | 
			
		||||
 | 
			
		||||
CoglPipelineFilter
 | 
			
		||||
_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,11 +50,6 @@ CoglPipelineFilter
 | 
			
		||||
_cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
 | 
			
		||||
                                     int layer_index);
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
 | 
			
		||||
                                         CoglPipelineLayer *authority1,
 | 
			
		||||
                                         CoglPipelineEvalFlags flags);
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
 | 
			
		||||
                                         CoglPipelineLayer *authority1,
 | 
			
		||||
@@ -93,11 +88,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
 | 
			
		||||
                                      CoglPipelineLayer **authorities,
 | 
			
		||||
                                      CoglPipelineHashState *state);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
 | 
			
		||||
                                              CoglPipelineLayer **authorities,
 | 
			
		||||
                                              CoglPipelineHashState *state);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
 | 
			
		||||
                                              CoglPipelineLayer **authorities,
 | 
			
		||||
 
 | 
			
		||||
@@ -136,87 +136,6 @@ cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
 | 
			
		||||
  return _cogl_pipeline_layer_get_texture (layer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTextureType
 | 
			
		||||
_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineLayer *authority =
 | 
			
		||||
    _cogl_pipeline_layer_get_authority (layer,
 | 
			
		||||
                                        COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE);
 | 
			
		||||
 | 
			
		||||
  return authority->texture_type;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_pipeline_set_layer_texture_type (CoglPipeline *pipeline,
 | 
			
		||||
                                       int layer_index,
 | 
			
		||||
                                       CoglTextureType texture_type)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE;
 | 
			
		||||
  CoglPipelineLayer *layer;
 | 
			
		||||
  CoglPipelineLayer *authority;
 | 
			
		||||
  CoglPipelineLayer *new;
 | 
			
		||||
 | 
			
		||||
  /* Note: this will ensure that the layer exists, creating one if it
 | 
			
		||||
   * doesn't already.
 | 
			
		||||
   *
 | 
			
		||||
   * Note: If the layer already existed it's possibly owned by another
 | 
			
		||||
   * pipeline. If the layer is created then it will be owned by
 | 
			
		||||
   * pipeline. */
 | 
			
		||||
  layer = _cogl_pipeline_get_layer (pipeline, layer_index);
 | 
			
		||||
 | 
			
		||||
  /* Now find the ancestor of the layer that is the authority for the
 | 
			
		||||
   * state we want to change */
 | 
			
		||||
  authority = _cogl_pipeline_layer_get_authority (layer, change);
 | 
			
		||||
 | 
			
		||||
  if (texture_type == authority->texture_type)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change);
 | 
			
		||||
  if (new != layer)
 | 
			
		||||
    layer = new;
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      /* If the original layer we found is currently the authority on
 | 
			
		||||
       * the state we are changing see if we can revert to one of our
 | 
			
		||||
       * ancestors being the authority. */
 | 
			
		||||
      if (layer == authority &&
 | 
			
		||||
          _cogl_pipeline_layer_get_parent (authority) != NULL)
 | 
			
		||||
        {
 | 
			
		||||
          CoglPipelineLayer *parent =
 | 
			
		||||
            _cogl_pipeline_layer_get_parent (authority);
 | 
			
		||||
          CoglPipelineLayer *old_authority =
 | 
			
		||||
            _cogl_pipeline_layer_get_authority (parent, change);
 | 
			
		||||
 | 
			
		||||
          if (old_authority->texture_type == texture_type)
 | 
			
		||||
            {
 | 
			
		||||
              layer->differences &= ~change;
 | 
			
		||||
 | 
			
		||||
              g_assert (layer->owner == pipeline);
 | 
			
		||||
              if (layer->differences == 0)
 | 
			
		||||
                _cogl_pipeline_prune_empty_layer_difference (pipeline,
 | 
			
		||||
                                                             layer);
 | 
			
		||||
              goto changed;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  layer->texture_type = texture_type;
 | 
			
		||||
 | 
			
		||||
  /* If we weren't previously the authority on this state then we need
 | 
			
		||||
   * to extended our differences mask and so it's possible that some
 | 
			
		||||
   * of our ancestry will now become redundant, so we aim to reparent
 | 
			
		||||
   * ourselves if that's true... */
 | 
			
		||||
  if (layer != authority)
 | 
			
		||||
    {
 | 
			
		||||
      layer->differences |= change;
 | 
			
		||||
      _cogl_pipeline_layer_prune_redundant_ancestry (layer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
changed:
 | 
			
		||||
 | 
			
		||||
  pipeline->dirty_real_blend_enable = TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
 | 
			
		||||
                                       int layer_index,
 | 
			
		||||
@@ -301,69 +220,13 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
 | 
			
		||||
                                 int layer_index,
 | 
			
		||||
                                 CoglTexture *texture)
 | 
			
		||||
{
 | 
			
		||||
  /* For the convenience of fragend code we separate texture state
 | 
			
		||||
   * into the "type" and the "data", and setting a layer texture
 | 
			
		||||
   * updates both of these properties.
 | 
			
		||||
   *
 | 
			
		||||
   * One example for why this is helpful is that the fragends may
 | 
			
		||||
   * cache programs they generate and want to re-use those programs
 | 
			
		||||
   * with all pipelines having equivalent fragment processing state.
 | 
			
		||||
   * For the sake of determining if pipelines have equivalent fragment
 | 
			
		||||
   * processing state we don't need to compare that the same
 | 
			
		||||
   * underlying texture objects are referenced by the pipelines but we
 | 
			
		||||
   * do need to see if they use the same texture types. Making this
 | 
			
		||||
   * distinction is much simpler if they are in different state
 | 
			
		||||
   * groups.
 | 
			
		||||
   *
 | 
			
		||||
   * Note: if a NULL texture is set then we leave the type unchanged
 | 
			
		||||
   * so we can avoid needlessly invalidating any associated fragment
 | 
			
		||||
   * program.
 | 
			
		||||
   */
 | 
			
		||||
  if (texture)
 | 
			
		||||
    {
 | 
			
		||||
      CoglTextureType texture_type =
 | 
			
		||||
        _cogl_texture_get_type (texture);
 | 
			
		||||
      _cogl_pipeline_set_layer_texture_type (pipeline,
 | 
			
		||||
                                             layer_index,
 | 
			
		||||
                                             texture_type);
 | 
			
		||||
    }
 | 
			
		||||
  _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, texture);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
 | 
			
		||||
                                      int layer_index,
 | 
			
		||||
                                      CoglTextureType texture_type)
 | 
			
		||||
                                      int layer_index)
 | 
			
		||||
{
 | 
			
		||||
  CoglContext *ctx = _cogl_context_get_default ();
 | 
			
		||||
 | 
			
		||||
  /* Disallow setting texture types that aren't supported */
 | 
			
		||||
  switch (texture_type)
 | 
			
		||||
    {
 | 
			
		||||
    case COGL_TEXTURE_TYPE_2D:
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_3D:
 | 
			
		||||
      if (ctx->default_gl_texture_3d_tex == NULL)
 | 
			
		||||
        {
 | 
			
		||||
          g_warning ("The default 3D texture was set on a pipeline but "
 | 
			
		||||
                     "3D textures are not supported");
 | 
			
		||||
          texture_type = COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_RECTANGLE:
 | 
			
		||||
      if (ctx->default_gl_texture_rect_tex == NULL)
 | 
			
		||||
        {
 | 
			
		||||
          g_warning ("The default rectangle texture was set on a pipeline but "
 | 
			
		||||
                     "rectangle textures are not supported");
 | 
			
		||||
          texture_type = COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
        }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  _cogl_pipeline_set_layer_texture_type (pipeline, layer_index, texture_type);
 | 
			
		||||
  _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -950,14 +813,6 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
 | 
			
		||||
                                               snippet);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
 | 
			
		||||
                                         CoglPipelineLayer *authority1,
 | 
			
		||||
                                         CoglPipelineEvalFlags flags)
 | 
			
		||||
{
 | 
			
		||||
  return authority0->texture_type == authority1->texture_type;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
 | 
			
		||||
                                         CoglPipelineLayer *authority1,
 | 
			
		||||
@@ -966,8 +821,7 @@ _cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
 | 
			
		||||
  if (authority0->texture == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      if (authority1->texture == NULL)
 | 
			
		||||
        return (_cogl_pipeline_layer_get_texture_type (authority0) ==
 | 
			
		||||
                _cogl_pipeline_layer_get_texture_type (authority1));
 | 
			
		||||
        return TRUE;
 | 
			
		||||
      else
 | 
			
		||||
        return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
@@ -1647,18 +1501,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
 | 
			
		||||
    _cogl_util_one_at_a_time_hash (state->hash, &unit, sizeof (unit));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
 | 
			
		||||
                                              CoglPipelineLayer **authorities,
 | 
			
		||||
                                              CoglPipelineHashState *state)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureType texture_type = authority->texture_type;
 | 
			
		||||
 | 
			
		||||
  state->hash = _cogl_util_one_at_a_time_hash (state->hash,
 | 
			
		||||
                                               &texture_type,
 | 
			
		||||
                                               sizeof (texture_type));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
 | 
			
		||||
                                              CoglPipelineLayer **authorities,
 | 
			
		||||
 
 | 
			
		||||
@@ -159,13 +159,9 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
 | 
			
		||||
 * cogl_pipeline_set_layer_null_texture:
 | 
			
		||||
 * @pipeline: A #CoglPipeline
 | 
			
		||||
 * @layer_index: The layer number to modify
 | 
			
		||||
 * @texture_type: The type of the default texture to use
 | 
			
		||||
 *
 | 
			
		||||
 * Sets the texture for this layer to be the default texture for the
 | 
			
		||||
 * given type. This is equivalent to calling
 | 
			
		||||
 * cogl_pipeline_set_layer_texture() with %NULL for the texture
 | 
			
		||||
 * argument except that you can also specify the type of default
 | 
			
		||||
 * texture to use. The default texture is a 1x1 pixel white texture.
 | 
			
		||||
 * given type. The default texture is a 1x1 pixel white texture.
 | 
			
		||||
 *
 | 
			
		||||
 * This function is mostly useful if you want to create a base
 | 
			
		||||
 * pipeline that you want to create multiple copies from using
 | 
			
		||||
@@ -178,8 +174,7 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
 | 
			
		||||
                                      int layer_index,
 | 
			
		||||
                                      CoglTextureType texture_type);
 | 
			
		||||
                                      int layer_index);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_pipeline_get_layer_texture:
 | 
			
		||||
 
 | 
			
		||||
@@ -187,10 +187,6 @@ _cogl_pipeline_layer_copy_differences (CoglPipelineLayer *dest,
 | 
			
		||||
          g_warn_if_reached ();
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX:
 | 
			
		||||
          dest->texture_type = src->texture_type;
 | 
			
		||||
          break;
 | 
			
		||||
 | 
			
		||||
        case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX:
 | 
			
		||||
          dest->texture = src->texture;
 | 
			
		||||
          if (dest->texture)
 | 
			
		||||
@@ -272,7 +268,6 @@ _cogl_pipeline_layer_init_multi_property_sparse_state (
 | 
			
		||||
    /* XXX: avoid using a default: label so we get a warning if we
 | 
			
		||||
     * don't explicitly handle a newly defined state-group here. */
 | 
			
		||||
    case COGL_PIPELINE_LAYER_STATE_UNIT:
 | 
			
		||||
    case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE:
 | 
			
		||||
    case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA:
 | 
			
		||||
    case COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS:
 | 
			
		||||
    case COGL_PIPELINE_LAYER_STATE_USER_MATRIX:
 | 
			
		||||
@@ -662,16 +657,6 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
 | 
			
		||||
                                            layers_difference,
 | 
			
		||||
                                            authorities1);
 | 
			
		||||
 | 
			
		||||
  if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE)
 | 
			
		||||
    {
 | 
			
		||||
      CoglPipelineLayerStateIndex state_index =
 | 
			
		||||
        COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX;
 | 
			
		||||
      if (!_cogl_pipeline_layer_texture_type_equal (authorities0[state_index],
 | 
			
		||||
                                                    authorities1[state_index],
 | 
			
		||||
                                                    flags))
 | 
			
		||||
        return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA)
 | 
			
		||||
    {
 | 
			
		||||
      CoglPipelineLayerStateIndex state_index =
 | 
			
		||||
@@ -767,7 +752,6 @@ _cogl_pipeline_init_default_layers (void)
 | 
			
		||||
  layer->unit_index = 0;
 | 
			
		||||
 | 
			
		||||
  layer->texture = NULL;
 | 
			
		||||
  layer->texture_type = COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
 | 
			
		||||
  layer->sampler_cache_entry =
 | 
			
		||||
    _cogl_sampler_cache_get_default_entry (ctx->sampler_cache);
 | 
			
		||||
 
 | 
			
		||||
@@ -626,10 +626,6 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline);
 | 
			
		||||
 * meantime we hope this will handle most practical GLSL and ARBfp
 | 
			
		||||
 * requirements.
 | 
			
		||||
 *
 | 
			
		||||
 * Also remember you need to check for either the
 | 
			
		||||
 * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
 | 
			
		||||
 * using the cogl_program or cogl_shader API.
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 2.0
 | 
			
		||||
 * Stability: Unstable
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -1904,7 +1904,6 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineFallbackState *state = user_data;
 | 
			
		||||
  CoglPipeline *pipeline = state->pipeline;
 | 
			
		||||
  CoglTextureType texture_type = _cogl_pipeline_layer_get_texture_type (layer);
 | 
			
		||||
  CoglTexture *texture = NULL;
 | 
			
		||||
  COGL_STATIC_COUNTER (layer_fallback_counter,
 | 
			
		||||
                       "layer fallback counter",
 | 
			
		||||
@@ -1919,20 +1918,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
 | 
			
		||||
 | 
			
		||||
  COGL_COUNTER_INC (_cogl_uprof_context, layer_fallback_counter);
 | 
			
		||||
 | 
			
		||||
  switch (texture_type)
 | 
			
		||||
    {
 | 
			
		||||
    case COGL_TEXTURE_TYPE_2D:
 | 
			
		||||
      texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_3D:
 | 
			
		||||
      texture = COGL_TEXTURE (ctx->default_gl_texture_3d_tex);
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_RECTANGLE:
 | 
			
		||||
      texture = COGL_TEXTURE (ctx->default_gl_texture_rect_tex);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
 | 
			
		||||
 | 
			
		||||
  if (texture == NULL)
 | 
			
		||||
    {
 | 
			
		||||
@@ -2625,8 +2611,6 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
 | 
			
		||||
  CoglPipelineLayerStateIndex _index;
 | 
			
		||||
  layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_UNIT_INDEX] =
 | 
			
		||||
    _cogl_pipeline_layer_hash_unit_state;
 | 
			
		||||
  layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX] =
 | 
			
		||||
    _cogl_pipeline_layer_hash_texture_type_state;
 | 
			
		||||
  layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX] =
 | 
			
		||||
    _cogl_pipeline_layer_hash_texture_data_state;
 | 
			
		||||
  layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX] =
 | 
			
		||||
@@ -2649,7 +2633,7 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
  /* So we get a big error if we forget to update this code! */
 | 
			
		||||
  _COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 10,
 | 
			
		||||
  _COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 9,
 | 
			
		||||
                       "Don't forget to install a hash function for new "
 | 
			
		||||
                       "pipeline state and update assert at end of "
 | 
			
		||||
                       "_cogl_pipeline_init_state_hash_functions");
 | 
			
		||||
@@ -3054,15 +3038,13 @@ _cogl_pipeline_get_layer_state_for_fragment_codegen (CoglContext *context)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineLayerState state =
 | 
			
		||||
    (COGL_PIPELINE_LAYER_STATE_COMBINE |
 | 
			
		||||
     COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE |
 | 
			
		||||
     COGL_PIPELINE_LAYER_STATE_UNIT |
 | 
			
		||||
     COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS);
 | 
			
		||||
 | 
			
		||||
  /* If the driver supports GLSL then we might be using gl_PointCoord
 | 
			
		||||
  /* Since the driver supports GLSL then we might be using gl_PointCoord
 | 
			
		||||
   * to implement the sprite coords. In that case the generated code
 | 
			
		||||
   * depends on the point sprite state */
 | 
			
		||||
  if (cogl_has_feature (context, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
    state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
 | 
			
		||||
  state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
 | 
			
		||||
 | 
			
		||||
  return state;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,14 +42,13 @@ G_BEGIN_DECLS
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:cogl-primitive-texture
 | 
			
		||||
 * @short_description: Interface for low-level textures like
 | 
			
		||||
 *                     #CoglTexture2D and #CoglTexture3D.
 | 
			
		||||
 *                     #CoglTexture2D.
 | 
			
		||||
 *
 | 
			
		||||
 * A #CoglPrimitiveTexture is a texture that is directly represented
 | 
			
		||||
 * by a single texture on the GPU. For example these could be a
 | 
			
		||||
 * #CoglTexture2D, #CoglTexture3D or #CoglTextureRectangle. This is
 | 
			
		||||
 * opposed to high level meta textures which may be composed of
 | 
			
		||||
 * multiple primitive textures or a sub-region of another texture such
 | 
			
		||||
 * as #CoglAtlasTexture and #CoglTexture2DSliced.
 | 
			
		||||
 * by a single texture on the GPU. For example this could be a
 | 
			
		||||
 * #CoglTexture2D. This is opposed to high level meta textures which
 | 
			
		||||
 * may be composed of multiple primitive textures or a sub-region of
 | 
			
		||||
 * another texture such as #CoglAtlasTexture and #CoglTexture2DSliced.
 | 
			
		||||
 *
 | 
			
		||||
 * A texture that implements this interface can be directly used with
 | 
			
		||||
 * the low level cogl_primitive_draw() API. Other types of textures
 | 
			
		||||
 
 | 
			
		||||
@@ -926,8 +926,8 @@ cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
 | 
			
		||||
 * This drawing api doesn't support high-level meta texture types such
 | 
			
		||||
 * as #CoglTexture2DSliced so it is the user's responsibility to
 | 
			
		||||
 * ensure that only low-level textures that can be directly sampled by
 | 
			
		||||
 * a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
 | 
			
		||||
 * are associated with layers of the given @pipeline.
 | 
			
		||||
 * a GPU such as #CoglTexture2D are associated with layers of the given
 | 
			
		||||
 * @pipeline.
 | 
			
		||||
 *
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 * Since: 1.16
 | 
			
		||||
 
 | 
			
		||||
@@ -187,8 +187,6 @@ validate_first_layer_cb (CoglPipeline *pipeline,
 | 
			
		||||
 *   texture coordinates require repeating,
 | 
			
		||||
 * - CoglTexture2DAtlas: if the users given texture coordinates require
 | 
			
		||||
 *   repeating,
 | 
			
		||||
 * - CoglTextureRectangle: if the users given texture coordinates require
 | 
			
		||||
 *   repeating,
 | 
			
		||||
 * - CoglTexturePixmap: if the users given texture coordinates require
 | 
			
		||||
 *   repeating
 | 
			
		||||
 */
 | 
			
		||||
@@ -427,11 +425,9 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
 | 
			
		||||
 * - CoglTexture2DSliced: if only comprised of a single slice with optional
 | 
			
		||||
 *   waste, assuming the users given texture coordinates don't require
 | 
			
		||||
 *   repeating.
 | 
			
		||||
 * - CoglTexture{1D,2D,3D}: always.
 | 
			
		||||
 * - CoglTexture{1D,2D}: always.
 | 
			
		||||
 * - CoglTexture2DAtlas: assuming the users given texture coordinates don't
 | 
			
		||||
 *   require repeating.
 | 
			
		||||
 * - CoglTextureRectangle: assuming the users given texture coordinates don't
 | 
			
		||||
 *   require repeating.
 | 
			
		||||
 * - CoglTexturePixmap: assuming the users given texture coordinates don't
 | 
			
		||||
 *   require repeating.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -784,8 +784,7 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer)
 | 
			
		||||
  _COGL_GET_CONTEXT (ctx, 0);
 | 
			
		||||
 | 
			
		||||
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2)
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
    GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
 | 
			
		||||
  GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  return n;
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,6 @@
 | 
			
		||||
#include "cogl-context-private.h"
 | 
			
		||||
#include "cogl-object.h"
 | 
			
		||||
#include "cogl-texture-driver.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-texture-2d.h"
 | 
			
		||||
#include "cogl-gtype-private.h"
 | 
			
		||||
#include "driver/gl/cogl-texture-gl-private.h"
 | 
			
		||||
@@ -60,30 +59,13 @@ _cogl_sub_texture_unmap_quad (CoglSubTexture *sub_tex,
 | 
			
		||||
                              float *coords)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (sub_tex);
 | 
			
		||||
  float width = cogl_texture_get_width (sub_tex->full_texture);
 | 
			
		||||
  float height = cogl_texture_get_height (sub_tex->full_texture);
 | 
			
		||||
 | 
			
		||||
  /* NB: coords[] come in as non-normalized if sub_tex->full_texture
 | 
			
		||||
   * is a CoglTextureRectangle otherwhise they are normalized. The
 | 
			
		||||
   * coordinates we write out though must always be normalized.
 | 
			
		||||
   *
 | 
			
		||||
   * NB: sub_tex->sub_x/y/width/height are in non-normalized
 | 
			
		||||
   * coordinates.
 | 
			
		||||
   */
 | 
			
		||||
  if (cogl_is_texture_rectangle (sub_tex->full_texture))
 | 
			
		||||
    {
 | 
			
		||||
      coords[0] = (coords[0] - sub_tex->sub_x) / tex->width;
 | 
			
		||||
      coords[1] = (coords[1] - sub_tex->sub_y) / tex->height;
 | 
			
		||||
      coords[2] = (coords[2] - sub_tex->sub_x) / tex->width;
 | 
			
		||||
      coords[3] = (coords[3] - sub_tex->sub_y) / tex->height;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      float width = cogl_texture_get_width (sub_tex->full_texture);
 | 
			
		||||
      float height = cogl_texture_get_height (sub_tex->full_texture);
 | 
			
		||||
      coords[0] = (coords[0] * width - sub_tex->sub_x) / tex->width;
 | 
			
		||||
      coords[1] = (coords[1] * height - sub_tex->sub_y) / tex->height;
 | 
			
		||||
      coords[2] = (coords[2] * width - sub_tex->sub_x) / tex->width;
 | 
			
		||||
      coords[3] = (coords[3] * height - sub_tex->sub_y) / tex->height;
 | 
			
		||||
    }
 | 
			
		||||
  coords[0] = (coords[0] * width - sub_tex->sub_x) / tex->width;
 | 
			
		||||
  coords[1] = (coords[1] * height - sub_tex->sub_y) / tex->height;
 | 
			
		||||
  coords[2] = (coords[2] * width - sub_tex->sub_x) / tex->width;
 | 
			
		||||
  coords[3] = (coords[3] * height - sub_tex->sub_y) / tex->height;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -91,31 +73,13 @@ _cogl_sub_texture_map_quad (CoglSubTexture *sub_tex,
 | 
			
		||||
                            float *coords)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (sub_tex);
 | 
			
		||||
  float width = cogl_texture_get_width (sub_tex->full_texture);
 | 
			
		||||
  float height = cogl_texture_get_height (sub_tex->full_texture);
 | 
			
		||||
 | 
			
		||||
  /* NB: coords[] always come in as normalized coordinates but may go
 | 
			
		||||
   * out as non-normalized if sub_tex->full_texture is a
 | 
			
		||||
   * CoglTextureRectangle.
 | 
			
		||||
   *
 | 
			
		||||
   * NB: sub_tex->sub_x/y/width/height are in non-normalized
 | 
			
		||||
   * coordinates.
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  if (cogl_is_texture_rectangle (sub_tex->full_texture))
 | 
			
		||||
    {
 | 
			
		||||
      coords[0] = coords[0] * tex->width + sub_tex->sub_x;
 | 
			
		||||
      coords[1] = coords[1] * tex->height + sub_tex->sub_y;
 | 
			
		||||
      coords[2] = coords[2] * tex->width + sub_tex->sub_x;
 | 
			
		||||
      coords[3] = coords[3] * tex->height + sub_tex->sub_y;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      float width = cogl_texture_get_width (sub_tex->full_texture);
 | 
			
		||||
      float height = cogl_texture_get_height (sub_tex->full_texture);
 | 
			
		||||
      coords[0] = (coords[0] * tex->width + sub_tex->sub_x) / width;
 | 
			
		||||
      coords[1] = (coords[1] * tex->height + sub_tex->sub_y) / height;
 | 
			
		||||
      coords[2] = (coords[2] * tex->width + sub_tex->sub_x) / width;
 | 
			
		||||
      coords[3] = (coords[3] * tex->height + sub_tex->sub_y) / height;
 | 
			
		||||
    }
 | 
			
		||||
  coords[0] = (coords[0] * tex->width + sub_tex->sub_x) / width;
 | 
			
		||||
  coords[1] = (coords[1] * tex->height + sub_tex->sub_y) / height;
 | 
			
		||||
  coords[2] = (coords[2] * tex->width + sub_tex->sub_x) / width;
 | 
			
		||||
  coords[3] = (coords[3] * tex->height + sub_tex->sub_y) / height;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef struct _CoglSubTextureForeachData
 | 
			
		||||
@@ -165,8 +129,7 @@ _cogl_sub_texture_foreach_sub_texture_in_region (
 | 
			
		||||
  _cogl_sub_texture_map_quad (sub_tex, mapped_coords);
 | 
			
		||||
 | 
			
		||||
  /* TODO: Add something like cogl_is_low_level_texture() */
 | 
			
		||||
  if (cogl_is_texture_2d (full_texture) ||
 | 
			
		||||
      cogl_is_texture_rectangle (full_texture))
 | 
			
		||||
  if (cogl_is_texture_2d (full_texture))
 | 
			
		||||
    {
 | 
			
		||||
      callback (sub_tex->full_texture,
 | 
			
		||||
                mapped_coords,
 | 
			
		||||
@@ -452,14 +415,6 @@ _cogl_sub_texture_get_gl_format (CoglTexture *tex)
 | 
			
		||||
  return _cogl_texture_gl_get_format (sub_tex->full_texture);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_sub_texture_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_get_type (sub_tex->full_texture);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_sub_texture_vtable =
 | 
			
		||||
  {
 | 
			
		||||
@@ -481,7 +436,6 @@ cogl_sub_texture_vtable =
 | 
			
		||||
    _cogl_sub_texture_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_sub_texture_get_format,
 | 
			
		||||
    _cogl_sub_texture_get_gl_format,
 | 
			
		||||
    _cogl_sub_texture_get_type,
 | 
			
		||||
    NULL, /* is_foreign */
 | 
			
		||||
    NULL /* set_auto_mipmap */
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -585,65 +585,6 @@ _cogl_rect_slices_for_size (int     size_to_fill,
 | 
			
		||||
  return n_spans;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
_cogl_pot_slices_for_size (int    size_to_fill,
 | 
			
		||||
                           int    max_span_size,
 | 
			
		||||
                           int    max_waste,
 | 
			
		||||
                           GArray *out_spans)
 | 
			
		||||
{
 | 
			
		||||
  int      n_spans = 0;
 | 
			
		||||
  CoglSpan span;
 | 
			
		||||
 | 
			
		||||
  /* Init first slice span */
 | 
			
		||||
  span.start = 0;
 | 
			
		||||
  span.size = max_span_size;
 | 
			
		||||
  span.waste = 0;
 | 
			
		||||
 | 
			
		||||
  /* Fix invalid max_waste */
 | 
			
		||||
  if (max_waste < 0)
 | 
			
		||||
    max_waste = 0;
 | 
			
		||||
 | 
			
		||||
  while (TRUE)
 | 
			
		||||
    {
 | 
			
		||||
      /* Is the whole area covered? */
 | 
			
		||||
      if (size_to_fill > span.size)
 | 
			
		||||
        {
 | 
			
		||||
          /* Not yet - add a span of this size */
 | 
			
		||||
          if (out_spans)
 | 
			
		||||
            g_array_append_val (out_spans, span);
 | 
			
		||||
 | 
			
		||||
          span.start   += span.size;
 | 
			
		||||
          size_to_fill -= span.size;
 | 
			
		||||
          n_spans++;
 | 
			
		||||
        }
 | 
			
		||||
      else if (span.size - size_to_fill <= max_waste)
 | 
			
		||||
        {
 | 
			
		||||
          /* Yes and waste is small enough */
 | 
			
		||||
          /* Pick the next power of two up from size_to_fill. This can
 | 
			
		||||
             sometimes be less than the span.size that would be chosen
 | 
			
		||||
             otherwise */
 | 
			
		||||
          span.size = _cogl_util_next_p2 (size_to_fill);
 | 
			
		||||
          span.waste = span.size - size_to_fill;
 | 
			
		||||
          if (out_spans)
 | 
			
		||||
            g_array_append_val (out_spans, span);
 | 
			
		||||
 | 
			
		||||
          return ++n_spans;
 | 
			
		||||
        }
 | 
			
		||||
      else
 | 
			
		||||
        {
 | 
			
		||||
          /* Yes but waste is too large */
 | 
			
		||||
          while (span.size - size_to_fill > max_waste)
 | 
			
		||||
            {
 | 
			
		||||
              span.size /= 2;
 | 
			
		||||
              g_assert (span.size > 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Can't get here */
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
 | 
			
		||||
                                                           GLenum wrap_mode_s,
 | 
			
		||||
@@ -700,18 +641,9 @@ setup_spans (CoglContext *ctx,
 | 
			
		||||
  int   (*slices_for_size) (int, int, int, GArray*);
 | 
			
		||||
 | 
			
		||||
  /* Initialize size of largest slice according to supported features */
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
 | 
			
		||||
    {
 | 
			
		||||
      max_width = width;
 | 
			
		||||
      max_height = height;
 | 
			
		||||
      slices_for_size = _cogl_rect_slices_for_size;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      max_width = _cogl_util_next_p2 (width);
 | 
			
		||||
      max_height = _cogl_util_next_p2 (height);
 | 
			
		||||
      slices_for_size = _cogl_pot_slices_for_size;
 | 
			
		||||
    }
 | 
			
		||||
  max_width = width;
 | 
			
		||||
  max_height = height;
 | 
			
		||||
  slices_for_size = _cogl_rect_slices_for_size;
 | 
			
		||||
 | 
			
		||||
  /* Negative number means no slicing forced by the user */
 | 
			
		||||
  if (max_waste <= -1)
 | 
			
		||||
@@ -999,9 +931,7 @@ _cogl_texture_2d_sliced_new_from_foreign (CoglContext *ctx,
 | 
			
		||||
   * in GLES, hence such a function prototype.
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  /* This should only be called when the texture target is 2D. If a
 | 
			
		||||
     rectangle texture is used then _cogl_texture_new_from_foreign
 | 
			
		||||
     will create a cogl_texture_rectangle instead */
 | 
			
		||||
  /* This should only be called when the texture target is 2D. */
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (gl_target == GL_TEXTURE_2D, NULL);
 | 
			
		||||
 | 
			
		||||
  /* Assert it is a valid GL texture object */
 | 
			
		||||
@@ -1512,12 +1442,6 @@ _cogl_texture_2d_sliced_get_gl_format (CoglTexture *tex)
 | 
			
		||||
  return _cogl_texture_gl_get_format (COGL_TEXTURE (slice_tex));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_texture_2d_sliced_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_texture_2d_sliced_vtable =
 | 
			
		||||
  {
 | 
			
		||||
@@ -1539,7 +1463,6 @@ cogl_texture_2d_sliced_vtable =
 | 
			
		||||
    _cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_texture_2d_sliced_get_format,
 | 
			
		||||
    _cogl_texture_2d_sliced_get_gl_format,
 | 
			
		||||
    _cogl_texture_2d_sliced_get_type,
 | 
			
		||||
    _cogl_texture_2d_sliced_is_foreign,
 | 
			
		||||
    NULL /* set_auto_mipmap */
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -505,14 +505,7 @@ _cogl_texture_2d_is_sliced (CoglTexture *tex)
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_2d_can_hardware_repeat (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT) ||
 | 
			
		||||
      (_cogl_util_is_pot (tex->width) &&
 | 
			
		||||
       _cogl_util_is_pot (tex->height)))
 | 
			
		||||
    return TRUE;
 | 
			
		||||
  else
 | 
			
		||||
    return FALSE;
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
@@ -674,12 +667,6 @@ _cogl_texture_2d_is_foreign (CoglTexture *tex)
 | 
			
		||||
  return COGL_TEXTURE_2D (tex)->is_foreign;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_texture_2d_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_TYPE_2D;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_texture_2d_vtable =
 | 
			
		||||
  {
 | 
			
		||||
@@ -701,7 +688,6 @@ cogl_texture_2d_vtable =
 | 
			
		||||
    _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_texture_2d_get_format,
 | 
			
		||||
    _cogl_texture_2d_get_gl_format,
 | 
			
		||||
    _cogl_texture_2d_get_type,
 | 
			
		||||
    _cogl_texture_2d_is_foreign,
 | 
			
		||||
    _cogl_texture_2d_set_auto_mipmap
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2010 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *   Neil Roberts <neil@linux.intel.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __COGL_TEXTURE_3D_PRIVATE_H
 | 
			
		||||
#define __COGL_TEXTURE_3D_PRIVATE_H
 | 
			
		||||
 | 
			
		||||
#include "cogl-object-private.h"
 | 
			
		||||
#include "cogl-pipeline-private.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
#include "cogl-texture-3d.h"
 | 
			
		||||
 | 
			
		||||
struct _CoglTexture3D
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture _parent;
 | 
			
		||||
 | 
			
		||||
  /* The internal format of the texture represented as a
 | 
			
		||||
     CoglPixelFormat */
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
  int depth;
 | 
			
		||||
  gboolean auto_mipmap;
 | 
			
		||||
  gboolean mipmaps_dirty;
 | 
			
		||||
 | 
			
		||||
  /* TODO: factor out these OpenGL specific members into some form
 | 
			
		||||
   * of driver private state. */
 | 
			
		||||
 | 
			
		||||
  /* The internal format of the GL texture represented as a GL enum */
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  /* The texture object number */
 | 
			
		||||
  GLuint gl_texture;
 | 
			
		||||
  GLenum gl_legacy_texobj_min_filter;
 | 
			
		||||
  GLenum gl_legacy_texobj_mag_filter;
 | 
			
		||||
  GLint gl_legacy_texobj_wrap_mode_s;
 | 
			
		||||
  GLint gl_legacy_texobj_wrap_mode_t;
 | 
			
		||||
  GLint gl_legacy_texobj_wrap_mode_p;
 | 
			
		||||
  CoglTexturePixel first_pixel;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* __COGL_TEXTURE_3D_PRIVATE_H */
 | 
			
		||||
@@ -1,758 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2010 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *  Neil Roberts   <neil@linux.intel.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cogl-config.h"
 | 
			
		||||
 | 
			
		||||
#include "cogl-private.h"
 | 
			
		||||
#include "cogl-util.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
#include "cogl-texture-3d-private.h"
 | 
			
		||||
#include "cogl-texture-3d.h"
 | 
			
		||||
#include "cogl-texture-driver.h"
 | 
			
		||||
#include "cogl-context-private.h"
 | 
			
		||||
#include "cogl-object-private.h"
 | 
			
		||||
#include "cogl-journal-private.h"
 | 
			
		||||
#include "cogl-pipeline-private.h"
 | 
			
		||||
#include "cogl-error-private.h"
 | 
			
		||||
#include "cogl-gtype-private.h"
 | 
			
		||||
#include "driver/gl/cogl-texture-gl-private.h"
 | 
			
		||||
#include "driver/gl/cogl-pipeline-opengl-private.h"
 | 
			
		||||
#include "driver/gl/cogl-util-gl-private.h"
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
/* These might not be defined on GLES */
 | 
			
		||||
#ifndef GL_TEXTURE_3D
 | 
			
		||||
#define GL_TEXTURE_3D                           0x806F
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_TEXTURE_WRAP_R
 | 
			
		||||
#define GL_TEXTURE_WRAP_R                       0x8072
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
 | 
			
		||||
 | 
			
		||||
COGL_TEXTURE_DEFINE (Texture3D, texture_3d);
 | 
			
		||||
COGL_GTYPE_DEFINE_CLASS (Texture3D, texture_3d,
 | 
			
		||||
                         COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable cogl_texture_3d_vtable;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
 | 
			
		||||
                                                    GLenum wrap_mode_s,
 | 
			
		||||
                                                    GLenum wrap_mode_t,
 | 
			
		||||
                                                    GLenum wrap_mode_p)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  /* Only set the wrap mode if it's different from the current value
 | 
			
		||||
     to avoid too many GL calls. */
 | 
			
		||||
  if (tex_3d->gl_legacy_texobj_wrap_mode_s != wrap_mode_s ||
 | 
			
		||||
      tex_3d->gl_legacy_texobj_wrap_mode_t != wrap_mode_t ||
 | 
			
		||||
      tex_3d->gl_legacy_texobj_wrap_mode_p != wrap_mode_p)
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
 | 
			
		||||
                                       tex_3d->gl_texture,
 | 
			
		||||
                                       FALSE);
 | 
			
		||||
      GE( ctx, glTexParameteri (GL_TEXTURE_3D,
 | 
			
		||||
                                GL_TEXTURE_WRAP_S,
 | 
			
		||||
                                wrap_mode_s) );
 | 
			
		||||
      GE( ctx, glTexParameteri (GL_TEXTURE_3D,
 | 
			
		||||
                                GL_TEXTURE_WRAP_T,
 | 
			
		||||
                                wrap_mode_t) );
 | 
			
		||||
      GE( ctx, glTexParameteri (GL_TEXTURE_3D,
 | 
			
		||||
                                GL_TEXTURE_WRAP_R,
 | 
			
		||||
                                wrap_mode_p) );
 | 
			
		||||
 | 
			
		||||
      tex_3d->gl_legacy_texobj_wrap_mode_s = wrap_mode_s;
 | 
			
		||||
      tex_3d->gl_legacy_texobj_wrap_mode_t = wrap_mode_t;
 | 
			
		||||
      tex_3d->gl_legacy_texobj_wrap_mode_p = wrap_mode_p;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_free (CoglTexture3D *tex_3d)
 | 
			
		||||
{
 | 
			
		||||
  if (tex_3d->gl_texture)
 | 
			
		||||
    _cogl_delete_gl_texture (tex_3d->gl_texture);
 | 
			
		||||
 | 
			
		||||
  /* Chain up */
 | 
			
		||||
  _cogl_texture_free (COGL_TEXTURE (tex_3d));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_set_auto_mipmap (CoglTexture *tex,
 | 
			
		||||
                                  gboolean value)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
 | 
			
		||||
  tex_3d->auto_mipmap = value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTexture3D *
 | 
			
		||||
_cogl_texture_3d_create_base (CoglContext *ctx,
 | 
			
		||||
                              int width,
 | 
			
		||||
                              int height,
 | 
			
		||||
                              int depth,
 | 
			
		||||
                              CoglPixelFormat internal_format,
 | 
			
		||||
                              CoglTextureLoader *loader)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1);
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_3d);
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_init (tex, ctx, width, height,
 | 
			
		||||
                      internal_format, loader, &cogl_texture_3d_vtable);
 | 
			
		||||
 | 
			
		||||
  tex_3d->gl_texture = 0;
 | 
			
		||||
 | 
			
		||||
  tex_3d->depth = depth;
 | 
			
		||||
  tex_3d->mipmaps_dirty = TRUE;
 | 
			
		||||
  tex_3d->auto_mipmap = TRUE;
 | 
			
		||||
 | 
			
		||||
  /* We default to GL_LINEAR for both filters */
 | 
			
		||||
  tex_3d->gl_legacy_texobj_min_filter = GL_LINEAR;
 | 
			
		||||
  tex_3d->gl_legacy_texobj_mag_filter = GL_LINEAR;
 | 
			
		||||
 | 
			
		||||
  /* Wrap mode not yet set */
 | 
			
		||||
  tex_3d->gl_legacy_texobj_wrap_mode_s = GL_FALSE;
 | 
			
		||||
  tex_3d->gl_legacy_texobj_wrap_mode_t = GL_FALSE;
 | 
			
		||||
  tex_3d->gl_legacy_texobj_wrap_mode_p = GL_FALSE;
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_3d_object_new (tex_3d);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_with_size (CoglContext *ctx,
 | 
			
		||||
                               int width,
 | 
			
		||||
                               int height,
 | 
			
		||||
                               int depth)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureLoader *loader = _cogl_texture_create_loader ();
 | 
			
		||||
  loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
 | 
			
		||||
  loader->src.sized.width = width;
 | 
			
		||||
  loader->src.sized.height = height;
 | 
			
		||||
  loader->src.sized.depth = depth;
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_3d_create_base (ctx, width, height, depth,
 | 
			
		||||
                                       COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                                       loader);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
 | 
			
		||||
                                 int height,
 | 
			
		||||
                                 int depth)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureLoader *loader;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (bmp, NULL);
 | 
			
		||||
 | 
			
		||||
  loader = _cogl_texture_create_loader ();
 | 
			
		||||
  loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
 | 
			
		||||
  loader->src.bitmap.bitmap = cogl_object_ref (bmp);
 | 
			
		||||
  loader->src.bitmap.height = height;
 | 
			
		||||
  loader->src.bitmap.depth = depth;
 | 
			
		||||
  loader->src.bitmap.can_convert_in_place = FALSE; /* TODO add api for this */
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_3d_create_base (_cogl_bitmap_get_context (bmp),
 | 
			
		||||
                                       cogl_bitmap_get_width (bmp),
 | 
			
		||||
                                       height,
 | 
			
		||||
                                       depth,
 | 
			
		||||
                                       cogl_bitmap_get_format (bmp),
 | 
			
		||||
                                       loader);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_from_data (CoglContext *context,
 | 
			
		||||
                               int width,
 | 
			
		||||
                               int height,
 | 
			
		||||
                               int depth,
 | 
			
		||||
                               CoglPixelFormat format,
 | 
			
		||||
                               int rowstride,
 | 
			
		||||
                               int image_stride,
 | 
			
		||||
                               const uint8_t *data,
 | 
			
		||||
                               CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglBitmap *bitmap;
 | 
			
		||||
  CoglTexture3D *ret;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (data, NULL);
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
 | 
			
		||||
 | 
			
		||||
  /* Rowstride from width if not given */
 | 
			
		||||
  if (rowstride == 0)
 | 
			
		||||
    rowstride = width * _cogl_pixel_format_get_bytes_per_pixel (format);
 | 
			
		||||
  /* Image stride from height and rowstride if not given */
 | 
			
		||||
  if (image_stride == 0)
 | 
			
		||||
    image_stride = height * rowstride;
 | 
			
		||||
 | 
			
		||||
  if (image_stride < rowstride * height)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  /* GL doesn't support uploading when the image_stride isn't a
 | 
			
		||||
     multiple of the rowstride. If this happens we'll just pack the
 | 
			
		||||
     image into a new bitmap. The documentation for this function
 | 
			
		||||
     recommends avoiding this situation. */
 | 
			
		||||
  if (image_stride % rowstride != 0)
 | 
			
		||||
    {
 | 
			
		||||
      uint8_t *bmp_data;
 | 
			
		||||
      int bmp_rowstride;
 | 
			
		||||
      int z, y;
 | 
			
		||||
 | 
			
		||||
      bitmap = _cogl_bitmap_new_with_malloc_buffer (context,
 | 
			
		||||
                                                    width,
 | 
			
		||||
                                                    depth * height,
 | 
			
		||||
                                                    format,
 | 
			
		||||
                                                    error);
 | 
			
		||||
      if (!bitmap)
 | 
			
		||||
        return NULL;
 | 
			
		||||
 | 
			
		||||
      bmp_data = _cogl_bitmap_map (bitmap,
 | 
			
		||||
                                   COGL_BUFFER_ACCESS_WRITE,
 | 
			
		||||
                                   COGL_BUFFER_MAP_HINT_DISCARD,
 | 
			
		||||
                                   error);
 | 
			
		||||
 | 
			
		||||
      if (bmp_data == NULL)
 | 
			
		||||
        {
 | 
			
		||||
          cogl_object_unref (bitmap);
 | 
			
		||||
          return NULL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      bmp_rowstride = cogl_bitmap_get_rowstride (bitmap);
 | 
			
		||||
 | 
			
		||||
      /* Copy all of the images in */
 | 
			
		||||
      for (z = 0; z < depth; z++)
 | 
			
		||||
        for (y = 0; y < height; y++)
 | 
			
		||||
          memcpy (bmp_data + (z * bmp_rowstride * height +
 | 
			
		||||
                              bmp_rowstride * y),
 | 
			
		||||
                  data + z * image_stride + rowstride * y,
 | 
			
		||||
                  bmp_rowstride);
 | 
			
		||||
 | 
			
		||||
      _cogl_bitmap_unmap (bitmap);
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    bitmap = cogl_bitmap_new_for_data (context,
 | 
			
		||||
                                       width,
 | 
			
		||||
                                       image_stride / rowstride * depth,
 | 
			
		||||
                                       format,
 | 
			
		||||
                                       rowstride,
 | 
			
		||||
                                       (uint8_t *) data);
 | 
			
		||||
 | 
			
		||||
  ret = cogl_texture_3d_new_from_bitmap (bitmap,
 | 
			
		||||
                                         height,
 | 
			
		||||
                                         depth);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (bitmap);
 | 
			
		||||
 | 
			
		||||
  if (ret &&
 | 
			
		||||
      !cogl_texture_allocate (COGL_TEXTURE (ret), error))
 | 
			
		||||
    {
 | 
			
		||||
      cogl_object_unref (ret);
 | 
			
		||||
      return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_can_create (CoglContext *ctx,
 | 
			
		||||
                             int width,
 | 
			
		||||
                             int height,
 | 
			
		||||
                             int depth,
 | 
			
		||||
                             CoglPixelFormat internal_format,
 | 
			
		||||
                             CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  /* This should only happen on GLES */
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "3D textures are not supported by the GPU");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* If NPOT textures aren't supported then the size must be a power
 | 
			
		||||
     of two */
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT) &&
 | 
			
		||||
      (!_cogl_util_is_pot (width) ||
 | 
			
		||||
       !_cogl_util_is_pot (height) ||
 | 
			
		||||
       !_cogl_util_is_pot (depth)))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "A non-power-of-two size was requested but this is not "
 | 
			
		||||
                       "supported by the GPU");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          NULL,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  /* Check that the driver can create a texture with that size */
 | 
			
		||||
  if (!ctx->texture_driver->size_supported_3d (ctx,
 | 
			
		||||
                                               GL_TEXTURE_3D,
 | 
			
		||||
                                               gl_intformat,
 | 
			
		||||
                                               gl_type,
 | 
			
		||||
                                               width,
 | 
			
		||||
                                               height,
 | 
			
		||||
                                               depth))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "The requested dimensions are not supported by the GPU");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
allocate_with_size (CoglTexture3D *tex_3d,
 | 
			
		||||
                    CoglTextureLoader *loader,
 | 
			
		||||
                    CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_3d);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
  int width = loader->src.sized.width;
 | 
			
		||||
  int height = loader->src.sized.height;
 | 
			
		||||
  int depth = loader->src.sized.depth;
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
  GLenum gl_texture;
 | 
			
		||||
 | 
			
		||||
  internal_format =
 | 
			
		||||
    _cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY);
 | 
			
		||||
 | 
			
		||||
  if (!_cogl_texture_3d_can_create (ctx,
 | 
			
		||||
                                    width,
 | 
			
		||||
                                    height,
 | 
			
		||||
                                    depth,
 | 
			
		||||
                                    internal_format,
 | 
			
		||||
                                    error))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  gl_texture =
 | 
			
		||||
    ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format);
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
 | 
			
		||||
                                   gl_texture,
 | 
			
		||||
                                   FALSE);
 | 
			
		||||
  /* Clear any GL errors */
 | 
			
		||||
  _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
  ctx->glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
 | 
			
		||||
                     width, height, depth,
 | 
			
		||||
                     0, gl_format, gl_type, NULL);
 | 
			
		||||
 | 
			
		||||
  if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
    {
 | 
			
		||||
      GE( ctx, glDeleteTextures (1, &gl_texture) );
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex_3d->gl_texture = gl_texture;
 | 
			
		||||
  tex_3d->gl_format = gl_intformat;
 | 
			
		||||
 | 
			
		||||
  tex_3d->depth = depth;
 | 
			
		||||
 | 
			
		||||
  tex_3d->internal_format = internal_format;
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_allocated (tex, internal_format, width, height);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
allocate_from_bitmap (CoglTexture3D *tex_3d,
 | 
			
		||||
                      CoglTextureLoader *loader,
 | 
			
		||||
                      CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_3d);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
  CoglBitmap *bmp = loader->src.bitmap.bitmap;
 | 
			
		||||
  int bmp_width = cogl_bitmap_get_width (bmp);
 | 
			
		||||
  int height = loader->src.bitmap.height;
 | 
			
		||||
  int depth = loader->src.bitmap.depth;
 | 
			
		||||
  CoglPixelFormat bmp_format = cogl_bitmap_get_format (bmp);
 | 
			
		||||
  gboolean can_convert_in_place = loader->src.bitmap.can_convert_in_place;
 | 
			
		||||
  CoglBitmap *upload_bmp;
 | 
			
		||||
  CoglPixelFormat upload_format;
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  internal_format = _cogl_texture_determine_internal_format (tex, bmp_format);
 | 
			
		||||
 | 
			
		||||
  if (!_cogl_texture_3d_can_create (ctx,
 | 
			
		||||
                                    bmp_width, height, depth,
 | 
			
		||||
                                    internal_format,
 | 
			
		||||
                                    error))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  upload_bmp = _cogl_bitmap_convert_for_upload (bmp,
 | 
			
		||||
                                                internal_format,
 | 
			
		||||
                                                can_convert_in_place,
 | 
			
		||||
                                                error);
 | 
			
		||||
  if (upload_bmp == NULL)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  upload_format = cogl_bitmap_get_format (upload_bmp);
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          upload_format,
 | 
			
		||||
                                          NULL, /* internal format */
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          NULL,
 | 
			
		||||
                                          NULL);
 | 
			
		||||
 | 
			
		||||
  /* Keep a copy of the first pixel so that if glGenerateMipmap isn't
 | 
			
		||||
     supported we can fallback to using GL_GENERATE_MIPMAP */
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
 | 
			
		||||
    {
 | 
			
		||||
      CoglError *ignore = NULL;
 | 
			
		||||
      uint8_t *data = _cogl_bitmap_map (upload_bmp,
 | 
			
		||||
                                        COGL_BUFFER_ACCESS_READ, 0,
 | 
			
		||||
                                        &ignore);
 | 
			
		||||
 | 
			
		||||
      tex_3d->first_pixel.gl_format = gl_format;
 | 
			
		||||
      tex_3d->first_pixel.gl_type = gl_type;
 | 
			
		||||
 | 
			
		||||
      if (data)
 | 
			
		||||
        {
 | 
			
		||||
          memcpy (tex_3d->first_pixel.data, data,
 | 
			
		||||
                  _cogl_pixel_format_get_bytes_per_pixel (upload_format));
 | 
			
		||||
          _cogl_bitmap_unmap (upload_bmp);
 | 
			
		||||
        }
 | 
			
		||||
      else
 | 
			
		||||
        {
 | 
			
		||||
          g_warning ("Failed to read first pixel of bitmap for "
 | 
			
		||||
                     "glGenerateMipmap fallback");
 | 
			
		||||
          cogl_error_free (ignore);
 | 
			
		||||
          memset (tex_3d->first_pixel.data, 0,
 | 
			
		||||
                  _cogl_pixel_format_get_bytes_per_pixel (upload_format));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex_3d->gl_texture =
 | 
			
		||||
    ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format);
 | 
			
		||||
 | 
			
		||||
  if (!ctx->texture_driver->upload_to_gl_3d (ctx,
 | 
			
		||||
                                             GL_TEXTURE_3D,
 | 
			
		||||
                                             tex_3d->gl_texture,
 | 
			
		||||
                                             FALSE, /* is_foreign */
 | 
			
		||||
                                             height,
 | 
			
		||||
                                             depth,
 | 
			
		||||
                                             upload_bmp,
 | 
			
		||||
                                             gl_intformat,
 | 
			
		||||
                                             gl_format,
 | 
			
		||||
                                             gl_type,
 | 
			
		||||
                                             error))
 | 
			
		||||
    {
 | 
			
		||||
      cogl_object_unref (upload_bmp);
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex_3d->gl_format = gl_intformat;
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (upload_bmp);
 | 
			
		||||
 | 
			
		||||
  tex_3d->depth = loader->src.bitmap.depth;
 | 
			
		||||
 | 
			
		||||
  tex_3d->internal_format = internal_format;
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_allocated (tex, internal_format,
 | 
			
		||||
                               bmp_width, loader->src.bitmap.height);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_allocate (CoglTexture *tex,
 | 
			
		||||
                           CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
  CoglTextureLoader *loader = tex->loader;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
 | 
			
		||||
 | 
			
		||||
  switch (loader->src_type)
 | 
			
		||||
    {
 | 
			
		||||
    case COGL_TEXTURE_SOURCE_TYPE_SIZED:
 | 
			
		||||
      return allocate_with_size (tex_3d, loader, error);
 | 
			
		||||
    case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
 | 
			
		||||
      return allocate_from_bitmap (tex_3d, loader, error);
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_reached (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
_cogl_texture_3d_get_max_waste (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_is_sliced (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_can_hardware_repeat (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_transform_coords_to_gl (CoglTexture *tex,
 | 
			
		||||
                                         float *s,
 | 
			
		||||
                                         float *t)
 | 
			
		||||
{
 | 
			
		||||
  /* The texture coordinates map directly so we don't need to do
 | 
			
		||||
     anything */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTransformResult
 | 
			
		||||
_cogl_texture_3d_transform_quad_coords_to_gl (CoglTexture *tex,
 | 
			
		||||
                                              float *coords)
 | 
			
		||||
{
 | 
			
		||||
  /* The texture coordinates map directly so we don't need to do
 | 
			
		||||
     anything other than check for repeats */
 | 
			
		||||
 | 
			
		||||
  gboolean need_repeat = FALSE;
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < 4; i++)
 | 
			
		||||
    if (coords[i] < 0.0f || coords[i] > 1.0f)
 | 
			
		||||
      need_repeat = TRUE;
 | 
			
		||||
 | 
			
		||||
  return (need_repeat ? COGL_TRANSFORM_HARDWARE_REPEAT
 | 
			
		||||
          : COGL_TRANSFORM_NO_REPEAT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_get_gl_texture (CoglTexture *tex,
 | 
			
		||||
                                 GLuint *out_gl_handle,
 | 
			
		||||
                                 GLenum *out_gl_target)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
 | 
			
		||||
  if (out_gl_handle)
 | 
			
		||||
    *out_gl_handle = tex_3d->gl_texture;
 | 
			
		||||
 | 
			
		||||
  if (out_gl_target)
 | 
			
		||||
    *out_gl_target = GL_TEXTURE_3D;
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_gl_flush_legacy_texobj_filters (CoglTexture *tex,
 | 
			
		||||
                                                 GLenum min_filter,
 | 
			
		||||
                                                 GLenum mag_filter)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  if (min_filter == tex_3d->gl_legacy_texobj_min_filter
 | 
			
		||||
      && mag_filter == tex_3d->gl_legacy_texobj_mag_filter)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  /* Store new values */
 | 
			
		||||
  tex_3d->gl_legacy_texobj_min_filter = min_filter;
 | 
			
		||||
  tex_3d->gl_legacy_texobj_mag_filter = mag_filter;
 | 
			
		||||
 | 
			
		||||
  /* Apply new filters to the texture */
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
 | 
			
		||||
                                   tex_3d->gl_texture,
 | 
			
		||||
                                   FALSE);
 | 
			
		||||
  GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, mag_filter) );
 | 
			
		||||
  GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, min_filter) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  /* Only update if the mipmaps are dirty */
 | 
			
		||||
  if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
 | 
			
		||||
      tex_3d->auto_mipmap && tex_3d->mipmaps_dirty)
 | 
			
		||||
    {
 | 
			
		||||
      /* glGenerateMipmap is defined in the FBO extension. If it's not
 | 
			
		||||
         available we'll fallback to temporarily enabling
 | 
			
		||||
         GL_GENERATE_MIPMAP and reuploading the first pixel */
 | 
			
		||||
      if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
 | 
			
		||||
        _cogl_texture_gl_generate_mipmaps (tex);
 | 
			
		||||
#ifdef HAVE_COGL_GL
 | 
			
		||||
      else if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED))
 | 
			
		||||
        {
 | 
			
		||||
          _cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
 | 
			
		||||
                                           tex_3d->gl_texture,
 | 
			
		||||
                                           FALSE);
 | 
			
		||||
 | 
			
		||||
          GE( ctx, glTexParameteri (GL_TEXTURE_3D,
 | 
			
		||||
                                    GL_GENERATE_MIPMAP,
 | 
			
		||||
                                    GL_TRUE) );
 | 
			
		||||
          GE( ctx, glTexSubImage3D (GL_TEXTURE_3D,
 | 
			
		||||
                                    0, /* level */
 | 
			
		||||
                                    0, /* xoffset */
 | 
			
		||||
                                    0, /* yoffset */
 | 
			
		||||
                                    0, /* zoffset */
 | 
			
		||||
                                    1, /* width */
 | 
			
		||||
                                    1, /* height */
 | 
			
		||||
                                    1, /* depth */
 | 
			
		||||
                                    tex_3d->first_pixel.gl_format,
 | 
			
		||||
                                    tex_3d->first_pixel.gl_type,
 | 
			
		||||
                                    tex_3d->first_pixel.data) );
 | 
			
		||||
          GE( ctx, glTexParameteri (GL_TEXTURE_3D,
 | 
			
		||||
                                    GL_GENERATE_MIPMAP,
 | 
			
		||||
                                    GL_FALSE) );
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
      tex_3d->mipmaps_dirty = FALSE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_3d_ensure_non_quad_rendering (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  /* Nothing needs to be done */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_3d_set_region (CoglTexture *tex,
 | 
			
		||||
                             int src_x,
 | 
			
		||||
                             int src_y,
 | 
			
		||||
                             int dst_x,
 | 
			
		||||
                             int dst_y,
 | 
			
		||||
                             int dst_width,
 | 
			
		||||
                             int dst_height,
 | 
			
		||||
                             int level,
 | 
			
		||||
                             CoglBitmap *bmp,
 | 
			
		||||
                             CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  /* This function doesn't really make sense for 3D textures because
 | 
			
		||||
     it can't specify which image to upload to */
 | 
			
		||||
  _cogl_set_error (error,
 | 
			
		||||
                   COGL_SYSTEM_ERROR,
 | 
			
		||||
                   COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                   "Setting a 2D region on a 3D texture isn't "
 | 
			
		||||
                   "currently supported");
 | 
			
		||||
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
_cogl_texture_3d_get_data (CoglTexture *tex,
 | 
			
		||||
                           CoglPixelFormat format,
 | 
			
		||||
                           int rowstride,
 | 
			
		||||
                           uint8_t *data)
 | 
			
		||||
{
 | 
			
		||||
  /* FIXME: we could probably implement this by assuming the data is
 | 
			
		||||
     big enough to hold all of the images and that there is no stride
 | 
			
		||||
     between the images. However it would be better to have an API
 | 
			
		||||
     that can provide an image stride and this function probably isn't
 | 
			
		||||
     particularly useful anyway so for now it just reports failure */
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglPixelFormat
 | 
			
		||||
_cogl_texture_3d_get_format (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_3D (tex)->internal_format;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GLenum
 | 
			
		||||
_cogl_texture_3d_get_gl_format (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_3D (tex)->gl_format;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_texture_3d_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_TYPE_3D;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_texture_3d_vtable =
 | 
			
		||||
  {
 | 
			
		||||
    TRUE, /* primitive */
 | 
			
		||||
    _cogl_texture_3d_allocate,
 | 
			
		||||
    _cogl_texture_3d_set_region,
 | 
			
		||||
    NULL, /* is_get_data_supported */
 | 
			
		||||
    _cogl_texture_3d_get_data,
 | 
			
		||||
    NULL, /* foreach_sub_texture_in_region */
 | 
			
		||||
    _cogl_texture_3d_get_max_waste,
 | 
			
		||||
    _cogl_texture_3d_is_sliced,
 | 
			
		||||
    _cogl_texture_3d_can_hardware_repeat,
 | 
			
		||||
    _cogl_texture_3d_transform_coords_to_gl,
 | 
			
		||||
    _cogl_texture_3d_transform_quad_coords_to_gl,
 | 
			
		||||
    _cogl_texture_3d_get_gl_texture,
 | 
			
		||||
    _cogl_texture_3d_gl_flush_legacy_texobj_filters,
 | 
			
		||||
    _cogl_texture_3d_pre_paint,
 | 
			
		||||
    _cogl_texture_3d_ensure_non_quad_rendering,
 | 
			
		||||
    _cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_texture_3d_get_format,
 | 
			
		||||
    _cogl_texture_3d_get_gl_format,
 | 
			
		||||
    _cogl_texture_3d_get_type,
 | 
			
		||||
    NULL, /* is_foreign */
 | 
			
		||||
    _cogl_texture_3d_set_auto_mipmap
 | 
			
		||||
  };
 | 
			
		||||
@@ -1,202 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2010 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *   Neil Roberts <neil@linux.intel.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
 | 
			
		||||
#error "Only <cogl/cogl.h> can be included directly."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __COGL_TEXTURE_3D_H
 | 
			
		||||
#define __COGL_TEXTURE_3D_H
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:cogl-texture-3d
 | 
			
		||||
 * @short_description: Functions for creating and manipulating 3D textures
 | 
			
		||||
 *
 | 
			
		||||
 * These functions allow 3D textures to be used. 3D textures can be
 | 
			
		||||
 * thought of as layers of 2D images arranged into a cuboid
 | 
			
		||||
 * shape. When choosing a texel from the texture, Cogl will take into
 | 
			
		||||
 * account the 'r' texture coordinate to select one of the images.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
typedef struct _CoglTexture3D CoglTexture3D;
 | 
			
		||||
 | 
			
		||||
#define COGL_TEXTURE_3D(X) ((CoglTexture3D *)X)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_3d_get_gtype:
 | 
			
		||||
 *
 | 
			
		||||
 * Returns: a #GType that can be used with the GLib type system.
 | 
			
		||||
 */
 | 
			
		||||
GType cogl_texture_3d_get_gtype (void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_3d_new_with_size:
 | 
			
		||||
 * @context: a #CoglContext
 | 
			
		||||
 * @width: width of the texture in pixels.
 | 
			
		||||
 * @height: height of the texture in pixels.
 | 
			
		||||
 * @depth: depth of the texture in pixels.
 | 
			
		||||
 *
 | 
			
		||||
 * Creates a low-level #CoglTexture3D texture with the specified
 | 
			
		||||
 * dimensions and pixel format.
 | 
			
		||||
 *
 | 
			
		||||
 * The storage for the texture is not allocated before this function
 | 
			
		||||
 * returns. You can call cogl_texture_allocate() to explicitly
 | 
			
		||||
 * allocate the underlying storage or preferably let Cogl
 | 
			
		||||
 * automatically allocate storage lazily when it may know more about
 | 
			
		||||
 * how the texture is going to be used and can optimize how it is
 | 
			
		||||
 * allocated.
 | 
			
		||||
 *
 | 
			
		||||
 * The texture is still configurable until it has been allocated so
 | 
			
		||||
 * for example you can influence the internal format of the texture
 | 
			
		||||
 * using cogl_texture_set_components() and
 | 
			
		||||
 * cogl_texture_set_premultiplied().
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This texture will fail to allocate later if
 | 
			
		||||
 * %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also
 | 
			
		||||
 * fail if the requested dimensions are not supported by the
 | 
			
		||||
 * GPU.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Returns: (transfer full): A new #CoglTexture3D object with no storage yet allocated.
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 * Stability: Unstable
 | 
			
		||||
 */
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_with_size (CoglContext *context,
 | 
			
		||||
                               int width,
 | 
			
		||||
                               int height,
 | 
			
		||||
                               int depth);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_3d_new_from_data:
 | 
			
		||||
 * @context: a #CoglContext
 | 
			
		||||
 * @width: width of the texture in pixels.
 | 
			
		||||
 * @height: height of the texture in pixels.
 | 
			
		||||
 * @depth: depth of the texture in pixels.
 | 
			
		||||
 * @format: the #CoglPixelFormat the buffer is stored in in RAM
 | 
			
		||||
 * @rowstride: the memory offset in bytes between the starts of
 | 
			
		||||
 *    scanlines in @data or 0 to infer it from the width and format
 | 
			
		||||
 * @image_stride: the number of bytes from one image to the next. This
 | 
			
		||||
 *    can be used to add padding between the images in a similar way
 | 
			
		||||
 *    that the rowstride can be used to add padding between
 | 
			
		||||
 *    rows. Alternatively 0 can be passed to infer the @image_stride
 | 
			
		||||
 *    from the @height.
 | 
			
		||||
 * @data: pointer the memory region where the source buffer resides
 | 
			
		||||
 * @error: A CoglError return location.
 | 
			
		||||
 *
 | 
			
		||||
 * Creates a low-level 3D texture and initializes it with @data. The
 | 
			
		||||
 * data is assumed to be packed array of @depth images. There can be
 | 
			
		||||
 * padding between the images using @image_stride.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This api will always immediately allocate GPU memory for the
 | 
			
		||||
 * texture and upload the given data so that the @data pointer does
 | 
			
		||||
 * not need to remain valid once this function returns. This means it
 | 
			
		||||
 * is not possible to configure the texture before it is allocated. If
 | 
			
		||||
 * you do need to configure the texture before allocation (to specify
 | 
			
		||||
 * constraints on the internal format for example) then you can
 | 
			
		||||
 * instead create a #CoglBitmap for your data and use
 | 
			
		||||
 * cogl_texture_3d_new_from_bitmap().</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): the newly created #CoglTexture3D or
 | 
			
		||||
 *               %NULL if there was an error and an exception will be
 | 
			
		||||
 *               returned through @error.
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 * Stability: Unstable
 | 
			
		||||
 */
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_from_data (CoglContext *context,
 | 
			
		||||
                               int width,
 | 
			
		||||
                               int height,
 | 
			
		||||
                               int depth,
 | 
			
		||||
                               CoglPixelFormat format,
 | 
			
		||||
                               int rowstride,
 | 
			
		||||
                               int image_stride,
 | 
			
		||||
                               const uint8_t *data,
 | 
			
		||||
                               CoglError **error);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_3d_new_from_bitmap:
 | 
			
		||||
 * @bitmap: A #CoglBitmap object.
 | 
			
		||||
 * @height: height of the texture in pixels.
 | 
			
		||||
 * @depth: depth of the texture in pixels.
 | 
			
		||||
 *
 | 
			
		||||
 * Creates a low-level 3D texture and initializes it with the images
 | 
			
		||||
 * in @bitmap. The images are assumed to be packed together after one
 | 
			
		||||
 * another in the increasing y axis. The height of individual image is
 | 
			
		||||
 * given as @height and the number of images is given in @depth. The
 | 
			
		||||
 * actual height of the bitmap can be larger than @height × @depth. In
 | 
			
		||||
 * this case it assumes there is padding between the images.
 | 
			
		||||
 *
 | 
			
		||||
 * The storage for the texture is not allocated before this function
 | 
			
		||||
 * returns. You can call cogl_texture_allocate() to explicitly
 | 
			
		||||
 * allocate the underlying storage or preferably let Cogl
 | 
			
		||||
 * automatically allocate storage lazily when it may know more about
 | 
			
		||||
 * how the texture is going to be used and can optimize how it is
 | 
			
		||||
 * allocated.
 | 
			
		||||
 *
 | 
			
		||||
 * The texture is still configurable until it has been allocated so
 | 
			
		||||
 * for example you can influence the internal format of the texture
 | 
			
		||||
 * using cogl_texture_set_components() and
 | 
			
		||||
 * cogl_texture_set_premultiplied().
 | 
			
		||||
 *
 | 
			
		||||
 * <note>This texture will fail to allocate later if
 | 
			
		||||
 * %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also
 | 
			
		||||
 * fail if the requested dimensions are not supported by the
 | 
			
		||||
 * GPU.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): a newly created #CoglTexture3D
 | 
			
		||||
 * Since: 2.0
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 */
 | 
			
		||||
CoglTexture3D *
 | 
			
		||||
cogl_texture_3d_new_from_bitmap (CoglBitmap *bitmap,
 | 
			
		||||
                                 int height,
 | 
			
		||||
                                 int depth);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_is_texture_3d:
 | 
			
		||||
 * @object: a #CoglObject
 | 
			
		||||
 *
 | 
			
		||||
 * Checks whether the given object references a #CoglTexture3D
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: %TRUE if the passed object represents a 3D texture
 | 
			
		||||
 *   and %FALSE otherwise
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 1.4
 | 
			
		||||
 * Stability: Unstable
 | 
			
		||||
 */
 | 
			
		||||
gboolean
 | 
			
		||||
cogl_is_texture_3d (void *object);
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* __COGL_TEXTURE_3D_H */
 | 
			
		||||
@@ -103,26 +103,6 @@ struct _CoglTextureDriver
 | 
			
		||||
                    GLuint source_gl_type,
 | 
			
		||||
                    CoglError **error);
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Replaces the contents of the GL texture with the entire bitmap. The
 | 
			
		||||
   * width of the texture is inferred from the bitmap. The height and
 | 
			
		||||
   * depth of the texture is given directly. The 'image_height' (which
 | 
			
		||||
   * is the number of rows between images) is inferred by dividing the
 | 
			
		||||
   * height of the bitmap by the depth.
 | 
			
		||||
   */
 | 
			
		||||
  gboolean
 | 
			
		||||
  (* upload_to_gl_3d) (CoglContext *ctx,
 | 
			
		||||
                       GLenum gl_target,
 | 
			
		||||
                       GLuint gl_handle,
 | 
			
		||||
                       gboolean is_foreign,
 | 
			
		||||
                       GLint height,
 | 
			
		||||
                       GLint depth,
 | 
			
		||||
                       CoglBitmap *source_bmp,
 | 
			
		||||
                       GLint internal_gl_format,
 | 
			
		||||
                       GLuint source_gl_format,
 | 
			
		||||
                       GLuint source_gl_type,
 | 
			
		||||
                       CoglError **error);
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * This sets up the glPixelStore state for an download to a destination with
 | 
			
		||||
   * the same size, and with no offset.
 | 
			
		||||
@@ -162,15 +142,6 @@ struct _CoglTextureDriver
 | 
			
		||||
                      int width,
 | 
			
		||||
                      int height);
 | 
			
		||||
 | 
			
		||||
  gboolean
 | 
			
		||||
  (* size_supported_3d) (CoglContext *ctx,
 | 
			
		||||
                         GLenum gl_target,
 | 
			
		||||
                         GLenum gl_format,
 | 
			
		||||
                         GLenum gl_type,
 | 
			
		||||
                         int width,
 | 
			
		||||
                         int height,
 | 
			
		||||
                         int depth);
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * It may depend on the driver as to what texture targets may be used when
 | 
			
		||||
   * creating a foreign texture. E.g. OpenGL supports ARB_texture_rectangle
 | 
			
		||||
 
 | 
			
		||||
@@ -146,8 +146,6 @@ struct _CoglTextureVtable
 | 
			
		||||
  CoglPixelFormat (* get_format) (CoglTexture *tex);
 | 
			
		||||
  GLenum (* get_gl_format) (CoglTexture *tex);
 | 
			
		||||
 | 
			
		||||
  CoglTextureType (* get_type) (CoglTexture *tex);
 | 
			
		||||
 | 
			
		||||
  gboolean (* is_foreign) (CoglTexture *tex);
 | 
			
		||||
 | 
			
		||||
  /* Only needs to be implemented if is_primitive == TRUE */
 | 
			
		||||
@@ -354,18 +352,6 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
 | 
			
		||||
                                       CoglMetaTextureCallback callback,
 | 
			
		||||
                                       void *user_data);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * _cogl_texture_get_type:
 | 
			
		||||
 * @texture: a #CoglTexture pointer
 | 
			
		||||
 *
 | 
			
		||||
 * Retrieves the texture type of the underlying hardware texture that
 | 
			
		||||
 * this #CoglTexture will use.
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: The type of the hardware texture.
 | 
			
		||||
 */
 | 
			
		||||
CoglTextureType
 | 
			
		||||
_cogl_texture_get_type (CoglTexture *texture);
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_texture_set_region (CoglTexture *texture,
 | 
			
		||||
                          int width,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2009 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __COGL_TEXTURE_RECTANGLE_H
 | 
			
		||||
#define __COGL_TEXTURE_RECTANGLE_H
 | 
			
		||||
 | 
			
		||||
#include "cogl-pipeline-private.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle.h"
 | 
			
		||||
 | 
			
		||||
struct _CoglTextureRectangle
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture _parent;
 | 
			
		||||
 | 
			
		||||
  /* The internal format of the texture represented as a
 | 
			
		||||
     CoglPixelFormat */
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
 | 
			
		||||
  /* TODO: factor out these OpenGL specific members into some form
 | 
			
		||||
   * of driver private state. */
 | 
			
		||||
 | 
			
		||||
  /* The internal format of the GL texture represented as a GL enum */
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  /* The texture object number */
 | 
			
		||||
  GLuint gl_texture;
 | 
			
		||||
  GLenum gl_legacy_texobj_min_filter;
 | 
			
		||||
  GLenum gl_legacy_texobj_mag_filter;
 | 
			
		||||
  GLint gl_legacy_texobj_wrap_mode_s;
 | 
			
		||||
  GLint gl_legacy_texobj_wrap_mode_t;
 | 
			
		||||
  gboolean is_foreign;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
_cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
 | 
			
		||||
                                          GLuint width,
 | 
			
		||||
                                          GLuint height,
 | 
			
		||||
                                          CoglPixelFormat format);
 | 
			
		||||
 | 
			
		||||
#endif /* __COGL_TEXTURE_RECTANGLE_H */
 | 
			
		||||
@@ -1,776 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2010 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *  Neil Roberts   <neil@linux.intel.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cogl-config.h"
 | 
			
		||||
 | 
			
		||||
#include "cogl-private.h"
 | 
			
		||||
#include "cogl-util.h"
 | 
			
		||||
#include "cogl-texture-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-texture-driver.h"
 | 
			
		||||
#include "cogl-context-private.h"
 | 
			
		||||
#include "cogl-object-private.h"
 | 
			
		||||
#include "cogl-journal-private.h"
 | 
			
		||||
#include "cogl-error-private.h"
 | 
			
		||||
#include "cogl-gtype-private.h"
 | 
			
		||||
#include "driver/gl/cogl-pipeline-opengl-private.h"
 | 
			
		||||
#include "driver/gl/cogl-util-gl-private.h"
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
/* These aren't defined under GLES */
 | 
			
		||||
#ifndef GL_TEXTURE_RECTANGLE_ARB
 | 
			
		||||
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_CLAMP
 | 
			
		||||
#define GL_CLAMP                 0x2900
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GL_CLAMP_TO_BORDER
 | 
			
		||||
#define GL_CLAMP_TO_BORDER       0x812D
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect);
 | 
			
		||||
 | 
			
		||||
COGL_TEXTURE_DEFINE (TextureRectangle, texture_rectangle);
 | 
			
		||||
COGL_GTYPE_DEFINE_CLASS (TextureRectangle, texture_rectangle,
 | 
			
		||||
                         COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable cogl_texture_rectangle_vtable;
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
can_use_wrap_mode (GLenum wrap_mode)
 | 
			
		||||
{
 | 
			
		||||
  return (wrap_mode == GL_CLAMP ||
 | 
			
		||||
          wrap_mode == GL_CLAMP_TO_EDGE ||
 | 
			
		||||
          wrap_mode == GL_CLAMP_TO_BORDER);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
 | 
			
		||||
                                                           GLenum wrap_mode_s,
 | 
			
		||||
                                                           GLenum wrap_mode_t,
 | 
			
		||||
                                                           GLenum wrap_mode_p)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  /* Only set the wrap mode if it's different from the current value
 | 
			
		||||
     to avoid too many GL calls. Texture rectangle doesn't make use of
 | 
			
		||||
     the r coordinate so we can ignore its wrap mode */
 | 
			
		||||
  if (tex_rect->gl_legacy_texobj_wrap_mode_s != wrap_mode_s ||
 | 
			
		||||
      tex_rect->gl_legacy_texobj_wrap_mode_t != wrap_mode_t)
 | 
			
		||||
    {
 | 
			
		||||
      g_assert (can_use_wrap_mode (wrap_mode_s));
 | 
			
		||||
      g_assert (can_use_wrap_mode (wrap_mode_t));
 | 
			
		||||
 | 
			
		||||
      _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                       tex_rect->gl_texture,
 | 
			
		||||
                                       tex_rect->is_foreign);
 | 
			
		||||
      GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                GL_TEXTURE_WRAP_S, wrap_mode_s) );
 | 
			
		||||
      GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                GL_TEXTURE_WRAP_T, wrap_mode_t) );
 | 
			
		||||
 | 
			
		||||
      tex_rect->gl_legacy_texobj_wrap_mode_s = wrap_mode_s;
 | 
			
		||||
      tex_rect->gl_legacy_texobj_wrap_mode_t = wrap_mode_t;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect)
 | 
			
		||||
{
 | 
			
		||||
  if (!tex_rect->is_foreign && tex_rect->gl_texture)
 | 
			
		||||
    _cogl_delete_gl_texture (tex_rect->gl_texture);
 | 
			
		||||
 | 
			
		||||
  /* Chain up */
 | 
			
		||||
  _cogl_texture_free (COGL_TEXTURE (tex_rect));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_can_create (CoglContext *ctx,
 | 
			
		||||
                                    unsigned int width,
 | 
			
		||||
                                    unsigned int height,
 | 
			
		||||
                                    CoglPixelFormat internal_format,
 | 
			
		||||
                                    CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_TEXTURE_ERROR,
 | 
			
		||||
                       COGL_TEXTURE_ERROR_TYPE,
 | 
			
		||||
                       "The CoglTextureRectangle feature isn't available");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  /* Check that the driver can create a texture with that size */
 | 
			
		||||
  if (!ctx->texture_driver->size_supported (ctx,
 | 
			
		||||
                                            GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                            gl_intformat,
 | 
			
		||||
                                            gl_format,
 | 
			
		||||
                                            gl_type,
 | 
			
		||||
                                            width,
 | 
			
		||||
                                            height))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_TEXTURE_ERROR,
 | 
			
		||||
                       COGL_TEXTURE_ERROR_SIZE,
 | 
			
		||||
                       "The requested texture size + format is unsupported");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_set_auto_mipmap (CoglTexture *tex,
 | 
			
		||||
                                         gboolean value)
 | 
			
		||||
{
 | 
			
		||||
  /* Rectangle textures currently never support mipmapping so there's
 | 
			
		||||
     no point in doing anything here */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureRectangle *
 | 
			
		||||
_cogl_texture_rectangle_create_base (CoglContext *ctx,
 | 
			
		||||
                                     int width,
 | 
			
		||||
                                     int height,
 | 
			
		||||
                                     CoglPixelFormat internal_format,
 | 
			
		||||
                                     CoglTextureLoader *loader)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = g_new (CoglTextureRectangle, 1);
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_rect);
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_init (tex, ctx, width, height,
 | 
			
		||||
                      internal_format, loader,
 | 
			
		||||
                      &cogl_texture_rectangle_vtable);
 | 
			
		||||
 | 
			
		||||
  tex_rect->gl_texture = 0;
 | 
			
		||||
  tex_rect->is_foreign = FALSE;
 | 
			
		||||
 | 
			
		||||
  /* We default to GL_LINEAR for both filters */
 | 
			
		||||
  tex_rect->gl_legacy_texobj_min_filter = GL_LINEAR;
 | 
			
		||||
  tex_rect->gl_legacy_texobj_mag_filter = GL_LINEAR;
 | 
			
		||||
 | 
			
		||||
  /* Wrap mode not yet set */
 | 
			
		||||
  tex_rect->gl_legacy_texobj_wrap_mode_s = GL_FALSE;
 | 
			
		||||
  tex_rect->gl_legacy_texobj_wrap_mode_t = GL_FALSE;
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_rectangle_object_new (tex_rect);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
 | 
			
		||||
                                      int width,
 | 
			
		||||
                                      int height)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureLoader *loader = _cogl_texture_create_loader ();
 | 
			
		||||
  loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
 | 
			
		||||
  loader->src.sized.width = width;
 | 
			
		||||
  loader->src.sized.height = height;
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_rectangle_create_base (ctx, width, height,
 | 
			
		||||
                                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                                              loader);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
allocate_with_size (CoglTextureRectangle *tex_rect,
 | 
			
		||||
                    CoglTextureLoader *loader,
 | 
			
		||||
                    CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_rect);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
  int width = loader->src.sized.width;
 | 
			
		||||
  int height = loader->src.sized.height;
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
  GLenum gl_texture;
 | 
			
		||||
 | 
			
		||||
  internal_format =
 | 
			
		||||
    _cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY);
 | 
			
		||||
 | 
			
		||||
  if (!_cogl_texture_rectangle_can_create (ctx,
 | 
			
		||||
                                           width,
 | 
			
		||||
                                           height,
 | 
			
		||||
                                           internal_format,
 | 
			
		||||
                                           error))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  gl_texture =
 | 
			
		||||
    ctx->texture_driver->gen (ctx,
 | 
			
		||||
                              GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                              internal_format);
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                   gl_texture,
 | 
			
		||||
                                   tex_rect->is_foreign);
 | 
			
		||||
 | 
			
		||||
  /* Clear any GL errors */
 | 
			
		||||
  _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
  ctx->glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_intformat,
 | 
			
		||||
                     width, height, 0, gl_format, gl_type, NULL);
 | 
			
		||||
 | 
			
		||||
  if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
    {
 | 
			
		||||
      GE( ctx, glDeleteTextures (1, &gl_texture) );
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex_rect->internal_format = internal_format;
 | 
			
		||||
 | 
			
		||||
  tex_rect->gl_texture = gl_texture;
 | 
			
		||||
  tex_rect->gl_format = gl_intformat;
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
 | 
			
		||||
                               internal_format, width, height);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
allocate_from_bitmap (CoglTextureRectangle *tex_rect,
 | 
			
		||||
                      CoglTextureLoader *loader,
 | 
			
		||||
                      CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_rect);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  CoglPixelFormat internal_format;
 | 
			
		||||
  CoglBitmap *bmp = loader->src.bitmap.bitmap;
 | 
			
		||||
  int width = cogl_bitmap_get_width (bmp);
 | 
			
		||||
  int height = cogl_bitmap_get_height (bmp);
 | 
			
		||||
  gboolean can_convert_in_place = loader->src.bitmap.can_convert_in_place;
 | 
			
		||||
  CoglBitmap *upload_bmp;
 | 
			
		||||
  GLenum gl_intformat;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  internal_format =
 | 
			
		||||
    _cogl_texture_determine_internal_format (tex, cogl_bitmap_get_format (bmp));
 | 
			
		||||
 | 
			
		||||
  if (!_cogl_texture_rectangle_can_create (ctx,
 | 
			
		||||
                                           width,
 | 
			
		||||
                                           height,
 | 
			
		||||
                                           internal_format,
 | 
			
		||||
                                           error))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  upload_bmp = _cogl_bitmap_convert_for_upload (bmp,
 | 
			
		||||
                                                internal_format,
 | 
			
		||||
                                                can_convert_in_place,
 | 
			
		||||
                                                error);
 | 
			
		||||
  if (upload_bmp == NULL)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          cogl_bitmap_get_format (upload_bmp),
 | 
			
		||||
                                          NULL, /* internal format */
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
                                          NULL,
 | 
			
		||||
                                          NULL);
 | 
			
		||||
 | 
			
		||||
  tex_rect->gl_texture =
 | 
			
		||||
    ctx->texture_driver->gen (ctx,
 | 
			
		||||
                              GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                              internal_format);
 | 
			
		||||
  if (!ctx->texture_driver->upload_to_gl (ctx,
 | 
			
		||||
                                          GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                          tex_rect->gl_texture,
 | 
			
		||||
                                          FALSE,
 | 
			
		||||
                                          upload_bmp,
 | 
			
		||||
                                          gl_intformat,
 | 
			
		||||
                                          gl_format,
 | 
			
		||||
                                          gl_type,
 | 
			
		||||
                                          error))
 | 
			
		||||
    {
 | 
			
		||||
      cogl_object_unref (upload_bmp);
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex_rect->gl_format = gl_intformat;
 | 
			
		||||
  tex_rect->internal_format = internal_format;
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (upload_bmp);
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
 | 
			
		||||
                               internal_format, width, height);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
allocate_from_gl_foreign (CoglTextureRectangle *tex_rect,
 | 
			
		||||
                          CoglTextureLoader *loader,
 | 
			
		||||
                          CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = COGL_TEXTURE (tex_rect);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  CoglPixelFormat format = loader->src.gl_foreign.format;
 | 
			
		||||
  GLint gl_compressed = GL_FALSE;
 | 
			
		||||
  GLenum gl_int_format = 0;
 | 
			
		||||
 | 
			
		||||
  if (!ctx->texture_driver->allows_foreign_gl_target (ctx,
 | 
			
		||||
                                                      GL_TEXTURE_RECTANGLE_ARB))
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "Foreign GL_TEXTURE_RECTANGLE textures are not "
 | 
			
		||||
                       "supported by your system");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Make sure binding succeeds */
 | 
			
		||||
  _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                   loader->src.gl_foreign.gl_handle, TRUE);
 | 
			
		||||
  if (_cogl_gl_util_get_error (ctx) != GL_NO_ERROR)
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "Failed to bind foreign GL_TEXTURE_RECTANGLE texture");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Obtain texture parameters */
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_COGL_GL
 | 
			
		||||
  if (_cogl_has_private_feature
 | 
			
		||||
      (ctx, COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS))
 | 
			
		||||
    {
 | 
			
		||||
      GLint val;
 | 
			
		||||
 | 
			
		||||
      GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
 | 
			
		||||
                                         GL_TEXTURE_COMPRESSED,
 | 
			
		||||
                                         &gl_compressed) );
 | 
			
		||||
 | 
			
		||||
      GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
 | 
			
		||||
                                         GL_TEXTURE_INTERNAL_FORMAT,
 | 
			
		||||
                                         &val) );
 | 
			
		||||
 | 
			
		||||
      gl_int_format = val;
 | 
			
		||||
 | 
			
		||||
      /* If we can query GL for the actual pixel format then we'll ignore
 | 
			
		||||
         the passed in format and use that. */
 | 
			
		||||
      if (!ctx->driver_vtable->pixel_format_from_gl_internal (ctx,
 | 
			
		||||
                                                              gl_int_format,
 | 
			
		||||
                                                              &format))
 | 
			
		||||
        {
 | 
			
		||||
          _cogl_set_error (error,
 | 
			
		||||
                           COGL_SYSTEM_ERROR,
 | 
			
		||||
                           COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                           "Unsupported internal format for foreign texture");
 | 
			
		||||
          return FALSE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
#endif
 | 
			
		||||
    {
 | 
			
		||||
      /* Otherwise we'll assume we can derive the GL format from the
 | 
			
		||||
         passed in format */
 | 
			
		||||
      ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                              format,
 | 
			
		||||
                                              &gl_int_format,
 | 
			
		||||
                                              NULL,
 | 
			
		||||
                                              NULL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Compressed texture images not supported */
 | 
			
		||||
  if (gl_compressed == GL_TRUE)
 | 
			
		||||
    {
 | 
			
		||||
      _cogl_set_error (error,
 | 
			
		||||
                       COGL_SYSTEM_ERROR,
 | 
			
		||||
                       COGL_SYSTEM_ERROR_UNSUPPORTED,
 | 
			
		||||
                       "Compressed foreign textures aren't currently supported");
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Setup bitmap info */
 | 
			
		||||
  tex_rect->is_foreign = TRUE;
 | 
			
		||||
 | 
			
		||||
  tex_rect->gl_texture = loader->src.gl_foreign.gl_handle;
 | 
			
		||||
  tex_rect->gl_format = gl_int_format;
 | 
			
		||||
 | 
			
		||||
  /* Unknown filter */
 | 
			
		||||
  tex_rect->gl_legacy_texobj_min_filter = GL_FALSE;
 | 
			
		||||
  tex_rect->gl_legacy_texobj_mag_filter = GL_FALSE;
 | 
			
		||||
 | 
			
		||||
  tex_rect->internal_format = format;
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
 | 
			
		||||
                               format,
 | 
			
		||||
                               loader->src.gl_foreign.width,
 | 
			
		||||
                               loader->src.gl_foreign.height);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_allocate (CoglTexture *tex,
 | 
			
		||||
                                  CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
 | 
			
		||||
  CoglTextureLoader *loader = tex->loader;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
 | 
			
		||||
 | 
			
		||||
  switch (loader->src_type)
 | 
			
		||||
    {
 | 
			
		||||
    case COGL_TEXTURE_SOURCE_TYPE_SIZED:
 | 
			
		||||
      return allocate_with_size (tex_rect, loader, error);
 | 
			
		||||
    case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
 | 
			
		||||
      return allocate_from_bitmap (tex_rect, loader, error);
 | 
			
		||||
    case COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN:
 | 
			
		||||
      return allocate_from_gl_foreign (tex_rect, loader, error);
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_return_val_if_reached (FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureLoader *loader;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
 | 
			
		||||
 | 
			
		||||
  loader = _cogl_texture_create_loader ();
 | 
			
		||||
  loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
 | 
			
		||||
  loader->src.bitmap.bitmap = cogl_object_ref (bmp);
 | 
			
		||||
  loader->src.bitmap.can_convert_in_place = FALSE; /* TODO add api for this */
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_rectangle_create_base (_cogl_bitmap_get_context (bmp),
 | 
			
		||||
                                              cogl_bitmap_get_width (bmp),
 | 
			
		||||
                                              cogl_bitmap_get_height (bmp),
 | 
			
		||||
                                              cogl_bitmap_get_format (bmp),
 | 
			
		||||
                                              loader);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
 | 
			
		||||
                                         unsigned int gl_handle,
 | 
			
		||||
                                         int width,
 | 
			
		||||
                                         int height,
 | 
			
		||||
                                         CoglPixelFormat format)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureLoader *loader;
 | 
			
		||||
 | 
			
		||||
  /* NOTE: width, height and internal format are not queriable in
 | 
			
		||||
   * GLES, hence such a function prototype. Also in the case of full
 | 
			
		||||
   * opengl the user may be creating a Cogl texture for a
 | 
			
		||||
   * texture_from_pixmap object where glTexImage2D may not have been
 | 
			
		||||
   * called and the texture_from_pixmap spec doesn't clarify that it
 | 
			
		||||
   * is reliable to query back the size from OpenGL.
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  /* Assert that it is a valid GL texture object */
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (ctx->glIsTexture (gl_handle), NULL);
 | 
			
		||||
 | 
			
		||||
  /* Validate width and height */
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (width > 0 && height > 0, NULL);
 | 
			
		||||
 | 
			
		||||
  loader = _cogl_texture_create_loader ();
 | 
			
		||||
  loader->src_type = COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN;
 | 
			
		||||
  loader->src.gl_foreign.gl_handle = gl_handle;
 | 
			
		||||
  loader->src.gl_foreign.width = width;
 | 
			
		||||
  loader->src.gl_foreign.height = height;
 | 
			
		||||
  loader->src.gl_foreign.format = format;
 | 
			
		||||
 | 
			
		||||
  return _cogl_texture_rectangle_create_base (ctx, width, height,
 | 
			
		||||
                                              format, loader);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
_cogl_texture_rectangle_get_max_waste (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_is_sliced (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_can_hardware_repeat (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_transform_coords_to_gl (CoglTexture *tex,
 | 
			
		||||
                                                float *s,
 | 
			
		||||
                                                float *t)
 | 
			
		||||
{
 | 
			
		||||
  *s *= tex->width;
 | 
			
		||||
  *t *= tex->height;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTransformResult
 | 
			
		||||
_cogl_texture_rectangle_transform_quad_coords_to_gl (CoglTexture *tex,
 | 
			
		||||
                                                     float *coords)
 | 
			
		||||
{
 | 
			
		||||
  gboolean need_repeat = FALSE;
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < 4; i++)
 | 
			
		||||
    {
 | 
			
		||||
      if (coords[i] < 0.0f || coords[i] > 1.0f)
 | 
			
		||||
        need_repeat = TRUE;
 | 
			
		||||
      coords[i] *= (i & 1) ? tex->height : tex->width;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return (need_repeat ? COGL_TRANSFORM_SOFTWARE_REPEAT
 | 
			
		||||
          : COGL_TRANSFORM_NO_REPEAT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_get_gl_texture (CoglTexture *tex,
 | 
			
		||||
                                        GLuint *out_gl_handle,
 | 
			
		||||
                                        GLenum *out_gl_target)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
 | 
			
		||||
 | 
			
		||||
  if (out_gl_handle)
 | 
			
		||||
    *out_gl_handle = tex_rect->gl_texture;
 | 
			
		||||
 | 
			
		||||
  if (out_gl_target)
 | 
			
		||||
    *out_gl_target = GL_TEXTURE_RECTANGLE_ARB;
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_gl_flush_legacy_texobj_filters (CoglTexture *tex,
 | 
			
		||||
                                                        GLenum min_filter,
 | 
			
		||||
                                                        GLenum mag_filter)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
 | 
			
		||||
  if (min_filter == tex_rect->gl_legacy_texobj_min_filter
 | 
			
		||||
      && mag_filter == tex_rect->gl_legacy_texobj_mag_filter)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  /* Rectangle textures don't support mipmapping */
 | 
			
		||||
  g_assert (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
 | 
			
		||||
 | 
			
		||||
  /* Store new values */
 | 
			
		||||
  tex_rect->gl_legacy_texobj_min_filter = min_filter;
 | 
			
		||||
  tex_rect->gl_legacy_texobj_mag_filter = mag_filter;
 | 
			
		||||
 | 
			
		||||
  /* Apply new filters to the texture */
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                   tex_rect->gl_texture,
 | 
			
		||||
                                   tex_rect->is_foreign);
 | 
			
		||||
  GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
 | 
			
		||||
                            mag_filter) );
 | 
			
		||||
  GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
 | 
			
		||||
                            min_filter) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_pre_paint (CoglTexture *tex,
 | 
			
		||||
                                   CoglTexturePrePaintFlags flags)
 | 
			
		||||
{
 | 
			
		||||
  /* Rectangle textures don't support mipmaps */
 | 
			
		||||
  g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_rectangle_ensure_non_quad_rendering (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  /* Nothing needs to be done */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_set_region (CoglTexture *tex,
 | 
			
		||||
                                    int src_x,
 | 
			
		||||
                                    int src_y,
 | 
			
		||||
                                    int dst_x,
 | 
			
		||||
                                    int dst_y,
 | 
			
		||||
                                    int dst_width,
 | 
			
		||||
                                    int dst_height,
 | 
			
		||||
                                    int level,
 | 
			
		||||
                                    CoglBitmap *bmp,
 | 
			
		||||
                                    CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglBitmap *upload_bmp;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  gboolean status;
 | 
			
		||||
 | 
			
		||||
  upload_bmp =
 | 
			
		||||
    _cogl_bitmap_convert_for_upload (bmp,
 | 
			
		||||
                                     _cogl_texture_get_format (tex),
 | 
			
		||||
                                     FALSE, /* can't convert in place */
 | 
			
		||||
                                     error);
 | 
			
		||||
  if (upload_bmp == NULL)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          cogl_bitmap_get_format (upload_bmp),
 | 
			
		||||
                                          NULL, /* internal format */
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  /* Send data to GL */
 | 
			
		||||
  status =
 | 
			
		||||
    ctx->texture_driver->upload_subregion_to_gl (ctx,
 | 
			
		||||
                                                 tex,
 | 
			
		||||
                                                 FALSE,
 | 
			
		||||
                                                 src_x, src_y,
 | 
			
		||||
                                                 dst_x, dst_y,
 | 
			
		||||
                                                 dst_width, dst_height,
 | 
			
		||||
                                                 level,
 | 
			
		||||
                                                 upload_bmp,
 | 
			
		||||
                                                 gl_format,
 | 
			
		||||
                                                 gl_type,
 | 
			
		||||
                                                 error);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (upload_bmp);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_get_data (CoglTexture *tex,
 | 
			
		||||
                                  CoglPixelFormat format,
 | 
			
		||||
                                  int rowstride,
 | 
			
		||||
                                  uint8_t *data)
 | 
			
		||||
{
 | 
			
		||||
  CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
 | 
			
		||||
  CoglContext *ctx = tex->context;
 | 
			
		||||
  int bpp;
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          format,
 | 
			
		||||
                                          NULL, /* internal format */
 | 
			
		||||
                                          &gl_format,
 | 
			
		||||
                                          &gl_type);
 | 
			
		||||
 | 
			
		||||
  ctx->texture_driver->prep_gl_for_pixels_download (ctx,
 | 
			
		||||
                                                    rowstride,
 | 
			
		||||
                                                    tex->width,
 | 
			
		||||
                                                    bpp);
 | 
			
		||||
 | 
			
		||||
  _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                   tex_rect->gl_texture,
 | 
			
		||||
                                   tex_rect->is_foreign);
 | 
			
		||||
  return ctx->texture_driver->gl_get_tex_image (ctx,
 | 
			
		||||
                                                GL_TEXTURE_RECTANGLE_ARB,
 | 
			
		||||
                                                gl_format,
 | 
			
		||||
                                                gl_type,
 | 
			
		||||
                                                data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglPixelFormat
 | 
			
		||||
_cogl_texture_rectangle_get_format (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_RECTANGLE (tex)->internal_format;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GLenum
 | 
			
		||||
_cogl_texture_rectangle_get_gl_format (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_RECTANGLE (tex)->gl_format;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_rectangle_is_foreign (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_RECTANGLE (tex)->is_foreign;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_texture_rectangle_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  return COGL_TEXTURE_TYPE_RECTANGLE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const CoglTextureVtable
 | 
			
		||||
cogl_texture_rectangle_vtable =
 | 
			
		||||
  {
 | 
			
		||||
    TRUE, /* primitive */
 | 
			
		||||
    _cogl_texture_rectangle_allocate,
 | 
			
		||||
    _cogl_texture_rectangle_set_region,
 | 
			
		||||
    NULL, /* is_get_data_supported */
 | 
			
		||||
    _cogl_texture_rectangle_get_data,
 | 
			
		||||
    NULL, /* foreach_sub_texture_in_region */
 | 
			
		||||
    _cogl_texture_rectangle_get_max_waste,
 | 
			
		||||
    _cogl_texture_rectangle_is_sliced,
 | 
			
		||||
    _cogl_texture_rectangle_can_hardware_repeat,
 | 
			
		||||
    _cogl_texture_rectangle_transform_coords_to_gl,
 | 
			
		||||
    _cogl_texture_rectangle_transform_quad_coords_to_gl,
 | 
			
		||||
    _cogl_texture_rectangle_get_gl_texture,
 | 
			
		||||
    _cogl_texture_rectangle_gl_flush_legacy_texobj_filters,
 | 
			
		||||
    _cogl_texture_rectangle_pre_paint,
 | 
			
		||||
    _cogl_texture_rectangle_ensure_non_quad_rendering,
 | 
			
		||||
    _cogl_texture_rectangle_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_texture_rectangle_get_format,
 | 
			
		||||
    _cogl_texture_rectangle_get_gl_format,
 | 
			
		||||
    _cogl_texture_rectangle_get_type,
 | 
			
		||||
    _cogl_texture_rectangle_is_foreign,
 | 
			
		||||
    _cogl_texture_rectangle_set_auto_mipmap
 | 
			
		||||
  };
 | 
			
		||||
@@ -1,216 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Cogl
 | 
			
		||||
 *
 | 
			
		||||
 * A Low Level GPU Graphics and Utilities API
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2011 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person
 | 
			
		||||
 * obtaining a copy of this software and associated documentation
 | 
			
		||||
 * files (the "Software"), to deal in the Software without
 | 
			
		||||
 * restriction, including without limitation the rights to use, copy,
 | 
			
		||||
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
			
		||||
 * of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 | 
			
		||||
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 | 
			
		||||
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 | 
			
		||||
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
 * SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *   Robert Bragg <robert@linux.intel.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __COGL_TEXURE_RECTANGLE_H
 | 
			
		||||
#define __COGL_TEXURE_RECTANGLE_H
 | 
			
		||||
 | 
			
		||||
#include "cogl-context.h"
 | 
			
		||||
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SECTION:cogl-texture-rectangle
 | 
			
		||||
 * @short_description: Functions for creating and manipulating rectangle
 | 
			
		||||
 *                     textures for use with non-normalized coordinates.
 | 
			
		||||
 *
 | 
			
		||||
 * These functions allow low-level "rectangle" textures to be allocated.
 | 
			
		||||
 * These textures are never constrained to power-of-two sizes but they
 | 
			
		||||
 * also don't support having a mipmap and can only be wrapped with
 | 
			
		||||
 * %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE.
 | 
			
		||||
 *
 | 
			
		||||
 * The most notable difference between rectangle textures and 2D
 | 
			
		||||
 * textures is that rectangle textures are sampled using un-normalized
 | 
			
		||||
 * texture coordinates, so instead of using coordinates (0,0) and
 | 
			
		||||
 * (1,1) to map to the top-left and bottom right corners of the
 | 
			
		||||
 * texture you would instead use (0,0) and (width,height).
 | 
			
		||||
 *
 | 
			
		||||
 * The use of non-normalized coordinates can be particularly
 | 
			
		||||
 * convenient when writing glsl shaders that use a texture as a lookup
 | 
			
		||||
 * table since you don't need to upload separate uniforms to map
 | 
			
		||||
 * normalized coordinates to texels.
 | 
			
		||||
 *
 | 
			
		||||
 * If you want to sample from a rectangle texture from GLSL you should
 | 
			
		||||
 * use the sampler2DRect sampler type.
 | 
			
		||||
 *
 | 
			
		||||
 * Applications wanting to use #CoglTextureRectangle should first check
 | 
			
		||||
 * for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature using
 | 
			
		||||
 * cogl_has_feature().
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
typedef struct _CoglTextureRectangle CoglTextureRectangle;
 | 
			
		||||
#define COGL_TEXTURE_RECTANGLE(X) ((CoglTextureRectangle *)X)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_rectangle_get_gtype:
 | 
			
		||||
 *
 | 
			
		||||
 * Returns: a #GType that can be used with the GLib type system.
 | 
			
		||||
 */
 | 
			
		||||
GType cogl_texture_rectangle_get_gtype (void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_is_texture_rectangle:
 | 
			
		||||
 * @object: A #CoglObject
 | 
			
		||||
 *
 | 
			
		||||
 * Gets whether the given object references an existing
 | 
			
		||||
 * #CoglTextureRectangle object.
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: %TRUE if the object references a
 | 
			
		||||
 *               #CoglTextureRectangle, %FALSE otherwise.
 | 
			
		||||
 */
 | 
			
		||||
gboolean
 | 
			
		||||
cogl_is_texture_rectangle (void *object);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_rectangle_new_with_size:
 | 
			
		||||
 * @ctx: A #CoglContext pointer
 | 
			
		||||
 * @width: The texture width to allocate
 | 
			
		||||
 * @height: The texture height to allocate
 | 
			
		||||
 *
 | 
			
		||||
 * Creates a new #CoglTextureRectangle texture with a given @width,
 | 
			
		||||
 * and @height. This texture is a low-level texture that the GPU can
 | 
			
		||||
 * sample from directly unlike high-level textures such as
 | 
			
		||||
 * #CoglTexture2DSliced and #CoglAtlasTexture.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Unlike for #CoglTexture2D textures, coordinates for
 | 
			
		||||
 * #CoglTextureRectangle textures should not be normalized. So instead
 | 
			
		||||
 * of using the coordinate (1, 1) to sample the bottom right corner of
 | 
			
		||||
 * a rectangle texture you would use (@width, @height) where @width
 | 
			
		||||
 * and @height are the width and height of the texture.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>If you want to sample from a rectangle texture from GLSL you
 | 
			
		||||
 * should use the sampler2DRect sampler type.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Applications wanting to use #CoglTextureRectangle should
 | 
			
		||||
 * first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
 | 
			
		||||
 * using cogl_has_feature().</note>
 | 
			
		||||
 *
 | 
			
		||||
 * The storage for the texture is not allocated before this function
 | 
			
		||||
 * returns. You can call cogl_texture_allocate() to explicitly
 | 
			
		||||
 * allocate the underlying storage or preferably let Cogl
 | 
			
		||||
 * automatically allocate storage lazily when it may know more about
 | 
			
		||||
 * how the texture is going to be used and can optimize how it is
 | 
			
		||||
 * allocated.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns value: (transfer full): A pointer to a new #CoglTextureRectangle
 | 
			
		||||
 *          object with no storage allocated yet.
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 */
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
 | 
			
		||||
                                      int width,
 | 
			
		||||
                                      int height);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_rectangle_new_from_bitmap:
 | 
			
		||||
 * @bitmap: A #CoglBitmap
 | 
			
		||||
 *
 | 
			
		||||
 * Allocates a new #CoglTextureRectangle texture which will be
 | 
			
		||||
 * initialized with the pixel data from @bitmap. This texture is a
 | 
			
		||||
 * low-level texture that the GPU can sample from directly unlike
 | 
			
		||||
 * high-level textures such as #CoglTexture2DSliced and
 | 
			
		||||
 * #CoglAtlasTexture.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Unlike for #CoglTexture2D textures, coordinates for
 | 
			
		||||
 * #CoglTextureRectangle textures should not be normalized. So instead
 | 
			
		||||
 * of using the coordinate (1, 1) to sample the bottom right corner of
 | 
			
		||||
 * a rectangle texture you would use (@width, @height) where @width
 | 
			
		||||
 * and @height are the width and height of the texture.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>If you want to sample from a rectangle texture from GLSL you
 | 
			
		||||
 * should use the sampler2DRect sampler type.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Applications wanting to use #CoglTextureRectangle should
 | 
			
		||||
 * first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
 | 
			
		||||
 * using cogl_has_feature().</note>
 | 
			
		||||
 *
 | 
			
		||||
 * The storage for the texture is not allocated before this function
 | 
			
		||||
 * returns. You can call cogl_texture_allocate() to explicitly
 | 
			
		||||
 * allocate the underlying storage or preferably let Cogl
 | 
			
		||||
 * automatically allocate storage lazily when it may know more about
 | 
			
		||||
 * how the texture is going to be used and can optimize how it is
 | 
			
		||||
 * allocated.
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): A pointer to a new
 | 
			
		||||
 *               #CoglTextureRectangle texture.
 | 
			
		||||
 * Since: 2.0
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 */
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_rectangle_new_from_foreign:
 | 
			
		||||
 * @ctx: A #CoglContext
 | 
			
		||||
 * @gl_handle: A GL handle for a GL_TEXTURE_RECTANGLE texture object
 | 
			
		||||
 * @width: Width of the foreign GL texture
 | 
			
		||||
 * @height: Height of the foreign GL texture
 | 
			
		||||
 * @format: The format of the texture
 | 
			
		||||
 *
 | 
			
		||||
 * Wraps an existing GL_TEXTURE_RECTANGLE texture object as a
 | 
			
		||||
 * #CoglTextureRectangle.  This can be used for integrating Cogl with
 | 
			
		||||
 * software using OpenGL directly.
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Unlike for #CoglTexture2D textures, coordinates for
 | 
			
		||||
 * #CoglTextureRectangle textures should not be normalized. So instead
 | 
			
		||||
 * of using the coordinate (1, 1) to sample the bottom right corner of
 | 
			
		||||
 * a rectangle texture you would use (@width, @height) where @width
 | 
			
		||||
 * and @height are the width and height of the texture.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>The results are undefined for passing an invalid @gl_handle
 | 
			
		||||
 * or if @width or @height don't have the correct texture
 | 
			
		||||
 * geometry.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>If you want to sample from a rectangle texture from GLSL you
 | 
			
		||||
 * should use the sampler2DRect sampler type.</note>
 | 
			
		||||
 *
 | 
			
		||||
 * <note>Applications wanting to use #CoglTextureRectangle should
 | 
			
		||||
 * first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
 | 
			
		||||
 * using cogl_has_feature().</note>
 | 
			
		||||
 *
 | 
			
		||||
 * The texture is still configurable until it has been allocated so
 | 
			
		||||
 * for example you can declare whether the texture is premultiplied
 | 
			
		||||
 * with cogl_texture_set_premultiplied().
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): A new #CoglTextureRectangle texture
 | 
			
		||||
 */
 | 
			
		||||
CoglTextureRectangle *
 | 
			
		||||
cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
 | 
			
		||||
                                         unsigned int gl_handle,
 | 
			
		||||
                                         int width,
 | 
			
		||||
                                         int height,
 | 
			
		||||
                                         CoglPixelFormat format);
 | 
			
		||||
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* __COGL_TEXURE_RECTANGLE_H */
 | 
			
		||||
@@ -47,8 +47,6 @@
 | 
			
		||||
#include "cogl-texture-2d-sliced-private.h"
 | 
			
		||||
#include "cogl-texture-2d-private.h"
 | 
			
		||||
#include "cogl-texture-2d-gl.h"
 | 
			
		||||
#include "cogl-texture-3d-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-sub-texture-private.h"
 | 
			
		||||
#include "cogl-atlas-texture-private.h"
 | 
			
		||||
#include "cogl-pipeline.h"
 | 
			
		||||
@@ -245,12 +243,6 @@ _cogl_texture_get_n_levels (CoglTexture *texture)
 | 
			
		||||
  int height = cogl_texture_get_height (texture);
 | 
			
		||||
  int max_dimension = MAX (width, height);
 | 
			
		||||
 | 
			
		||||
  if (cogl_is_texture_3d (texture))
 | 
			
		||||
    {
 | 
			
		||||
      CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture);
 | 
			
		||||
      max_dimension = MAX (max_dimension, tex_3d->depth);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return _cogl_util_fls (max_dimension);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -263,17 +255,9 @@ _cogl_texture_get_level_size (CoglTexture *texture,
 | 
			
		||||
{
 | 
			
		||||
  int current_width = cogl_texture_get_width (texture);
 | 
			
		||||
  int current_height = cogl_texture_get_height (texture);
 | 
			
		||||
  int current_depth;
 | 
			
		||||
  int current_depth = 0;
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  if (cogl_is_texture_3d (texture))
 | 
			
		||||
    {
 | 
			
		||||
      CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture);
 | 
			
		||||
      current_depth = tex_3d->depth;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    current_depth = 0;
 | 
			
		||||
 | 
			
		||||
  /* NB: The OpenGL spec (like D3D) uses a floor() convention to
 | 
			
		||||
   * round down the size of a mipmap level when dividing the size
 | 
			
		||||
   * of the previous level results in a fraction...
 | 
			
		||||
@@ -343,12 +327,6 @@ cogl_texture_get_gl_texture (CoglTexture *texture,
 | 
			
		||||
                                          out_gl_handle, out_gl_target);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTextureType
 | 
			
		||||
_cogl_texture_get_type (CoglTexture *texture)
 | 
			
		||||
{
 | 
			
		||||
  return texture->vtable->get_type (texture);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -107,25 +107,6 @@ typedef enum
 | 
			
		||||
  COGL_TEXTURE_ERROR_TYPE
 | 
			
		||||
} CoglTextureError;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CoglTextureType:
 | 
			
		||||
 * @COGL_TEXTURE_TYPE_2D: A #CoglTexture2D
 | 
			
		||||
 * @COGL_TEXTURE_TYPE_3D: A #CoglTexture3D
 | 
			
		||||
 * @COGL_TEXTURE_TYPE_RECTANGLE: A #CoglTextureRectangle
 | 
			
		||||
 *
 | 
			
		||||
 * Constants representing the underlying hardware texture type of a
 | 
			
		||||
 * #CoglTexture.
 | 
			
		||||
 *
 | 
			
		||||
 * Stability: unstable
 | 
			
		||||
 * Since: 1.10
 | 
			
		||||
 */
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  COGL_TEXTURE_TYPE_2D,
 | 
			
		||||
  COGL_TEXTURE_TYPE_3D,
 | 
			
		||||
  COGL_TEXTURE_TYPE_RECTANGLE
 | 
			
		||||
} CoglTextureType;
 | 
			
		||||
 | 
			
		||||
uint32_t cogl_texture_error_quark (void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -315,14 +315,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CoglFeatureFlags:
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_NPOT: Non power of two textures are supported
 | 
			
		||||
 *    by the hardware. This is a equivalent to the
 | 
			
		||||
 *    %COGL_FEATURE_TEXTURE_NPOT_BASIC, %COGL_FEATURE_TEXTURE_NPOT_MIPMAP
 | 
			
		||||
 *    and %COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined.
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
 | 
			
		||||
 * @COGL_FEATURE_SHADERS_GLSL: GLSL support
 | 
			
		||||
 * @COGL_FEATURE_OFFSCREEN: FBO support
 | 
			
		||||
 * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs
 | 
			
		||||
 * @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs
 | 
			
		||||
@@ -334,20 +328,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
 | 
			
		||||
 *     %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
 | 
			
		||||
 *     cogl_vertex_buffer_indices_new().
 | 
			
		||||
 * @COGL_FEATURE_DEPTH_RANGE: cogl_material_set_depth_range() support
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_NPOT_BASIC: The hardware supports non power
 | 
			
		||||
 *     of two textures, but you also need to check the
 | 
			
		||||
 *     %COGL_FEATURE_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_TEXTURE_NPOT_REPEAT
 | 
			
		||||
 *     features to know if the hardware supports npot texture mipmaps
 | 
			
		||||
 *     or repeat modes other than
 | 
			
		||||
 *     %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
 | 
			
		||||
 *     conjuntion with non power of two textures.
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_NPOT_REPEAT: Repeat modes other than
 | 
			
		||||
 *     %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the
 | 
			
		||||
 *     hardware.
 | 
			
		||||
 * @COGL_FEATURE_POINT_SPRITE: Whether
 | 
			
		||||
 *     cogl_material_set_layer_point_sprite_coords_enabled() is supported.
 | 
			
		||||
 * @COGL_FEATURE_TEXTURE_3D: 3D texture support
 | 
			
		||||
 * @COGL_FEATURE_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is
 | 
			
		||||
 *     supported with CoglBufferAccess including read support.
 | 
			
		||||
 * @COGL_FEATURE_MAP_BUFFER_FOR_WRITE: Whether cogl_buffer_map() is
 | 
			
		||||
@@ -361,11 +343,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
 | 
			
		||||
 */
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  COGL_FEATURE_TEXTURE_RECTANGLE      = (1 << 1),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_NPOT           = (1 << 2),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_YUV            = (1 << 3),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_READ_PIXELS    = (1 << 4),
 | 
			
		||||
  COGL_FEATURE_SHADERS_GLSL           = (1 << 5),
 | 
			
		||||
  COGL_FEATURE_OFFSCREEN              = (1 << 6),
 | 
			
		||||
  COGL_FEATURE_OFFSCREEN_MULTISAMPLE  = (1 << 7),
 | 
			
		||||
  COGL_FEATURE_OFFSCREEN_BLIT         = (1 << 8),
 | 
			
		||||
@@ -375,11 +354,7 @@ typedef enum
 | 
			
		||||
  COGL_FEATURE_PBOS		      = (1 << 12),
 | 
			
		||||
  COGL_FEATURE_UNSIGNED_INT_INDICES   = (1 << 13),
 | 
			
		||||
  COGL_FEATURE_DEPTH_RANGE            = (1 << 14),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_NPOT_BASIC     = (1 << 15),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_NPOT_MIPMAP    = (1 << 16),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_NPOT_REPEAT    = (1 << 17),
 | 
			
		||||
  COGL_FEATURE_POINT_SPRITE           = (1 << 18),
 | 
			
		||||
  COGL_FEATURE_TEXTURE_3D             = (1 << 19),
 | 
			
		||||
  COGL_FEATURE_MAP_BUFFER_FOR_READ    = (1 << 21),
 | 
			
		||||
  COGL_FEATURE_MAP_BUFFER_FOR_WRITE   = (1 << 22),
 | 
			
		||||
  COGL_FEATURE_ONSCREEN_MULTIPLE      = (1 << 23),
 | 
			
		||||
@@ -559,9 +534,7 @@ cogl_blend_string_error_quark (void);
 | 
			
		||||
 *
 | 
			
		||||
 * <itemizedlist>
 | 
			
		||||
 *  <listitem><para>You've tried to use a feature that is not
 | 
			
		||||
 *   advertised by cogl_has_feature(). This could happen if you create
 | 
			
		||||
 *   a 2d texture with a non-power-of-two size when
 | 
			
		||||
 *   %COGL_FEATURE_ID_TEXTURE_NPOT is not advertised.</para></listitem>
 | 
			
		||||
 *   advertised by cogl_has_feature().</para></listitem>
 | 
			
		||||
 *  <listitem><para>The GPU can not handle the configuration you have
 | 
			
		||||
 *   requested. An example might be if you try to use too many texture
 | 
			
		||||
 *   layers in a single #CoglPipeline</para></listitem>
 | 
			
		||||
 
 | 
			
		||||
@@ -105,8 +105,6 @@
 | 
			
		||||
#include <cogl/cogl-quaternion.h>
 | 
			
		||||
#include <cogl/cogl-texture-2d.h>
 | 
			
		||||
#include <cogl/cogl-texture-2d-gl.h>
 | 
			
		||||
#include <cogl/cogl-texture-rectangle.h>
 | 
			
		||||
#include <cogl/cogl-texture-3d.h>
 | 
			
		||||
#include <cogl/cogl-texture-2d-sliced.h>
 | 
			
		||||
#include <cogl/cogl-sub-texture.h>
 | 
			
		||||
#include <cogl/cogl-atlas-texture.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -410,7 +410,6 @@ cogl_is_texture_pixmap_x11
 | 
			
		||||
#endif
 | 
			
		||||
cogl_is_texture_rectangle
 | 
			
		||||
cogl_is_texture_2d
 | 
			
		||||
cogl_is_texture_3d
 | 
			
		||||
 | 
			
		||||
cogl_material_alpha_func_get_type
 | 
			
		||||
cogl_material_copy
 | 
			
		||||
@@ -909,7 +908,6 @@ cogl_texture_is_sliced
 | 
			
		||||
cogl_texture_new_from_bitmap
 | 
			
		||||
cogl_texture_new_from_data
 | 
			
		||||
cogl_texture_new_from_file
 | 
			
		||||
cogl_texture_new_from_foreign
 | 
			
		||||
cogl_texture_new_from_sub_texture
 | 
			
		||||
cogl_texture_new_with_size
 | 
			
		||||
#ifdef COGL_HAS_X11
 | 
			
		||||
@@ -954,12 +952,6 @@ cogl_texture_2d_sliced_new_from_bitmap
 | 
			
		||||
cogl_texture_2d_sliced_new_from_data
 | 
			
		||||
cogl_texture_2d_sliced_new_from_file
 | 
			
		||||
cogl_texture_2d_sliced_new_with_size
 | 
			
		||||
#ifdef COGL_HAS_GTYPE_SUPPORT
 | 
			
		||||
cogl_texture_3d_get_gtype
 | 
			
		||||
#endif
 | 
			
		||||
cogl_texture_3d_new_from_bitmap
 | 
			
		||||
cogl_texture_3d_new_from_data
 | 
			
		||||
cogl_texture_3d_new_with_size
 | 
			
		||||
 | 
			
		||||
cogl_transform
 | 
			
		||||
cogl_translate
 | 
			
		||||
 
 | 
			
		||||
@@ -48,7 +48,6 @@
 | 
			
		||||
#include "cogl-bitmap-private.h"
 | 
			
		||||
#include "cogl-atlas-texture-private.h"
 | 
			
		||||
#include "cogl-error-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle.h"
 | 
			
		||||
#include "cogl-sub-texture.h"
 | 
			
		||||
#include "cogl-texture-2d-gl.h"
 | 
			
		||||
 | 
			
		||||
@@ -82,25 +81,18 @@ cogl_texture_new_with_size (unsigned int width,
 | 
			
		||||
 | 
			
		||||
  _COGL_GET_CONTEXT (ctx, NULL);
 | 
			
		||||
 | 
			
		||||
  if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
 | 
			
		||||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
  tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
  if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
    {
 | 
			
		||||
      /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
      if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (skip_error);
 | 
			
		||||
          skip_error = NULL;
 | 
			
		||||
          cogl_object_unref (tex);
 | 
			
		||||
          tex = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      cogl_error_free (skip_error);
 | 
			
		||||
      skip_error = NULL;
 | 
			
		||||
      cogl_object_unref (tex);
 | 
			
		||||
      tex = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
@@ -210,7 +202,6 @@ _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
 | 
			
		||||
                               gboolean can_convert_in_place,
 | 
			
		||||
                               CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglContext *ctx = _cogl_bitmap_get_context (bitmap);
 | 
			
		||||
  CoglTexture *tex;
 | 
			
		||||
  CoglError *internal_error = NULL;
 | 
			
		||||
 | 
			
		||||
@@ -234,26 +225,18 @@ _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* If that doesn't work try a fast path 2D texture */
 | 
			
		||||
  if ((_cogl_util_is_pot (bitmap->width) &&
 | 
			
		||||
       _cogl_util_is_pot (bitmap->height)) ||
 | 
			
		||||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
 | 
			
		||||
                                                        can_convert_in_place));
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
  if (!cogl_texture_allocate (tex, &internal_error))
 | 
			
		||||
    {
 | 
			
		||||
      tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
 | 
			
		||||
                                                            can_convert_in_place));
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
      if (!cogl_texture_allocate (tex, &internal_error))
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (internal_error);
 | 
			
		||||
          internal_error = NULL;
 | 
			
		||||
          cogl_object_unref (tex);
 | 
			
		||||
          tex = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      cogl_error_free (internal_error);
 | 
			
		||||
      internal_error = NULL;
 | 
			
		||||
      cogl_object_unref (tex);
 | 
			
		||||
      tex = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
@@ -330,82 +313,6 @@ cogl_texture_new_from_file (const char        *filename,
 | 
			
		||||
  return texture;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTexture *
 | 
			
		||||
cogl_texture_new_from_foreign (GLuint           gl_handle,
 | 
			
		||||
			       GLenum           gl_target,
 | 
			
		||||
			       GLuint           width,
 | 
			
		||||
			       GLuint           height,
 | 
			
		||||
			       GLuint           x_pot_waste,
 | 
			
		||||
			       GLuint           y_pot_waste,
 | 
			
		||||
			       CoglPixelFormat  format)
 | 
			
		||||
{
 | 
			
		||||
  _COGL_GET_CONTEXT (ctx, NULL);
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_COGL_GL
 | 
			
		||||
  if (gl_target == GL_TEXTURE_RECTANGLE_ARB)
 | 
			
		||||
    {
 | 
			
		||||
      CoglTextureRectangle *texture_rectangle;
 | 
			
		||||
      CoglSubTexture *sub_texture;
 | 
			
		||||
 | 
			
		||||
      if (x_pot_waste != 0 || y_pot_waste != 0)
 | 
			
		||||
        {
 | 
			
		||||
          /* It shouldn't be necessary to have waste in this case since
 | 
			
		||||
           * the texture isn't limited to power of two sizes. */
 | 
			
		||||
          g_warning ("You can't create a foreign GL_TEXTURE_RECTANGLE cogl "
 | 
			
		||||
                     "texture with waste\n");
 | 
			
		||||
          return NULL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      texture_rectangle = cogl_texture_rectangle_new_from_foreign (ctx,
 | 
			
		||||
                                                                   gl_handle,
 | 
			
		||||
                                                                   width,
 | 
			
		||||
                                                                   height,
 | 
			
		||||
                                                                   format);
 | 
			
		||||
      _cogl_texture_set_internal_format (COGL_TEXTURE (texture_rectangle),
 | 
			
		||||
                                         format);
 | 
			
		||||
 | 
			
		||||
      /* CoglTextureRectangle textures work with non-normalized
 | 
			
		||||
       * coordinates, but the semantics for this function that people
 | 
			
		||||
       * depend on are that all returned texture works with normalized
 | 
			
		||||
       * coordinates so we wrap with a CoglSubTexture... */
 | 
			
		||||
      sub_texture = cogl_sub_texture_new (ctx,
 | 
			
		||||
                                          COGL_TEXTURE (texture_rectangle),
 | 
			
		||||
                                          0, 0, width, height);
 | 
			
		||||
      return COGL_TEXTURE (sub_texture);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  if (x_pot_waste != 0 || y_pot_waste != 0)
 | 
			
		||||
    {
 | 
			
		||||
      CoglTexture *tex =
 | 
			
		||||
        COGL_TEXTURE (_cogl_texture_2d_sliced_new_from_foreign (ctx,
 | 
			
		||||
                                                                gl_handle,
 | 
			
		||||
                                                                gl_target,
 | 
			
		||||
                                                                width,
 | 
			
		||||
                                                                height,
 | 
			
		||||
                                                                x_pot_waste,
 | 
			
		||||
                                                                y_pot_waste,
 | 
			
		||||
                                                                format));
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, format);
 | 
			
		||||
 | 
			
		||||
      cogl_texture_allocate (tex, NULL);
 | 
			
		||||
      return tex;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      CoglTexture *tex =
 | 
			
		||||
        COGL_TEXTURE (cogl_texture_2d_gl_new_from_foreign (ctx,
 | 
			
		||||
                                                           gl_handle,
 | 
			
		||||
                                                           width,
 | 
			
		||||
                                                           height,
 | 
			
		||||
                                                           format));
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, format);
 | 
			
		||||
 | 
			
		||||
      cogl_texture_allocate (tex, NULL);
 | 
			
		||||
      return tex;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CoglTexture *
 | 
			
		||||
cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
 | 
			
		||||
                                   int sub_x,
 | 
			
		||||
 
 | 
			
		||||
@@ -125,44 +125,6 @@ cogl_texture_new_from_data (int width,
 | 
			
		||||
                            int rowstride,
 | 
			
		||||
                            const uint8_t *data);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_new_from_foreign:
 | 
			
		||||
 * @gl_handle: opengl handle of foreign texture.
 | 
			
		||||
 * @gl_target: opengl target type of foreign texture
 | 
			
		||||
 * @width: width of foreign texture
 | 
			
		||||
 * @height: height of foreign texture.
 | 
			
		||||
 * @x_pot_waste: horizontal waste on the right hand edge of the texture.
 | 
			
		||||
 * @y_pot_waste: vertical waste on the bottom edge of the texture.
 | 
			
		||||
 * @format: format of the foreign texture.
 | 
			
		||||
 *
 | 
			
		||||
 * Creates a #CoglTexture based on an existing OpenGL texture; the
 | 
			
		||||
 * width, height and format are passed along since it is not always
 | 
			
		||||
 * possible to query these from OpenGL.
 | 
			
		||||
 *
 | 
			
		||||
 * The waste arguments allow you to create a Cogl texture that maps to
 | 
			
		||||
 * a region smaller than the real OpenGL texture. For instance if your
 | 
			
		||||
 * hardware only supports power-of-two textures you may load a
 | 
			
		||||
 * non-power-of-two image into a larger power-of-two texture and use
 | 
			
		||||
 * the waste arguments to tell Cogl which region should be mapped to
 | 
			
		||||
 * the texture coordinate range [0:1].
 | 
			
		||||
 *
 | 
			
		||||
 * Return value: (transfer full): A newly created #CoglTexture or
 | 
			
		||||
 *               %NULL on failure
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 0.8
 | 
			
		||||
 * Deprecated: 1.18: Use specific constructors such as
 | 
			
		||||
 *                   cogl_texture_2d_new_from_foreign()
 | 
			
		||||
 */
 | 
			
		||||
COGL_DEPRECATED_FOR (cogl_texture_2d_new_from_foreign)
 | 
			
		||||
CoglTexture *
 | 
			
		||||
cogl_texture_new_from_foreign (unsigned int gl_handle,
 | 
			
		||||
                               unsigned int gl_target,
 | 
			
		||||
                               unsigned int width,
 | 
			
		||||
                               unsigned int height,
 | 
			
		||||
                               unsigned int x_pot_waste,
 | 
			
		||||
                               unsigned int y_pot_waste,
 | 
			
		||||
                               CoglPixelFormat format);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * cogl_texture_new_from_bitmap:
 | 
			
		||||
 * @bitmap: A #CoglBitmap pointer
 | 
			
		||||
 
 | 
			
		||||
@@ -756,10 +756,6 @@ cogl_material_get_user_program (CoglMaterial *material);
 | 
			
		||||
 * meantime we hope this will handle most practical GLSL and ARBfp
 | 
			
		||||
 * requirements.
 | 
			
		||||
 *
 | 
			
		||||
 * Also remember you need to check for either the
 | 
			
		||||
 * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
 | 
			
		||||
 * using the cogl_program or cogl_shader API.
 | 
			
		||||
 *
 | 
			
		||||
 * Since: 1.4
 | 
			
		||||
 * Deprecated: 1.16: Use #CoglSnippet api instead instead
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -48,11 +48,6 @@ G_BEGIN_DECLS
 | 
			
		||||
 * Cogl allows accessing the GL programmable pipeline in order to create
 | 
			
		||||
 * vertex and fragment shaders.
 | 
			
		||||
 *
 | 
			
		||||
 * The shader source code can either be GLSL or ARBfp. If the source
 | 
			
		||||
 * code is ARBfp, it must begin with the string “!!ARBfp1.0”. The
 | 
			
		||||
 * application should check for the %COGL_FEATURE_SHADERS_GLSL or
 | 
			
		||||
 * %COGL_FEATURE_SHADERS_ARBFP features before using shaders.
 | 
			
		||||
 *
 | 
			
		||||
 * When using GLSL Cogl provides replacement names for most of the
 | 
			
		||||
 * builtin varyings and uniforms. It is recommended to use these names
 | 
			
		||||
 * wherever possible to increase portability between OpenGL 2.0 and
 | 
			
		||||
 
 | 
			
		||||
@@ -233,15 +233,9 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
 | 
			
		||||
                          void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineShaderState *shader_state = user_data;
 | 
			
		||||
  CoglTextureType texture_type =
 | 
			
		||||
    _cogl_pipeline_layer_get_texture_type (layer);
 | 
			
		||||
  const char *target_string;
 | 
			
		||||
 | 
			
		||||
  _cogl_gl_util_get_texture_target_string (texture_type, &target_string, NULL);
 | 
			
		||||
 | 
			
		||||
  g_string_append_printf (shader_state->header,
 | 
			
		||||
                          "uniform sampler%s cogl_sampler%i;\n",
 | 
			
		||||
                          target_string,
 | 
			
		||||
                          "uniform sampler2D cogl_sampler%i;\n",
 | 
			
		||||
                          layer->index);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
@@ -411,20 +405,12 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
 | 
			
		||||
{
 | 
			
		||||
  int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
 | 
			
		||||
  CoglPipelineSnippetData snippet_data;
 | 
			
		||||
  CoglTextureType texture_type;
 | 
			
		||||
  const char *target_string, *tex_coord_swizzle;
 | 
			
		||||
 | 
			
		||||
  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
 | 
			
		||||
 | 
			
		||||
  if (shader_state->unit_state[unit_index].sampled)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  texture_type =
 | 
			
		||||
    _cogl_pipeline_layer_get_texture_type (layer);
 | 
			
		||||
  _cogl_gl_util_get_texture_target_string (texture_type,
 | 
			
		||||
                                           &target_string,
 | 
			
		||||
                                           &tex_coord_swizzle);
 | 
			
		||||
 | 
			
		||||
  shader_state->unit_state[unit_index].sampled = TRUE;
 | 
			
		||||
 | 
			
		||||
  g_string_append_printf (shader_state->header,
 | 
			
		||||
@@ -455,20 +441,18 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
 | 
			
		||||
    {
 | 
			
		||||
      g_string_append_printf (shader_state->header,
 | 
			
		||||
                              "vec4\n"
 | 
			
		||||
                              "cogl_real_texture_lookup%i (sampler%s tex,\n"
 | 
			
		||||
                              "cogl_real_texture_lookup%i (sampler2D tex,\n"
 | 
			
		||||
                              "                            vec4 coords)\n"
 | 
			
		||||
                              "{\n"
 | 
			
		||||
                              "  return ",
 | 
			
		||||
                              layer->index,
 | 
			
		||||
                              target_string);
 | 
			
		||||
                              layer->index);
 | 
			
		||||
 | 
			
		||||
      if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
 | 
			
		||||
        g_string_append (shader_state->header,
 | 
			
		||||
                         "vec4 (1.0, 1.0, 1.0, 1.0);\n");
 | 
			
		||||
      else
 | 
			
		||||
        g_string_append_printf (shader_state->header,
 | 
			
		||||
                                "texture%s (tex, coords.%s);\n",
 | 
			
		||||
                                target_string, tex_coord_swizzle);
 | 
			
		||||
        g_string_append (shader_state->header,
 | 
			
		||||
                         "texture2D (tex, coords.st);\n");
 | 
			
		||||
 | 
			
		||||
      g_string_append (shader_state->header, "}\n");
 | 
			
		||||
    }
 | 
			
		||||
@@ -487,8 +471,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
 | 
			
		||||
  snippet_data.return_variable = "cogl_texel";
 | 
			
		||||
  snippet_data.arguments = "cogl_sampler, cogl_tex_coord";
 | 
			
		||||
  snippet_data.argument_declarations =
 | 
			
		||||
    g_strdup_printf ("sampler%s cogl_sampler, vec4 cogl_tex_coord",
 | 
			
		||||
                     target_string);
 | 
			
		||||
    g_strdup ("sampler2D cogl_sampler, vec4 cogl_tex_coord");
 | 
			
		||||
  snippet_data.source_buf = shader_state->header;
 | 
			
		||||
 | 
			
		||||
  _cogl_pipeline_snippet_generate_code (&snippet_data);
 | 
			
		||||
 
 | 
			
		||||
@@ -673,22 +673,13 @@ get_max_activateable_texture_units (void)
 | 
			
		||||
#ifdef HAVE_COGL_GL
 | 
			
		||||
      if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED))
 | 
			
		||||
        {
 | 
			
		||||
          /* GL_MAX_TEXTURE_COORDS is provided for both GLSL and ARBfp. It
 | 
			
		||||
             defines the number of texture coordinates that can be
 | 
			
		||||
             uploaded (but doesn't necessarily relate to how many texture
 | 
			
		||||
             images can be sampled) */
 | 
			
		||||
          if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
            /* Previously this code subtracted the value by one but there
 | 
			
		||||
               was no explanation for why it did this and it doesn't seem
 | 
			
		||||
               to make sense so it has been removed */
 | 
			
		||||
            GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_COORDS,
 | 
			
		||||
                                    values + n_values++));
 | 
			
		||||
          /* GL_MAX_TEXTURE_COORDS defines the number of texture coordinates
 | 
			
		||||
           * that can be uploaded (but doesn't necessarily relate to how many
 | 
			
		||||
           * texture images can be sampled) */
 | 
			
		||||
          GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_COORDS, values + n_values++));
 | 
			
		||||
 | 
			
		||||
          /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but
 | 
			
		||||
             not ARBfp */
 | 
			
		||||
          if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
            GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
 | 
			
		||||
                                    values + n_values++));
 | 
			
		||||
          GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
 | 
			
		||||
                                  values + n_values++));
 | 
			
		||||
        }
 | 
			
		||||
#endif /* HAVE_COGL_GL */
 | 
			
		||||
 | 
			
		||||
@@ -773,18 +764,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
 | 
			
		||||
      GLenum gl_target;
 | 
			
		||||
 | 
			
		||||
      if (texture == NULL)
 | 
			
		||||
        switch (_cogl_pipeline_layer_get_texture_type (layer))
 | 
			
		||||
          {
 | 
			
		||||
          case COGL_TEXTURE_TYPE_2D:
 | 
			
		||||
            texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
 | 
			
		||||
            break;
 | 
			
		||||
          case COGL_TEXTURE_TYPE_3D:
 | 
			
		||||
            texture = COGL_TEXTURE (ctx->default_gl_texture_3d_tex);
 | 
			
		||||
            break;
 | 
			
		||||
          case COGL_TEXTURE_TYPE_RECTANGLE:
 | 
			
		||||
            texture = COGL_TEXTURE (ctx->default_gl_texture_rect_tex);
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
 | 
			
		||||
 | 
			
		||||
      cogl_texture_get_gl_texture (texture,
 | 
			
		||||
                                   &gl_texture,
 | 
			
		||||
 
 | 
			
		||||
@@ -644,9 +644,6 @@ _cogl_pipeline_progend_glsl_start (CoglPipeline *pipeline)
 | 
			
		||||
 | 
			
		||||
  _COGL_GET_CONTEXT (ctx, FALSE);
 | 
			
		||||
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  user_program = cogl_pipeline_get_user_program (pipeline);
 | 
			
		||||
  if (user_program &&
 | 
			
		||||
      _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL)
 | 
			
		||||
 
 | 
			
		||||
@@ -169,15 +169,9 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
 | 
			
		||||
                          void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipelineShaderState *shader_state = user_data;
 | 
			
		||||
  CoglTextureType texture_type =
 | 
			
		||||
    _cogl_pipeline_layer_get_texture_type (layer);
 | 
			
		||||
  const char *target_string;
 | 
			
		||||
 | 
			
		||||
  _cogl_gl_util_get_texture_target_string (texture_type, &target_string, NULL);
 | 
			
		||||
 | 
			
		||||
  g_string_append_printf (shader_state->header,
 | 
			
		||||
                          "uniform sampler%s cogl_sampler%i;\n",
 | 
			
		||||
                          target_string,
 | 
			
		||||
                          "uniform sampler2D cogl_sampler%i;\n",
 | 
			
		||||
                          layer->index);
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
 
 | 
			
		||||
@@ -83,13 +83,6 @@ _cogl_texture_2d_gl_can_create (CoglContext *ctx,
 | 
			
		||||
  GLenum gl_format;
 | 
			
		||||
  GLenum gl_type;
 | 
			
		||||
 | 
			
		||||
  /* If NPOT textures aren't supported then the size must be a power
 | 
			
		||||
     of two */
 | 
			
		||||
  if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
      (!_cogl_util_is_pot (width) ||
 | 
			
		||||
       !_cogl_util_is_pot (height)))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  ctx->driver_vtable->pixel_format_to_gl (ctx,
 | 
			
		||||
                                          internal_format,
 | 
			
		||||
                                          &gl_intformat,
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,6 @@
 | 
			
		||||
#include <strings.h>
 | 
			
		||||
 | 
			
		||||
#include "cogl-context-private.h"
 | 
			
		||||
#include "cogl-texture-3d-private.h"
 | 
			
		||||
#include "cogl-util.h"
 | 
			
		||||
#include "driver/gl/cogl-util-gl-private.h"
 | 
			
		||||
#include "driver/gl/cogl-texture-gl-private.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -85,11 +85,6 @@ _cogl_gl_util_clear_gl_errors (CoglContext *ctx);
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_gl_util_catch_out_of_memory (CoglContext *ctx, CoglError **error);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
 | 
			
		||||
                                         const char **target_string_out,
 | 
			
		||||
                                         const char **swizzle_out);
 | 
			
		||||
 | 
			
		||||
/* Parses a GL version number stored in a string. @version_string must
 | 
			
		||||
 * point to the beginning of the version number (ie, it can't point to
 | 
			
		||||
 * the "OpenGL ES" part on GLES). The version number can be followed
 | 
			
		||||
 
 | 
			
		||||
@@ -127,49 +127,6 @@ _cogl_gl_util_catch_out_of_memory (CoglContext *ctx, CoglError **error)
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
_cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
 | 
			
		||||
                                         const char **target_string_out,
 | 
			
		||||
                                         const char **swizzle_out)
 | 
			
		||||
{
 | 
			
		||||
  const char *target_string, *tex_coord_swizzle;
 | 
			
		||||
 | 
			
		||||
  switch (texture_type)
 | 
			
		||||
    {
 | 
			
		||||
#if 0 /* TODO */
 | 
			
		||||
    case COGL_TEXTURE_TYPE_1D:
 | 
			
		||||
      target_string = "1D";
 | 
			
		||||
      tex_coord_swizzle = "s";
 | 
			
		||||
      break;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_2D:
 | 
			
		||||
      target_string = "2D";
 | 
			
		||||
      tex_coord_swizzle = "st";
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_3D:
 | 
			
		||||
      target_string = "3D";
 | 
			
		||||
      tex_coord_swizzle = "stp";
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case COGL_TEXTURE_TYPE_RECTANGLE:
 | 
			
		||||
      target_string = "2DRect";
 | 
			
		||||
      tex_coord_swizzle = "st";
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      target_string = "Unknown";
 | 
			
		||||
      tex_coord_swizzle = NULL;
 | 
			
		||||
      g_assert_not_reached ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (target_string_out)
 | 
			
		||||
    *target_string_out = target_string;
 | 
			
		||||
  if (swizzle_out)
 | 
			
		||||
    *swizzle_out = tex_coord_swizzle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gboolean
 | 
			
		||||
_cogl_gl_util_parse_gl_version (const char *version_string,
 | 
			
		||||
                                int *major_out,
 | 
			
		||||
 
 | 
			
		||||
@@ -407,15 +407,6 @@ _cogl_driver_update_features (CoglContext *ctx,
 | 
			
		||||
                                     gl_minor,
 | 
			
		||||
                                     gl_extensions);
 | 
			
		||||
 | 
			
		||||
  flags |= COGL_FEATURE_TEXTURE_NPOT
 | 
			
		||||
    | COGL_FEATURE_TEXTURE_NPOT_BASIC
 | 
			
		||||
    | COGL_FEATURE_TEXTURE_NPOT_MIPMAP
 | 
			
		||||
    | COGL_FEATURE_TEXTURE_NPOT_REPEAT;
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, TRUE);
 | 
			
		||||
 | 
			
		||||
  if (_cogl_check_extension ("GL_MESA_pack_invert", gl_extensions))
 | 
			
		||||
    COGL_FLAGS_SET (private_features,
 | 
			
		||||
                    COGL_PRIVATE_FEATURE_MESA_PACK_INVERT, TRUE);
 | 
			
		||||
@@ -451,9 +442,6 @@ _cogl_driver_update_features (CoglContext *ctx,
 | 
			
		||||
  COGL_FLAGS_SET (private_features,
 | 
			
		||||
                  COGL_PRIVATE_FEATURE_BLEND_CONSTANT, TRUE);
 | 
			
		||||
 | 
			
		||||
  flags |= COGL_FEATURE_SHADERS_GLSL;
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_GLSL, TRUE);
 | 
			
		||||
 | 
			
		||||
  flags |= COGL_FEATURE_POINT_SPRITE;
 | 
			
		||||
  COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_POINT_SPRITE, TRUE);
 | 
			
		||||
 | 
			
		||||
@@ -468,19 +456,6 @@ _cogl_driver_update_features (CoglContext *ctx,
 | 
			
		||||
                      COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE, TRUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (_cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions))
 | 
			
		||||
    {
 | 
			
		||||
      flags |= COGL_FEATURE_TEXTURE_RECTANGLE;
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features,
 | 
			
		||||
                      COGL_FEATURE_ID_TEXTURE_RECTANGLE, TRUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (ctx->glTexImage3D)
 | 
			
		||||
    {
 | 
			
		||||
      flags |= COGL_FEATURE_TEXTURE_3D;
 | 
			
		||||
      COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_3D, TRUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (ctx->glEGLImageTargetTexture2D)
 | 
			
		||||
    COGL_FLAGS_SET (private_features,
 | 
			
		||||
                    COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE, TRUE);
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,6 @@ _cogl_texture_driver_gen (CoglContext *ctx,
 | 
			
		||||
  switch (gl_target)
 | 
			
		||||
    {
 | 
			
		||||
    case GL_TEXTURE_2D:
 | 
			
		||||
    case GL_TEXTURE_3D:
 | 
			
		||||
      /* In case automatic mipmap generation gets disabled for this
 | 
			
		||||
       * texture but a minification filter depending on mipmap
 | 
			
		||||
       * interpolation is selected then we initialize the max mipmap
 | 
			
		||||
@@ -131,9 +130,6 @@ prep_gl_for_pixels_upload_full (CoglContext *ctx,
 | 
			
		||||
  GE( ctx, glPixelStorei (GL_UNPACK_SKIP_PIXELS, pixels_src_x) );
 | 
			
		||||
  GE( ctx, glPixelStorei (GL_UNPACK_SKIP_ROWS, pixels_src_y) );
 | 
			
		||||
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    GE( ctx, glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) );
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_gl_prep_alignment_for_pixels_upload (ctx, pixels_rowstride);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -161,9 +157,6 @@ prep_gl_for_pixels_download_full (CoglContext *ctx,
 | 
			
		||||
  GE( ctx, glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) );
 | 
			
		||||
  GE( ctx, glPixelStorei (GL_PACK_SKIP_ROWS, pixels_src_y) );
 | 
			
		||||
 | 
			
		||||
  if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    GE( ctx, glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) );
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_gl_prep_alignment_for_pixels_download (ctx,
 | 
			
		||||
                                                       pixels_bpp,
 | 
			
		||||
                                                       image_width,
 | 
			
		||||
@@ -355,59 +348,6 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
 | 
			
		||||
                                      GLenum gl_target,
 | 
			
		||||
                                      GLuint gl_handle,
 | 
			
		||||
                                      gboolean is_foreign,
 | 
			
		||||
                                      GLint height,
 | 
			
		||||
                                      GLint depth,
 | 
			
		||||
                                      CoglBitmap *source_bmp,
 | 
			
		||||
                                      GLint internal_gl_format,
 | 
			
		||||
                                      GLuint source_gl_format,
 | 
			
		||||
                                      GLuint source_gl_type,
 | 
			
		||||
                                      CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t *data;
 | 
			
		||||
  CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
 | 
			
		||||
  int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
 | 
			
		||||
  gboolean status = TRUE;
 | 
			
		||||
 | 
			
		||||
  data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0, error);
 | 
			
		||||
  if (!data)
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  /* Setup gl alignment to match rowstride and top-left corner */
 | 
			
		||||
  prep_gl_for_pixels_upload_full (ctx,
 | 
			
		||||
                                  cogl_bitmap_get_rowstride (source_bmp),
 | 
			
		||||
                                  (cogl_bitmap_get_height (source_bmp) /
 | 
			
		||||
                                   depth),
 | 
			
		||||
                                  0, 0, bpp);
 | 
			
		||||
 | 
			
		||||
  _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
 | 
			
		||||
 | 
			
		||||
  /* Clear any GL errors */
 | 
			
		||||
  _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
  ctx->glTexImage3D (gl_target,
 | 
			
		||||
                     0, /* level */
 | 
			
		||||
                     internal_gl_format,
 | 
			
		||||
                     cogl_bitmap_get_width (source_bmp),
 | 
			
		||||
                     height,
 | 
			
		||||
                     depth,
 | 
			
		||||
                     0,
 | 
			
		||||
                     source_gl_format,
 | 
			
		||||
                     source_gl_type,
 | 
			
		||||
                     data);
 | 
			
		||||
 | 
			
		||||
  if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
    status = FALSE;
 | 
			
		||||
 | 
			
		||||
  _cogl_bitmap_gl_unbind (source_bmp);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_gl_get_tex_image (CoglContext *ctx,
 | 
			
		||||
                                       GLenum gl_target,
 | 
			
		||||
@@ -423,35 +363,6 @@ _cogl_texture_driver_gl_get_tex_image (CoglContext *ctx,
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_size_supported_3d (CoglContext *ctx,
 | 
			
		||||
                                        GLenum gl_target,
 | 
			
		||||
                                        GLenum gl_format,
 | 
			
		||||
                                        GLenum gl_type,
 | 
			
		||||
                                        int width,
 | 
			
		||||
                                        int height,
 | 
			
		||||
                                        int depth)
 | 
			
		||||
{
 | 
			
		||||
  GLenum proxy_target;
 | 
			
		||||
  GLint new_width = 0;
 | 
			
		||||
 | 
			
		||||
  if (gl_target == GL_TEXTURE_3D)
 | 
			
		||||
    proxy_target = GL_PROXY_TEXTURE_3D;
 | 
			
		||||
  else
 | 
			
		||||
    /* Unknown target, assume it's not supported */
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 | 
			
		||||
  /* Proxy texture allows for a quick check for supported size */
 | 
			
		||||
  GE( ctx, glTexImage3D (proxy_target, 0, GL_RGBA,
 | 
			
		||||
                         width, height, depth, 0 /* border */,
 | 
			
		||||
                         gl_format, gl_type, NULL) );
 | 
			
		||||
 | 
			
		||||
  GE( ctx, glGetTexLevelParameteriv (proxy_target, 0,
 | 
			
		||||
                                     GL_TEXTURE_WIDTH, &new_width) );
 | 
			
		||||
 | 
			
		||||
  return new_width != 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_size_supported (CoglContext *ctx,
 | 
			
		||||
                                     GLenum gl_target,
 | 
			
		||||
@@ -523,11 +434,9 @@ _cogl_texture_driver_gl =
 | 
			
		||||
    _cogl_texture_driver_prep_gl_for_pixels_upload,
 | 
			
		||||
    _cogl_texture_driver_upload_subregion_to_gl,
 | 
			
		||||
    _cogl_texture_driver_upload_to_gl,
 | 
			
		||||
    _cogl_texture_driver_upload_to_gl_3d,
 | 
			
		||||
    _cogl_texture_driver_prep_gl_for_pixels_download,
 | 
			
		||||
    _cogl_texture_driver_gl_get_tex_image,
 | 
			
		||||
    _cogl_texture_driver_size_supported,
 | 
			
		||||
    _cogl_texture_driver_size_supported_3d,
 | 
			
		||||
    _cogl_texture_driver_allows_foreign_gl_target,
 | 
			
		||||
    _cogl_texture_driver_find_best_gl_get_data_format
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -302,15 +302,11 @@ _cogl_driver_update_features (CoglContext *context,
 | 
			
		||||
                                     gl_minor,
 | 
			
		||||
                                     gl_extensions);
 | 
			
		||||
 | 
			
		||||
  flags |= COGL_FEATURE_SHADERS_GLSL | COGL_FEATURE_OFFSCREEN;
 | 
			
		||||
  flags |= COGL_FEATURE_OFFSCREEN;
 | 
			
		||||
  /* Note GLES 2 core doesn't support mipmaps for npot textures or
 | 
			
		||||
   * repeat modes other than CLAMP_TO_EDGE. */
 | 
			
		||||
  flags |= COGL_FEATURE_TEXTURE_NPOT_BASIC;
 | 
			
		||||
  flags |= COGL_FEATURE_DEPTH_RANGE;
 | 
			
		||||
  COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_GLSL, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_OFFSCREEN, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features,
 | 
			
		||||
                  COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_RANGE, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features,
 | 
			
		||||
                  COGL_FEATURE_ID_MIRRORED_REPEAT, TRUE);
 | 
			
		||||
@@ -350,24 +346,6 @@ _cogl_driver_update_features (CoglContext *context,
 | 
			
		||||
      COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_TEXTURE, TRUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  flags |= (COGL_FEATURE_TEXTURE_NPOT |
 | 
			
		||||
            COGL_FEATURE_TEXTURE_NPOT_BASIC |
 | 
			
		||||
            COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
 | 
			
		||||
            COGL_FEATURE_TEXTURE_NPOT_REPEAT);
 | 
			
		||||
  COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_NPOT, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features,
 | 
			
		||||
                  COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features,
 | 
			
		||||
                  COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP, TRUE);
 | 
			
		||||
  COGL_FLAGS_SET (context->features,
 | 
			
		||||
                  COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, TRUE);
 | 
			
		||||
 | 
			
		||||
  if (context->glTexImage3D)
 | 
			
		||||
    {
 | 
			
		||||
      flags |= COGL_FEATURE_TEXTURE_3D;
 | 
			
		||||
      COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_3D, TRUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (context->glMapBuffer)
 | 
			
		||||
    {
 | 
			
		||||
      /* The GL_OES_mapbuffer extension doesn't support mapping for
 | 
			
		||||
 
 | 
			
		||||
@@ -394,152 +394,6 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
 | 
			
		||||
                                      GLenum gl_target,
 | 
			
		||||
                                      GLuint gl_handle,
 | 
			
		||||
                                      gboolean is_foreign,
 | 
			
		||||
                                      GLint height,
 | 
			
		||||
                                      GLint depth,
 | 
			
		||||
                                      CoglBitmap *source_bmp,
 | 
			
		||||
                                      GLint internal_gl_format,
 | 
			
		||||
                                      GLuint source_gl_format,
 | 
			
		||||
                                      GLuint source_gl_type,
 | 
			
		||||
                                      CoglError **error)
 | 
			
		||||
{
 | 
			
		||||
  CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
 | 
			
		||||
  int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
 | 
			
		||||
  int rowstride = cogl_bitmap_get_rowstride (source_bmp);
 | 
			
		||||
  int bmp_width = cogl_bitmap_get_width (source_bmp);
 | 
			
		||||
  int bmp_height = cogl_bitmap_get_height (source_bmp);
 | 
			
		||||
  uint8_t *data;
 | 
			
		||||
 | 
			
		||||
  _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
 | 
			
		||||
 | 
			
		||||
  /* If the rowstride or image height can't be specified with just
 | 
			
		||||
     GL_ALIGNMENT alone then we need to copy the bitmap because there
 | 
			
		||||
     is no GL_ROW_LENGTH */
 | 
			
		||||
  if (rowstride / bpp != bmp_width ||
 | 
			
		||||
      height != bmp_height / depth)
 | 
			
		||||
    {
 | 
			
		||||
      CoglBitmap *bmp;
 | 
			
		||||
      int image_height = bmp_height / depth;
 | 
			
		||||
      CoglPixelFormat source_bmp_format = cogl_bitmap_get_format (source_bmp);
 | 
			
		||||
      int i;
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, bmp_width * bpp, bpp);
 | 
			
		||||
 | 
			
		||||
      /* Initialize the texture with empty data and then upload each
 | 
			
		||||
         image with a sub-region update */
 | 
			
		||||
 | 
			
		||||
      /* Clear any GL errors */
 | 
			
		||||
      _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
      ctx->glTexImage3D (gl_target,
 | 
			
		||||
                         0, /* level */
 | 
			
		||||
                         internal_gl_format,
 | 
			
		||||
                         bmp_width,
 | 
			
		||||
                         height,
 | 
			
		||||
                         depth,
 | 
			
		||||
                         0,
 | 
			
		||||
                         source_gl_format,
 | 
			
		||||
                         source_gl_type,
 | 
			
		||||
                         NULL);
 | 
			
		||||
 | 
			
		||||
      if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
      bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
 | 
			
		||||
                                                 bmp_width,
 | 
			
		||||
                                                 height,
 | 
			
		||||
                                                 source_bmp_format,
 | 
			
		||||
                                                 error);
 | 
			
		||||
      if (!bmp)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
      for (i = 0; i < depth; i++)
 | 
			
		||||
        {
 | 
			
		||||
          if (!_cogl_bitmap_copy_subregion (source_bmp,
 | 
			
		||||
                                            bmp,
 | 
			
		||||
                                            0, image_height * i,
 | 
			
		||||
                                            0, 0,
 | 
			
		||||
                                            bmp_width,
 | 
			
		||||
                                            height,
 | 
			
		||||
                                            error))
 | 
			
		||||
            {
 | 
			
		||||
              cogl_object_unref (bmp);
 | 
			
		||||
              return FALSE;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          data = _cogl_bitmap_gl_bind (bmp,
 | 
			
		||||
                                       COGL_BUFFER_ACCESS_READ, 0, error);
 | 
			
		||||
          if (!data)
 | 
			
		||||
            {
 | 
			
		||||
              cogl_object_unref (bmp);
 | 
			
		||||
              return FALSE;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          /* Clear any GL errors */
 | 
			
		||||
          _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
          ctx->glTexSubImage3D (gl_target,
 | 
			
		||||
                                0, /* level */
 | 
			
		||||
                                0, /* xoffset */
 | 
			
		||||
                                0, /* yoffset */
 | 
			
		||||
                                i, /* zoffset */
 | 
			
		||||
                                bmp_width, /* width */
 | 
			
		||||
                                height, /* height */
 | 
			
		||||
                                1, /* depth */
 | 
			
		||||
                                source_gl_format,
 | 
			
		||||
                                source_gl_type,
 | 
			
		||||
                                data);
 | 
			
		||||
 | 
			
		||||
          if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
            {
 | 
			
		||||
              cogl_object_unref (bmp);
 | 
			
		||||
              _cogl_bitmap_gl_unbind (bmp);
 | 
			
		||||
              return FALSE;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          _cogl_bitmap_gl_unbind (bmp);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      cogl_object_unref (bmp);
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0, error);
 | 
			
		||||
      if (!data)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
 | 
			
		||||
 | 
			
		||||
      /* Clear any GL errors */
 | 
			
		||||
      _cogl_gl_util_clear_gl_errors (ctx);
 | 
			
		||||
 | 
			
		||||
      ctx->glTexImage3D (gl_target,
 | 
			
		||||
                         0, /* level */
 | 
			
		||||
                         internal_gl_format,
 | 
			
		||||
                         bmp_width,
 | 
			
		||||
                         height,
 | 
			
		||||
                         depth,
 | 
			
		||||
                         0,
 | 
			
		||||
                         source_gl_format,
 | 
			
		||||
                         source_gl_type,
 | 
			
		||||
                         data);
 | 
			
		||||
 | 
			
		||||
      if (_cogl_gl_util_catch_out_of_memory (ctx, error))
 | 
			
		||||
        {
 | 
			
		||||
          _cogl_bitmap_gl_unbind (source_bmp);
 | 
			
		||||
          return FALSE;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      _cogl_bitmap_gl_unbind (source_bmp);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* NB: GLES doesn't support glGetTexImage2D, so cogl-texture will instead
 | 
			
		||||
 * fallback to a generic render + readpixels approach to downloading
 | 
			
		||||
 * texture data. (See _cogl_texture_draw_and_read() ) */
 | 
			
		||||
@@ -553,25 +407,6 @@ _cogl_texture_driver_gl_get_tex_image (CoglContext *ctx,
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_size_supported_3d (CoglContext *ctx,
 | 
			
		||||
                                        GLenum gl_target,
 | 
			
		||||
                                        GLenum gl_format,
 | 
			
		||||
                                        GLenum gl_type,
 | 
			
		||||
                                        int width,
 | 
			
		||||
                                        int height,
 | 
			
		||||
                                        int depth)
 | 
			
		||||
{
 | 
			
		||||
  GLint max_size;
 | 
			
		||||
 | 
			
		||||
  /* GLES doesn't support a proxy texture target so let's at least
 | 
			
		||||
     check whether the size is greater than
 | 
			
		||||
     GL_MAX_3D_TEXTURE_SIZE_OES */
 | 
			
		||||
  GE( ctx, glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE_OES, &max_size) );
 | 
			
		||||
 | 
			
		||||
  return width <= max_size && height <= max_size && depth <= max_size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
_cogl_texture_driver_size_supported (CoglContext *ctx,
 | 
			
		||||
                                     GLenum gl_target,
 | 
			
		||||
@@ -622,11 +457,9 @@ _cogl_texture_driver_gles =
 | 
			
		||||
    _cogl_texture_driver_prep_gl_for_pixels_upload,
 | 
			
		||||
    _cogl_texture_driver_upload_subregion_to_gl,
 | 
			
		||||
    _cogl_texture_driver_upload_to_gl,
 | 
			
		||||
    _cogl_texture_driver_upload_to_gl_3d,
 | 
			
		||||
    _cogl_texture_driver_prep_gl_for_pixels_download,
 | 
			
		||||
    _cogl_texture_driver_gl_get_tex_image,
 | 
			
		||||
    _cogl_texture_driver_size_supported,
 | 
			
		||||
    _cogl_texture_driver_size_supported_3d,
 | 
			
		||||
    _cogl_texture_driver_allows_foreign_gl_target,
 | 
			
		||||
    _cogl_texture_driver_find_best_gl_get_data_format
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -109,27 +109,6 @@ COGL_EXT_FUNCTION (GLboolean, glUnmapBuffer,
 | 
			
		||||
                   (GLenum		 target))
 | 
			
		||||
COGL_EXT_END ()
 | 
			
		||||
 | 
			
		||||
COGL_EXT_BEGIN (texture_3d, 1, 2,
 | 
			
		||||
                0, /* not in either GLES */
 | 
			
		||||
                "OES\0",
 | 
			
		||||
                "texture_3D\0")
 | 
			
		||||
COGL_EXT_FUNCTION (void, glTexImage3D,
 | 
			
		||||
                   (GLenum target, GLint level,
 | 
			
		||||
                    GLint internalFormat,
 | 
			
		||||
                    GLsizei width, GLsizei height,
 | 
			
		||||
                    GLsizei depth, GLint border,
 | 
			
		||||
                    GLenum format, GLenum type,
 | 
			
		||||
                    const GLvoid *pixels))
 | 
			
		||||
COGL_EXT_FUNCTION (void, glTexSubImage3D,
 | 
			
		||||
                   (GLenum target, GLint level,
 | 
			
		||||
                    GLint xoffset, GLint yoffset,
 | 
			
		||||
                    GLint zoffset, GLsizei width,
 | 
			
		||||
                    GLsizei height, GLsizei depth,
 | 
			
		||||
                    GLenum format,
 | 
			
		||||
                    GLenum type, const GLvoid *pixels))
 | 
			
		||||
COGL_EXT_END ()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
COGL_EXT_BEGIN (offscreen_blit, 3, 0,
 | 
			
		||||
                0, /* not in either GLES */
 | 
			
		||||
 
 | 
			
		||||
@@ -29,8 +29,6 @@ global:
 | 
			
		||||
  _cogl_texture_can_hardware_repeat;
 | 
			
		||||
  _cogl_pipeline_prune_to_n_layers;
 | 
			
		||||
  _cogl_primitive_draw;
 | 
			
		||||
  #test_;
 | 
			
		||||
  #unit_test_;
 | 
			
		||||
  _cogl_winsys_glx_get_vtable;
 | 
			
		||||
  _cogl_winsys_egl_xlib_get_vtable;
 | 
			
		||||
  _cogl_winsys_egl_get_vtable;
 | 
			
		||||
@@ -48,6 +46,7 @@ global:
 | 
			
		||||
  _cogl_pixel_format_get_bytes_per_pixel*;
 | 
			
		||||
  _cogl_system_error_quark;
 | 
			
		||||
  _cogl_util_next_p2;
 | 
			
		||||
  @unit_tests_symbols@
 | 
			
		||||
local:
 | 
			
		||||
  *;
 | 
			
		||||
};
 | 
			
		||||
@@ -119,9 +119,7 @@ cogl_nonintrospected_headers = [
 | 
			
		||||
  'cogl-quaternion.h',
 | 
			
		||||
  'cogl-matrix-stack.h',
 | 
			
		||||
  'cogl-poll.h',
 | 
			
		||||
  'cogl-texture-3d.h',
 | 
			
		||||
  'cogl-texture-2d-gl.h',
 | 
			
		||||
  'cogl-texture-rectangle.h',
 | 
			
		||||
  'cogl-sub-texture.h',
 | 
			
		||||
  'cogl-atlas-texture.h',
 | 
			
		||||
  'cogl-meta-texture.h',
 | 
			
		||||
@@ -307,15 +305,11 @@ cogl_sources = [
 | 
			
		||||
  'cogl-texture-private.h',
 | 
			
		||||
  'cogl-texture-2d-private.h',
 | 
			
		||||
  'cogl-texture-2d-sliced-private.h',
 | 
			
		||||
  'cogl-texture-3d-private.h',
 | 
			
		||||
  'cogl-texture-driver.h',
 | 
			
		||||
  'cogl-sub-texture.c',
 | 
			
		||||
  'cogl-texture.c',
 | 
			
		||||
  'cogl-texture-2d.c',
 | 
			
		||||
  'cogl-texture-2d-sliced.c',
 | 
			
		||||
  'cogl-texture-3d.c',
 | 
			
		||||
  'cogl-texture-rectangle-private.h',
 | 
			
		||||
  'cogl-texture-rectangle.c',
 | 
			
		||||
  'cogl-rectangle-map.h',
 | 
			
		||||
  'cogl-rectangle-map.c',
 | 
			
		||||
  'cogl-atlas.h',
 | 
			
		||||
@@ -461,16 +455,24 @@ cogl_headers_all = [
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
cogl_test_deps = []
 | 
			
		||||
cogl_unit_tests_map_data = configuration_data()
 | 
			
		||||
 | 
			
		||||
if have_cogl_tests
 | 
			
		||||
  cogl_test_deps += [libmutter_cogl_test_fixtures_dep]
 | 
			
		||||
 | 
			
		||||
  cogl_unit_tests_map_data.set('unit_tests_symbols', 'test_*; unit_test_*;')
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
libmutter_cogl_map = configure_file(
 | 
			
		||||
  input: 'libmutter-cogl.map.in',
 | 
			
		||||
  output: 'libmutter-cogl.map',
 | 
			
		||||
  configuration: cogl_unit_tests_map_data,
 | 
			
		||||
  install: false,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
libmutter_cogl_name = 'mutter-cogl-' + libmutter_api_version
 | 
			
		||||
libmutter_cogl_map = 'libmutter-cogl.map'
 | 
			
		||||
libmutter_cogl_link_args = [
 | 
			
		||||
  '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(),
 | 
			
		||||
      libmutter_cogl_map),
 | 
			
		||||
  '-Wl,--version-script,@0@'.format(libmutter_cogl_map),
 | 
			
		||||
]
 | 
			
		||||
libmutter_cogl = shared_library(libmutter_cogl_name,
 | 
			
		||||
  sources: [cogl_sources, cogl_headers_all],
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,6 @@
 | 
			
		||||
#include "cogl-texture-driver.h"
 | 
			
		||||
#include "cogl-texture-2d-private.h"
 | 
			
		||||
#include "cogl-texture-2d-sliced.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-context-private.h"
 | 
			
		||||
#include "cogl-display-private.h"
 | 
			
		||||
#include "cogl-renderer-private.h"
 | 
			
		||||
@@ -582,29 +581,21 @@ create_fallback_texture (CoglContext *ctx,
 | 
			
		||||
  CoglTexture *tex;
 | 
			
		||||
  CoglError *skip_error = NULL;
 | 
			
		||||
 | 
			
		||||
  if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
 | 
			
		||||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
  tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 | 
			
		||||
 | 
			
		||||
  _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
  /* TODO: instead of allocating storage here it would be better
 | 
			
		||||
   * if we had some api that let us just check that the size is
 | 
			
		||||
   * supported by the hardware so storage could be allocated
 | 
			
		||||
   * lazily when uploading data. */
 | 
			
		||||
  if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
    {
 | 
			
		||||
      /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
 | 
			
		||||
                                                         width, height));
 | 
			
		||||
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, internal_format);
 | 
			
		||||
 | 
			
		||||
      /* TODO: instead of allocating storage here it would be better
 | 
			
		||||
       * if we had some api that let us just check that the size is
 | 
			
		||||
       * supported by the hardware so storage could be allocated
 | 
			
		||||
       * lazily when uploading data. */
 | 
			
		||||
      if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (skip_error);
 | 
			
		||||
          cogl_object_unref (tex);
 | 
			
		||||
          tex = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      cogl_error_free (skip_error);
 | 
			
		||||
      cogl_object_unref (tex);
 | 
			
		||||
      tex = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
@@ -879,33 +870,6 @@ _cogl_texture_pixmap_x11_get_data (CoglTexture *tex,
 | 
			
		||||
  return cogl_texture_get_data (child_tex, format, rowstride, data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef struct _NormalizeCoordsWrapperData
 | 
			
		||||
{
 | 
			
		||||
  int width;
 | 
			
		||||
  int height;
 | 
			
		||||
  CoglMetaTextureCallback callback;
 | 
			
		||||
  void *user_data;
 | 
			
		||||
} NormalizeCoordsWrapperData;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
normalize_coords_wrapper_cb (CoglTexture *child_texture,
 | 
			
		||||
                             const float *child_texture_coords,
 | 
			
		||||
                             const float *meta_coords,
 | 
			
		||||
                             void *user_data)
 | 
			
		||||
{
 | 
			
		||||
  NormalizeCoordsWrapperData *data = user_data;
 | 
			
		||||
  float normalized_coords[4];
 | 
			
		||||
 | 
			
		||||
  normalized_coords[0] = meta_coords[0] / data->width;
 | 
			
		||||
  normalized_coords[1] = meta_coords[1] / data->height;
 | 
			
		||||
  normalized_coords[2] = meta_coords[2] / data->width;
 | 
			
		||||
  normalized_coords[3] = meta_coords[3] / data->height;
 | 
			
		||||
 | 
			
		||||
  data->callback (child_texture,
 | 
			
		||||
                  child_texture_coords, normalized_coords,
 | 
			
		||||
                  data->user_data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_pixmap_x11_foreach_sub_texture_in_region
 | 
			
		||||
                                  (CoglTexture              *tex,
 | 
			
		||||
@@ -920,47 +884,15 @@ _cogl_texture_pixmap_x11_foreach_sub_texture_in_region
 | 
			
		||||
  CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 | 
			
		||||
 | 
			
		||||
  /* Forward on to the child texture */
 | 
			
		||||
 | 
			
		||||
  /* tfp textures may be implemented in terms of a
 | 
			
		||||
   * CoglTextureRectangle texture which uses un-normalized texture
 | 
			
		||||
   * coordinates but we want to consistently deal with normalized
 | 
			
		||||
   * texture coordinates with CoglTexturePixmapX11... */
 | 
			
		||||
  if (cogl_is_texture_rectangle (child_tex))
 | 
			
		||||
    {
 | 
			
		||||
      NormalizeCoordsWrapperData data;
 | 
			
		||||
      int width = tex->width;
 | 
			
		||||
      int height = tex->height;
 | 
			
		||||
 | 
			
		||||
      virtual_tx_1 *= width;
 | 
			
		||||
      virtual_ty_1 *= height;
 | 
			
		||||
      virtual_tx_2 *= width;
 | 
			
		||||
      virtual_ty_2 *= height;
 | 
			
		||||
 | 
			
		||||
      data.width = width;
 | 
			
		||||
      data.height = height;
 | 
			
		||||
      data.callback = callback;
 | 
			
		||||
      data.user_data = user_data;
 | 
			
		||||
 | 
			
		||||
      cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (child_tex),
 | 
			
		||||
                                           virtual_tx_1,
 | 
			
		||||
                                           virtual_ty_1,
 | 
			
		||||
                                           virtual_tx_2,
 | 
			
		||||
                                           virtual_ty_2,
 | 
			
		||||
                                           COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                           COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                           normalize_coords_wrapper_cb,
 | 
			
		||||
                                           &data);
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (child_tex),
 | 
			
		||||
                                         virtual_tx_1,
 | 
			
		||||
                                         virtual_ty_1,
 | 
			
		||||
                                         virtual_tx_2,
 | 
			
		||||
                                         virtual_ty_2,
 | 
			
		||||
                                         COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                         COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                         callback,
 | 
			
		||||
                                         user_data);
 | 
			
		||||
  cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (child_tex),
 | 
			
		||||
                                       virtual_tx_1,
 | 
			
		||||
                                       virtual_ty_1,
 | 
			
		||||
                                       virtual_tx_2,
 | 
			
		||||
                                       virtual_ty_2,
 | 
			
		||||
                                       COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                       COGL_PIPELINE_WRAP_MODE_REPEAT,
 | 
			
		||||
                                       callback,
 | 
			
		||||
                                       user_data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
@@ -1100,18 +1032,6 @@ _cogl_texture_pixmap_x11_get_gl_format (CoglTexture *tex)
 | 
			
		||||
  return _cogl_texture_gl_get_format (child_tex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static CoglTextureType
 | 
			
		||||
_cogl_texture_pixmap_x11_get_type (CoglTexture *tex)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
 | 
			
		||||
  CoglTexture *child_tex;
 | 
			
		||||
 | 
			
		||||
  child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
 | 
			
		||||
 | 
			
		||||
  /* Forward on to the child texture */
 | 
			
		||||
  return _cogl_texture_get_type (child_tex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
_cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
 | 
			
		||||
{
 | 
			
		||||
@@ -1178,7 +1098,6 @@ cogl_texture_pixmap_x11_vtable =
 | 
			
		||||
    _cogl_texture_pixmap_x11_gl_flush_legacy_texobj_wrap_modes,
 | 
			
		||||
    _cogl_texture_pixmap_x11_get_format,
 | 
			
		||||
    _cogl_texture_pixmap_x11_get_gl_format,
 | 
			
		||||
    _cogl_texture_pixmap_x11_get_type,
 | 
			
		||||
    NULL, /* is_foreign */
 | 
			
		||||
    NULL /* set_auto_mipmap */
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -147,3 +147,9 @@ COGL_WINSYS_FEATURE_BEGIN (surfaceless_context,
 | 
			
		||||
                           "surfaceless_context\0",
 | 
			
		||||
                           COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT)
 | 
			
		||||
COGL_WINSYS_FEATURE_END ()
 | 
			
		||||
 | 
			
		||||
COGL_WINSYS_FEATURE_BEGIN (context_priority,
 | 
			
		||||
                           "IMG\0",
 | 
			
		||||
                           "context_priority\0",
 | 
			
		||||
                           COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
 | 
			
		||||
COGL_WINSYS_FEATURE_END ()
 | 
			
		||||
 
 | 
			
		||||
@@ -105,7 +105,8 @@ typedef enum _CoglEGLWinsysFeature
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT                =1L<<3,
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_BUFFER_AGE                    =1L<<4,
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_FENCE_SYNC                    =1L<<5,
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT           =1L<<6
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT           =1L<<6,
 | 
			
		||||
  COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY              =1L<<7,
 | 
			
		||||
} CoglEGLWinsysFeature;
 | 
			
		||||
 | 
			
		||||
typedef struct _CoglRendererEGL
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,12 @@
 | 
			
		||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef EGL_IMG_context_priority
 | 
			
		||||
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG          0x3100
 | 
			
		||||
#define EGL_CONTEXT_PRIORITY_HIGH_IMG           0x3101
 | 
			
		||||
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG         0x3102
 | 
			
		||||
#define EGL_CONTEXT_PRIORITY_LOW_IMG            0x3103
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define MAX_EGL_CONFIG_ATTRIBS 30
 | 
			
		||||
 | 
			
		||||
@@ -347,10 +353,11 @@ try_create_context (CoglDisplay *display,
 | 
			
		||||
  CoglRendererEGL *egl_renderer = renderer->winsys;
 | 
			
		||||
  EGLDisplay edpy;
 | 
			
		||||
  EGLConfig config;
 | 
			
		||||
  EGLint attribs[9];
 | 
			
		||||
  EGLint attribs[11];
 | 
			
		||||
  EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
 | 
			
		||||
  GError *config_error = NULL;
 | 
			
		||||
  const char *error_message;
 | 
			
		||||
  int i = 0;
 | 
			
		||||
 | 
			
		||||
  _COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context == NULL, TRUE);
 | 
			
		||||
 | 
			
		||||
@@ -388,24 +395,29 @@ try_create_context (CoglDisplay *display,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      /* Try to get a core profile 3.1 context with no deprecated features */
 | 
			
		||||
      attribs[0] = EGL_CONTEXT_MAJOR_VERSION_KHR;
 | 
			
		||||
      attribs[1] = 3;
 | 
			
		||||
      attribs[2] = EGL_CONTEXT_MINOR_VERSION_KHR;
 | 
			
		||||
      attribs[3] = 1;
 | 
			
		||||
      attribs[4] = EGL_CONTEXT_FLAGS_KHR;
 | 
			
		||||
      attribs[5] = EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 | 
			
		||||
      attribs[6] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
 | 
			
		||||
      attribs[7] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
 | 
			
		||||
      attribs[8] = EGL_NONE;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
 | 
			
		||||
      attribs[i++] = 3;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
 | 
			
		||||
      attribs[i++] = 1;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
 | 
			
		||||
    }
 | 
			
		||||
  else if (display->renderer->driver == COGL_DRIVER_GLES2)
 | 
			
		||||
    {
 | 
			
		||||
      attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
 | 
			
		||||
      attribs[1] = 2;
 | 
			
		||||
      attribs[2] = EGL_NONE;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
 | 
			
		||||
      attribs[i++] = 2;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    attribs[0] = EGL_NONE;
 | 
			
		||||
 | 
			
		||||
  if (egl_renderer->private_features &
 | 
			
		||||
      COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
 | 
			
		||||
    {
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_PRIORITY_LEVEL_IMG;
 | 
			
		||||
      attribs[i++] = EGL_CONTEXT_PRIORITY_HIGH_IMG;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  attribs[i++] = EGL_NONE;
 | 
			
		||||
 | 
			
		||||
  egl_display->egl_context = eglCreateContext (edpy,
 | 
			
		||||
                                               config,
 | 
			
		||||
@@ -418,6 +430,20 @@ try_create_context (CoglDisplay *display,
 | 
			
		||||
      goto fail;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (egl_renderer->private_features &
 | 
			
		||||
      COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
 | 
			
		||||
    {
 | 
			
		||||
      EGLint value = EGL_CONTEXT_PRIORITY_MEDIUM_IMG;
 | 
			
		||||
 | 
			
		||||
      eglQueryContext (egl_renderer->edpy,
 | 
			
		||||
                       egl_display->egl_context,
 | 
			
		||||
                       EGL_CONTEXT_PRIORITY_LEVEL_IMG,
 | 
			
		||||
                       &value);
 | 
			
		||||
 | 
			
		||||
      if (value != EGL_CONTEXT_PRIORITY_HIGH_IMG)
 | 
			
		||||
        g_warning ("Failed to obtain high priority context");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (egl_renderer->platform_vtable->context_created &&
 | 
			
		||||
      !egl_renderer->platform_vtable->context_created (display, error))
 | 
			
		||||
    return FALSE;
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,6 @@
 | 
			
		||||
#include "cogl-glx-display-private.h"
 | 
			
		||||
#include "cogl-private.h"
 | 
			
		||||
#include "cogl-texture-2d-private.h"
 | 
			
		||||
#include "cogl-texture-rectangle-private.h"
 | 
			
		||||
#include "cogl-frame-info-private.h"
 | 
			
		||||
#include "cogl-framebuffer-private.h"
 | 
			
		||||
#include "cogl-onscreen-private.h"
 | 
			
		||||
@@ -2525,54 +2524,6 @@ get_fbconfig_for_depth (CoglContext *context,
 | 
			
		||||
  return found;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
should_use_rectangle (CoglContext *context)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  if (context->rectangle_state == COGL_WINSYS_RECTANGLE_STATE_UNKNOWN)
 | 
			
		||||
    {
 | 
			
		||||
      if (cogl_has_feature (context, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
 | 
			
		||||
        {
 | 
			
		||||
          const char *rect_env;
 | 
			
		||||
 | 
			
		||||
          /* Use the rectangle only if it is available and either:
 | 
			
		||||
 | 
			
		||||
             the COGL_PIXMAP_TEXTURE_RECTANGLE environment variable is
 | 
			
		||||
             set to 'force'
 | 
			
		||||
 | 
			
		||||
             *or*
 | 
			
		||||
 | 
			
		||||
             the env var is set to 'allow' or not set and NPOTs textures
 | 
			
		||||
             are not available */
 | 
			
		||||
 | 
			
		||||
          context->rectangle_state =
 | 
			
		||||
            cogl_has_feature (context, COGL_FEATURE_ID_TEXTURE_NPOT) ?
 | 
			
		||||
            COGL_WINSYS_RECTANGLE_STATE_DISABLE :
 | 
			
		||||
            COGL_WINSYS_RECTANGLE_STATE_ENABLE;
 | 
			
		||||
 | 
			
		||||
          if ((rect_env = g_getenv ("COGL_PIXMAP_TEXTURE_RECTANGLE")) ||
 | 
			
		||||
              /* For compatibility, we'll also look at the old Clutter
 | 
			
		||||
                 environment variable */
 | 
			
		||||
              (rect_env = g_getenv ("CLUTTER_PIXMAP_TEXTURE_RECTANGLE")))
 | 
			
		||||
            {
 | 
			
		||||
              if (g_ascii_strcasecmp (rect_env, "force") == 0)
 | 
			
		||||
                context->rectangle_state =
 | 
			
		||||
                  COGL_WINSYS_RECTANGLE_STATE_ENABLE;
 | 
			
		||||
              else if (g_ascii_strcasecmp (rect_env, "disable") == 0)
 | 
			
		||||
                context->rectangle_state =
 | 
			
		||||
                  COGL_WINSYS_RECTANGLE_STATE_DISABLE;
 | 
			
		||||
              else if (g_ascii_strcasecmp (rect_env, "allow"))
 | 
			
		||||
                g_warning ("Unknown value for COGL_PIXMAP_TEXTURE_RECTANGLE, "
 | 
			
		||||
                           "should be 'force' or 'disable'");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      else
 | 
			
		||||
        context->rectangle_state = COGL_WINSYS_RECTANGLE_STATE_DISABLE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return context->rectangle_state == COGL_WINSYS_RECTANGLE_STATE_ENABLE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
try_create_glx_pixmap (CoglContext *context,
 | 
			
		||||
                       CoglTexturePixmapX11 *tex_pixmap,
 | 
			
		||||
@@ -2589,7 +2540,6 @@ try_create_glx_pixmap (CoglContext *context,
 | 
			
		||||
  GLXFBConfig fb_config = (GLXFBConfig)0;
 | 
			
		||||
  int attribs[7];
 | 
			
		||||
  int i = 0;
 | 
			
		||||
  GLenum target;
 | 
			
		||||
  CoglXlibTrapState trap_state;
 | 
			
		||||
 | 
			
		||||
  unsigned int depth = tex_pixmap->depth;
 | 
			
		||||
@@ -2610,14 +2560,6 @@ try_create_glx_pixmap (CoglContext *context,
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (should_use_rectangle (context))
 | 
			
		||||
    {
 | 
			
		||||
      target = GLX_TEXTURE_RECTANGLE_EXT;
 | 
			
		||||
      glx_tex_pixmap->can_mipmap = FALSE;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    target = GLX_TEXTURE_2D_EXT;
 | 
			
		||||
 | 
			
		||||
  if (!glx_tex_pixmap->can_mipmap)
 | 
			
		||||
    mipmap = FALSE;
 | 
			
		||||
 | 
			
		||||
@@ -2638,7 +2580,7 @@ try_create_glx_pixmap (CoglContext *context,
 | 
			
		||||
  attribs[i++] = mipmap;
 | 
			
		||||
 | 
			
		||||
  attribs[i++] = GLX_TEXTURE_TARGET_EXT;
 | 
			
		||||
  attribs[i++] = target;
 | 
			
		||||
  attribs[i++] = GLX_TEXTURE_2D_EXT;
 | 
			
		||||
 | 
			
		||||
  attribs[i++] = None;
 | 
			
		||||
 | 
			
		||||
@@ -2821,49 +2763,21 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
 | 
			
		||||
                        COGL_PIXEL_FORMAT_RGBA_8888_PRE :
 | 
			
		||||
                        COGL_PIXEL_FORMAT_RGB_888);
 | 
			
		||||
 | 
			
		||||
      if (should_use_rectangle (ctx))
 | 
			
		||||
        {
 | 
			
		||||
          texture_info->glx_tex = COGL_TEXTURE (
 | 
			
		||||
            cogl_texture_rectangle_new_with_size (ctx,
 | 
			
		||||
                                                  tex->width,
 | 
			
		||||
                                                  tex->height));
 | 
			
		||||
      texture_info->glx_tex = COGL_TEXTURE (
 | 
			
		||||
        cogl_texture_2d_new_with_size (ctx, tex->width, tex->height));
 | 
			
		||||
 | 
			
		||||
          _cogl_texture_set_internal_format (tex, texture_format);
 | 
			
		||||
      _cogl_texture_set_internal_format (tex, texture_format);
 | 
			
		||||
 | 
			
		||||
          if (cogl_texture_allocate (texture_info->glx_tex, &error))
 | 
			
		||||
            COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p",
 | 
			
		||||
                       tex_pixmap);
 | 
			
		||||
          else
 | 
			
		||||
            {
 | 
			
		||||
              COGL_NOTE (TEXTURE_PIXMAP, "Falling back for %p because a "
 | 
			
		||||
                         "texture rectangle could not be created: %s",
 | 
			
		||||
                         tex_pixmap, error->message);
 | 
			
		||||
              cogl_error_free (error);
 | 
			
		||||
              free_glx_pixmap (ctx, glx_tex_pixmap);
 | 
			
		||||
              return FALSE;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      if (cogl_texture_allocate (texture_info->glx_tex, &error))
 | 
			
		||||
        COGL_NOTE (TEXTURE_PIXMAP, "Created a texture 2d for %p", tex_pixmap);
 | 
			
		||||
      else
 | 
			
		||||
        {
 | 
			
		||||
          texture_info->glx_tex = COGL_TEXTURE (
 | 
			
		||||
            cogl_texture_2d_new_with_size (ctx,
 | 
			
		||||
                                           tex->width,
 | 
			
		||||
                                           tex->height));
 | 
			
		||||
 | 
			
		||||
          _cogl_texture_set_internal_format (tex, texture_format);
 | 
			
		||||
 | 
			
		||||
          if (cogl_texture_allocate (texture_info->glx_tex, &error))
 | 
			
		||||
            COGL_NOTE (TEXTURE_PIXMAP, "Created a texture 2d for %p",
 | 
			
		||||
                       tex_pixmap);
 | 
			
		||||
          else
 | 
			
		||||
            {
 | 
			
		||||
              COGL_NOTE (TEXTURE_PIXMAP, "Falling back for %p because a "
 | 
			
		||||
                         "texture 2d could not be created: %s",
 | 
			
		||||
                         tex_pixmap, error->message);
 | 
			
		||||
              cogl_error_free (error);
 | 
			
		||||
              free_glx_pixmap (ctx, glx_tex_pixmap);
 | 
			
		||||
              return FALSE;
 | 
			
		||||
            }
 | 
			
		||||
          COGL_NOTE (TEXTURE_PIXMAP, "Falling back for %p because a "
 | 
			
		||||
                     "texture 2d could not be created: %s",
 | 
			
		||||
                     tex_pixmap, error->message);
 | 
			
		||||
          cogl_error_free (error);
 | 
			
		||||
          free_glx_pixmap (ctx, glx_tex_pixmap);
 | 
			
		||||
          return FALSE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -64,13 +64,6 @@ typedef enum /*< prefix=COGL_WINSYS_ERROR >*/
 | 
			
		||||
  COGL_WINSYS_ERROR_CREATE_GLES2_CONTEXT,
 | 
			
		||||
} CoglWinsysError;
 | 
			
		||||
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  COGL_WINSYS_RECTANGLE_STATE_UNKNOWN,
 | 
			
		||||
  COGL_WINSYS_RECTANGLE_STATE_DISABLE,
 | 
			
		||||
  COGL_WINSYS_RECTANGLE_STATE_ENABLE
 | 
			
		||||
} CoglWinsysRectangleState;
 | 
			
		||||
 | 
			
		||||
typedef struct _CoglWinsysVtable
 | 
			
		||||
{
 | 
			
		||||
  CoglWinsysID id;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
cogl_includesubdir = join_paths(pkgname, 'cogl')
 | 
			
		||||
cogl_includedir = join_paths(includedir, cogl_includesubdir)
 | 
			
		||||
cogl_srcdir = join_paths(top_srcdir, 'cogl')
 | 
			
		||||
cogl_builddir = join_paths(builddir, 'cogl')
 | 
			
		||||
cogl_srcdir = meson.current_source_dir()
 | 
			
		||||
 | 
			
		||||
cogl_includepath = include_directories('.', 'cogl')
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,24 +24,6 @@ check_flags (TestFlags flags,
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_NPOT &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
 | 
			
		||||
    {
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_TEXTURE_3D &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    {
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_TEXTURE_RECTANGLE &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
 | 
			
		||||
    {
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_TEXTURE_RG &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RG))
 | 
			
		||||
    {
 | 
			
		||||
@@ -72,12 +54,6 @@ check_flags (TestFlags flags,
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_GLSL &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL))
 | 
			
		||||
    {
 | 
			
		||||
      return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (flags & TEST_REQUIREMENT_OFFSCREEN &&
 | 
			
		||||
      !cogl_has_feature (test_ctx, COGL_FEATURE_ID_OFFSCREEN))
 | 
			
		||||
    {
 | 
			
		||||
@@ -373,25 +349,17 @@ test_utils_texture_new_with_size (CoglContext *ctx,
 | 
			
		||||
  CoglTexture *tex;
 | 
			
		||||
  CoglError *skip_error = NULL;
 | 
			
		||||
 | 
			
		||||
  if ((test_utils_is_pot (width) && test_utils_is_pot (height)) ||
 | 
			
		||||
      (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
  tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
 | 
			
		||||
 | 
			
		||||
  cogl_texture_set_components (tex, components);
 | 
			
		||||
 | 
			
		||||
  if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
    {
 | 
			
		||||
      /* First try creating a fast-path non-sliced texture */
 | 
			
		||||
      tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
 | 
			
		||||
                                                         width, height));
 | 
			
		||||
 | 
			
		||||
      cogl_texture_set_components (tex, components);
 | 
			
		||||
 | 
			
		||||
      if (!cogl_texture_allocate (tex, &skip_error))
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (skip_error);
 | 
			
		||||
          cogl_object_unref (tex);
 | 
			
		||||
          tex = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      cogl_error_free (skip_error);
 | 
			
		||||
      cogl_object_unref (tex);
 | 
			
		||||
      tex = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
@@ -452,31 +420,23 @@ test_utils_texture_new_from_bitmap (CoglBitmap *bitmap,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* If that doesn't work try a fast path 2D texture */
 | 
			
		||||
  if ((test_utils_is_pot (cogl_bitmap_get_width (bitmap)) &&
 | 
			
		||||
       test_utils_is_pot (cogl_bitmap_get_height (bitmap))) ||
 | 
			
		||||
      (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
 | 
			
		||||
       cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
 | 
			
		||||
  tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
 | 
			
		||||
 | 
			
		||||
  cogl_texture_set_premultiplied (tex, premultiplied);
 | 
			
		||||
 | 
			
		||||
  if (cogl_error_matches (internal_error,
 | 
			
		||||
                          COGL_SYSTEM_ERROR,
 | 
			
		||||
                          COGL_SYSTEM_ERROR_NO_MEMORY))
 | 
			
		||||
    {
 | 
			
		||||
      tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap));
 | 
			
		||||
 | 
			
		||||
      cogl_texture_set_premultiplied (tex, premultiplied);
 | 
			
		||||
 | 
			
		||||
      if (cogl_error_matches (internal_error,
 | 
			
		||||
                              COGL_SYSTEM_ERROR,
 | 
			
		||||
                              COGL_SYSTEM_ERROR_NO_MEMORY))
 | 
			
		||||
        {
 | 
			
		||||
          g_assert_not_reached ();
 | 
			
		||||
          return NULL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      if (!tex)
 | 
			
		||||
        {
 | 
			
		||||
          cogl_error_free (internal_error);
 | 
			
		||||
          internal_error = NULL;
 | 
			
		||||
        }
 | 
			
		||||
      g_assert_not_reached ();
 | 
			
		||||
      return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
      cogl_error_free (internal_error);
 | 
			
		||||
      internal_error = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    tex = NULL;
 | 
			
		||||
 | 
			
		||||
  if (!tex)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,6 @@ typedef enum _TestFlags
 | 
			
		||||
  TEST_KNOWN_FAILURE = 1<<0,
 | 
			
		||||
  TEST_REQUIREMENT_GL = 1<<1,
 | 
			
		||||
  TEST_REQUIREMENT_NPOT = 1<<2,
 | 
			
		||||
  TEST_REQUIREMENT_TEXTURE_3D = 1<<3,
 | 
			
		||||
  TEST_REQUIREMENT_TEXTURE_RECTANGLE = 1<<4,
 | 
			
		||||
  TEST_REQUIREMENT_TEXTURE_RG = 1<<5,
 | 
			
		||||
  TEST_REQUIREMENT_POINT_SPRITE = 1<<6,
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,6 @@ cogl_test_conformance_sources = [
 | 
			
		||||
  'test-custom-attributes.c',
 | 
			
		||||
  'test-offscreen.c',
 | 
			
		||||
  'test-primitive.c',
 | 
			
		||||
  'test-texture-3d.c',
 | 
			
		||||
  'test-sparse-pipeline.c',
 | 
			
		||||
  'test-read-texture-formats.c',
 | 
			
		||||
  'test-write-texture-formats.c',
 | 
			
		||||
@@ -33,7 +32,6 @@ cogl_test_conformance_sources = [
 | 
			
		||||
  'test-map-buffer-range.c',
 | 
			
		||||
  'test-npot-texture.c',
 | 
			
		||||
  'test-alpha-textures.c',
 | 
			
		||||
  'test-wrap-rectangle-textures.c',
 | 
			
		||||
  'test-texture-get-set-data.c',
 | 
			
		||||
  'test-framebuffer-get-bits.c',
 | 
			
		||||
  'test-primitive-and-journal.c',
 | 
			
		||||
@@ -57,7 +55,6 @@ cogl_test_conformance_sources = [
 | 
			
		||||
#  "test-readpixels.c",
 | 
			
		||||
#  "test-texture-mipmaps.c",
 | 
			
		||||
#  "test-texture-pixmap-x11.c",",
 | 
			
		||||
#  "test-texture-rectangle.c",
 | 
			
		||||
#  "test-vertex-buffer-contiguous.c",
 | 
			
		||||
#  "test-vertex-buffer-interleved.c",
 | 
			
		||||
#  "test-vertex-buffer-mutability.c",
 | 
			
		||||
@@ -102,20 +99,37 @@ libmutter_cogl_test_conformance = executable('test-conformance',
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
find_unit_tests = find_program('meson/find-conform-unit-tests.sh')
 | 
			
		||||
test_conform_main = files(join_paths(meson.current_source_dir(), 'test-conform-main.c'))
 | 
			
		||||
cogl_conform_unit_tests = custom_target('cogl-tests-conform-unit-tests',
 | 
			
		||||
  output: 'unit-tests',
 | 
			
		||||
  input: 'test-conform-main.c',
 | 
			
		||||
  input: test_conform_main,
 | 
			
		||||
  command: [find_unit_tests, '@INPUT@', '@OUTPUT@'],
 | 
			
		||||
  install: have_installed_tests,
 | 
			
		||||
  install_dir: cogl_installed_tests_libexecdir,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
test('cogl/conform', cogl_run_tests,
 | 
			
		||||
  args: [
 | 
			
		||||
    cogl_config_env,
 | 
			
		||||
    libmutter_cogl_test_conformance,
 | 
			
		||||
    cogl_conform_unit_tests
 | 
			
		||||
  ],
 | 
			
		||||
  is_parallel: false,
 | 
			
		||||
  timeout: 120,
 | 
			
		||||
)
 | 
			
		||||
cogl_conformance_tests = run_command(
 | 
			
		||||
  find_unit_tests, test_conform_main, '/dev/stdout',
 | 
			
		||||
  check: true,
 | 
			
		||||
).stdout().strip().split('\n')
 | 
			
		||||
 | 
			
		||||
foreach test_target: cogl_conformance_tests
 | 
			
		||||
  name_parts = []
 | 
			
		||||
  foreach part: test_target.split('_')
 | 
			
		||||
    if part != 'test'
 | 
			
		||||
      name_parts += [part]
 | 
			
		||||
    endif
 | 
			
		||||
  endforeach
 | 
			
		||||
 | 
			
		||||
  test_name = '-'.join(name_parts)
 | 
			
		||||
  test(test_name, cogl_run_tests,
 | 
			
		||||
    suite: ['cogl', 'cogl/conform'],
 | 
			
		||||
    env: ['RUN_TESTS_QUIET=1'],
 | 
			
		||||
    args: [
 | 
			
		||||
      cogl_config_env,
 | 
			
		||||
      libmutter_cogl_test_conformance,
 | 
			
		||||
      test_target
 | 
			
		||||
    ],
 | 
			
		||||
    is_parallel: false,
 | 
			
		||||
  )
 | 
			
		||||
endforeach
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,6 @@
 | 
			
		||||
inputfile="$1"
 | 
			
		||||
outputfile="$2"
 | 
			
		||||
 | 
			
		||||
echo > "$outputfile"
 | 
			
		||||
 | 
			
		||||
sed -n -e 's/^ \{1,\}ADD_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' "$inputfile" | while read -r test; do
 | 
			
		||||
  echo "$test" >> "$outputfile"
 | 
			
		||||
done
 | 
			
		||||
 
 | 
			
		||||
@@ -73,8 +73,6 @@ main (int argc, char **argv)
 | 
			
		||||
  ADD_TEST (test_pixel_buffer_set_data, 0, 0);
 | 
			
		||||
  ADD_TEST (test_pixel_buffer_sub_region, 0, 0);
 | 
			
		||||
  UNPORTED_TEST (test_texture_rectangle);
 | 
			
		||||
  ADD_TEST (test_texture_3d, TEST_REQUIREMENT_TEXTURE_3D,
 | 
			
		||||
            TEST_REQUIREMENT_GL | TEST_KNOWN_FAILURE);
 | 
			
		||||
  ADD_TEST (test_wrap_modes, 0, 0);
 | 
			
		||||
  UNPORTED_TEST (test_texture_pixmap_x11);
 | 
			
		||||
  ADD_TEST (test_texture_get_set_data, 0, 0);
 | 
			
		||||
@@ -82,9 +80,6 @@ main (int argc, char **argv)
 | 
			
		||||
  ADD_TEST (test_read_texture_formats, 0, TEST_KNOWN_FAILURE);
 | 
			
		||||
  ADD_TEST (test_write_texture_formats, 0, 0);
 | 
			
		||||
  ADD_TEST (test_alpha_textures, 0, 0);
 | 
			
		||||
  ADD_TEST (test_wrap_rectangle_textures,
 | 
			
		||||
            TEST_REQUIREMENT_TEXTURE_RECTANGLE,
 | 
			
		||||
            TEST_KNOWN_FAILURE);
 | 
			
		||||
 | 
			
		||||
  UNPORTED_TEST (test_vertex_buffer_contiguous);
 | 
			
		||||
  UNPORTED_TEST (test_vertex_buffer_interleved);
 | 
			
		||||
 
 | 
			
		||||
@@ -16,14 +16,12 @@ void test_sub_texture (void);
 | 
			
		||||
void test_pixel_buffer_map (void);
 | 
			
		||||
void test_pixel_buffer_set_data (void);
 | 
			
		||||
void test_pixel_buffer_sub_region (void);
 | 
			
		||||
void test_texture_3d (void);
 | 
			
		||||
void test_wrap_modes (void);
 | 
			
		||||
void test_texture_get_set_data (void);
 | 
			
		||||
void test_atlas_migration (void);
 | 
			
		||||
void test_read_texture_formats (void);
 | 
			
		||||
void test_write_texture_formats (void);
 | 
			
		||||
void test_alpha_textures (void);
 | 
			
		||||
void test_wrap_rectangle_textures (void);
 | 
			
		||||
void test_primitive (void);
 | 
			
		||||
void test_just_vertex_shader (void);
 | 
			
		||||
void test_pipeline_uniforms (void);
 | 
			
		||||
 
 | 
			
		||||
@@ -106,10 +106,8 @@ make_texture (void)
 | 
			
		||||
        g_print ("Texture is not sliced\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* The texture should be sliced unless NPOTs are supported */
 | 
			
		||||
  g_assert (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT)
 | 
			
		||||
            ? !cogl_texture_is_sliced (tex)
 | 
			
		||||
            : cogl_texture_is_sliced (tex));
 | 
			
		||||
  /* The texture should be sliced unless NPOTs are supported, which they are */
 | 
			
		||||
  g_assert (!cogl_texture_is_sliced (tex));
 | 
			
		||||
 | 
			
		||||
  return tex;
 | 
			
		||||
}
 | 
			
		||||
@@ -147,14 +145,6 @@ paint (void)
 | 
			
		||||
void
 | 
			
		||||
test_npot_texture (void)
 | 
			
		||||
{
 | 
			
		||||
  if (cogl_test_verbose ())
 | 
			
		||||
    {
 | 
			
		||||
      if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
 | 
			
		||||
        g_print ("NPOT textures are supported\n");
 | 
			
		||||
      else
 | 
			
		||||
        g_print ("NPOT textures are not supported\n");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_orthographic (test_fb,
 | 
			
		||||
                                 0, 0,
 | 
			
		||||
                                 cogl_framebuffer_get_width (test_fb),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,275 +0,0 @@
 | 
			
		||||
#include <cogl/cogl.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "test-declarations.h"
 | 
			
		||||
#include "test-utils.h"
 | 
			
		||||
 | 
			
		||||
#define TEX_WIDTH        4
 | 
			
		||||
#define TEX_HEIGHT       8
 | 
			
		||||
#define TEX_DEPTH        16
 | 
			
		||||
/* Leave four bytes of padding between each row */
 | 
			
		||||
#define TEX_ROWSTRIDE    (TEX_WIDTH * 4 + 4)
 | 
			
		||||
/* Leave four rows of padding between each image */
 | 
			
		||||
#define TEX_IMAGE_STRIDE ((TEX_HEIGHT + 4) * TEX_ROWSTRIDE)
 | 
			
		||||
 | 
			
		||||
typedef struct _TestState
 | 
			
		||||
{
 | 
			
		||||
  int fb_width;
 | 
			
		||||
  int fb_height;
 | 
			
		||||
} TestState;
 | 
			
		||||
 | 
			
		||||
static CoglTexture3D *
 | 
			
		||||
create_texture_3d (CoglContext *context)
 | 
			
		||||
{
 | 
			
		||||
  int x, y, z;
 | 
			
		||||
  uint8_t *data = g_malloc (TEX_IMAGE_STRIDE * TEX_DEPTH);
 | 
			
		||||
  uint8_t *p = data;
 | 
			
		||||
  CoglTexture3D *tex;
 | 
			
		||||
  CoglError *error = NULL;
 | 
			
		||||
 | 
			
		||||
  for (z = 0; z < TEX_DEPTH; z++)
 | 
			
		||||
    {
 | 
			
		||||
      for (y = 0; y < TEX_HEIGHT; y++)
 | 
			
		||||
        {
 | 
			
		||||
          for (x = 0; x < TEX_WIDTH; x++)
 | 
			
		||||
            {
 | 
			
		||||
              /* Set red, green, blue to values based on x, y, z */
 | 
			
		||||
              *(p++) = 255 - x * 8;
 | 
			
		||||
              *(p++) = y * 8;
 | 
			
		||||
              *(p++) = 255 - z * 8;
 | 
			
		||||
              /* Fully opaque */
 | 
			
		||||
              *(p++) = 0xff;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          /* Set the padding between rows to 0xde */
 | 
			
		||||
          memset (p, 0xde, TEX_ROWSTRIDE - (TEX_WIDTH * 4));
 | 
			
		||||
          p += TEX_ROWSTRIDE - (TEX_WIDTH * 4);
 | 
			
		||||
        }
 | 
			
		||||
      /* Set the padding between images to 0xad */
 | 
			
		||||
      memset (p, 0xba, TEX_IMAGE_STRIDE - (TEX_HEIGHT * TEX_ROWSTRIDE));
 | 
			
		||||
      p += TEX_IMAGE_STRIDE - (TEX_HEIGHT * TEX_ROWSTRIDE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  tex = cogl_texture_3d_new_from_data (context,
 | 
			
		||||
                                       TEX_WIDTH, TEX_HEIGHT, TEX_DEPTH,
 | 
			
		||||
                                       COGL_PIXEL_FORMAT_RGBA_8888,
 | 
			
		||||
                                       TEX_ROWSTRIDE,
 | 
			
		||||
                                       TEX_IMAGE_STRIDE,
 | 
			
		||||
                                       data,
 | 
			
		||||
                                       &error);
 | 
			
		||||
 | 
			
		||||
  if (tex == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      g_assert (error != NULL);
 | 
			
		||||
      g_warning ("Failed to create 3D texture: %s", error->message);
 | 
			
		||||
      g_assert_not_reached ();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_free (data);
 | 
			
		||||
 | 
			
		||||
  return tex;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
draw_frame (TestState *state)
 | 
			
		||||
{
 | 
			
		||||
  CoglTexture *tex = create_texture_3d (test_ctx);
 | 
			
		||||
  CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
 | 
			
		||||
  typedef struct { float x, y, s, t, r; } Vert;
 | 
			
		||||
  CoglPrimitive *primitive;
 | 
			
		||||
  CoglAttributeBuffer *attribute_buffer;
 | 
			
		||||
  CoglAttribute *attributes[2];
 | 
			
		||||
  Vert *verts, *v;
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  cogl_pipeline_set_layer_texture (pipeline, 0, tex);
 | 
			
		||||
  cogl_object_unref (tex);
 | 
			
		||||
  cogl_pipeline_set_layer_filters (pipeline, 0,
 | 
			
		||||
                                   COGL_PIPELINE_FILTER_NEAREST,
 | 
			
		||||
                                   COGL_PIPELINE_FILTER_NEAREST);
 | 
			
		||||
 | 
			
		||||
  /* Render the texture repeated horizontally twice using a regular
 | 
			
		||||
     cogl rectangle. This should end up with the r texture coordinates
 | 
			
		||||
     as zero */
 | 
			
		||||
  cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline,
 | 
			
		||||
                                            0.0f, 0.0f, TEX_WIDTH * 2, TEX_HEIGHT,
 | 
			
		||||
                                            0.0f, 0.0f, 2.0f, 1.0f);
 | 
			
		||||
 | 
			
		||||
  /* Render all of the images in the texture using coordinates from a
 | 
			
		||||
     CoglPrimitive */
 | 
			
		||||
  v = verts = g_new (Vert, 4 * TEX_DEPTH);
 | 
			
		||||
  for (i = 0; i < TEX_DEPTH; i++)
 | 
			
		||||
    {
 | 
			
		||||
      float r = (i + 0.5f) / TEX_DEPTH;
 | 
			
		||||
 | 
			
		||||
      v->x = i * TEX_WIDTH;
 | 
			
		||||
      v->y = TEX_HEIGHT;
 | 
			
		||||
      v->s = 0;
 | 
			
		||||
      v->t = 0;
 | 
			
		||||
      v->r = r;
 | 
			
		||||
      v++;
 | 
			
		||||
 | 
			
		||||
      v->x = i * TEX_WIDTH;
 | 
			
		||||
      v->y = TEX_HEIGHT * 2;
 | 
			
		||||
      v->s = 0;
 | 
			
		||||
      v->t = 1;
 | 
			
		||||
      v->r = r;
 | 
			
		||||
      v++;
 | 
			
		||||
 | 
			
		||||
      v->x = i * TEX_WIDTH + TEX_WIDTH;
 | 
			
		||||
      v->y = TEX_HEIGHT * 2;
 | 
			
		||||
      v->s = 1;
 | 
			
		||||
      v->t = 1;
 | 
			
		||||
      v->r = r;
 | 
			
		||||
      v++;
 | 
			
		||||
 | 
			
		||||
      v->x = i * TEX_WIDTH + TEX_WIDTH;
 | 
			
		||||
      v->y = TEX_HEIGHT;
 | 
			
		||||
      v->s = 1;
 | 
			
		||||
      v->t = 0;
 | 
			
		||||
      v->r = r;
 | 
			
		||||
      v++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  attribute_buffer = cogl_attribute_buffer_new (test_ctx,
 | 
			
		||||
                                                4 * TEX_DEPTH * sizeof (Vert),
 | 
			
		||||
                                                verts);
 | 
			
		||||
  attributes[0] = cogl_attribute_new (attribute_buffer,
 | 
			
		||||
                                      "cogl_position_in",
 | 
			
		||||
                                      sizeof (Vert),
 | 
			
		||||
                                      G_STRUCT_OFFSET (Vert, x),
 | 
			
		||||
                                      2, /* n_components */
 | 
			
		||||
                                      COGL_ATTRIBUTE_TYPE_FLOAT);
 | 
			
		||||
  attributes[1] = cogl_attribute_new (attribute_buffer,
 | 
			
		||||
                                      "cogl_tex_coord_in",
 | 
			
		||||
                                      sizeof (Vert),
 | 
			
		||||
                                      G_STRUCT_OFFSET (Vert, s),
 | 
			
		||||
                                      3, /* n_components */
 | 
			
		||||
                                      COGL_ATTRIBUTE_TYPE_FLOAT);
 | 
			
		||||
  primitive = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES,
 | 
			
		||||
                                                  6 * TEX_DEPTH,
 | 
			
		||||
                                                  attributes,
 | 
			
		||||
                                                  2 /* n_attributes */);
 | 
			
		||||
 | 
			
		||||
  cogl_primitive_set_indices (primitive,
 | 
			
		||||
                              cogl_get_rectangle_indices (test_ctx,
 | 
			
		||||
                                                          TEX_DEPTH),
 | 
			
		||||
                              6 * TEX_DEPTH);
 | 
			
		||||
 | 
			
		||||
  cogl_primitive_draw (primitive, test_fb, pipeline);
 | 
			
		||||
 | 
			
		||||
  g_free (verts);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (primitive);
 | 
			
		||||
  cogl_object_unref (attributes[0]);
 | 
			
		||||
  cogl_object_unref (attributes[1]);
 | 
			
		||||
  cogl_object_unref (attribute_buffer);
 | 
			
		||||
  cogl_object_unref (pipeline);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
validate_block (int block_x, int block_y, int z)
 | 
			
		||||
{
 | 
			
		||||
  int x, y;
 | 
			
		||||
 | 
			
		||||
  for (y = 0; y < TEX_HEIGHT; y++)
 | 
			
		||||
    for (x = 0; x < TEX_WIDTH; x++)
 | 
			
		||||
      test_utils_check_pixel_rgb (test_fb,
 | 
			
		||||
                                  block_x * TEX_WIDTH + x,
 | 
			
		||||
                                  block_y * TEX_HEIGHT + y,
 | 
			
		||||
                                  255 - x * 8,
 | 
			
		||||
                                  y * 8,
 | 
			
		||||
                                  255 - z * 8);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
validate_result (void)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
 | 
			
		||||
  validate_block (0, 0, 0);
 | 
			
		||||
 | 
			
		||||
  for (i = 0; i < TEX_DEPTH; i++)
 | 
			
		||||
    validate_block (i, 1, i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_multi_texture (TestState *state)
 | 
			
		||||
{
 | 
			
		||||
  CoglPipeline *pipeline;
 | 
			
		||||
  CoglTexture3D *tex_3d;
 | 
			
		||||
  CoglTexture2D *tex_2d;
 | 
			
		||||
  uint8_t tex_data[4];
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
 | 
			
		||||
 | 
			
		||||
  /* Tests a pipeline that is using multi-texturing to combine a 3D
 | 
			
		||||
     texture with a 2D texture. The texture from another layer is
 | 
			
		||||
     sampled with TEXTURE_? just to pick up a specific bug that was
 | 
			
		||||
     happening with the ARBfp fragend */
 | 
			
		||||
 | 
			
		||||
  pipeline = cogl_pipeline_new (test_ctx);
 | 
			
		||||
 | 
			
		||||
  tex_data[0] = 0xff;
 | 
			
		||||
  tex_data[1] = 0x00;
 | 
			
		||||
  tex_data[2] = 0x00;
 | 
			
		||||
  tex_data[3] = 0xff;
 | 
			
		||||
  tex_2d = cogl_texture_2d_new_from_data (test_ctx,
 | 
			
		||||
                                          1, 1, /* width/height */
 | 
			
		||||
                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                                          4, /* rowstride */
 | 
			
		||||
                                          tex_data,
 | 
			
		||||
                                          NULL);
 | 
			
		||||
  cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d);
 | 
			
		||||
 | 
			
		||||
  tex_data[0] = 0x00;
 | 
			
		||||
  tex_data[1] = 0xff;
 | 
			
		||||
  tex_data[2] = 0x00;
 | 
			
		||||
  tex_data[3] = 0xff;
 | 
			
		||||
  tex_3d = cogl_texture_3d_new_from_data (test_ctx,
 | 
			
		||||
                                          1, 1, 1, /* width/height/depth */
 | 
			
		||||
                                          COGL_PIXEL_FORMAT_RGBA_8888_PRE,
 | 
			
		||||
                                          4, /* rowstride */
 | 
			
		||||
                                          4, /* image_stride */
 | 
			
		||||
                                          tex_data,
 | 
			
		||||
                                          NULL);
 | 
			
		||||
  cogl_pipeline_set_layer_texture (pipeline, 1, tex_3d);
 | 
			
		||||
 | 
			
		||||
  cogl_pipeline_set_layer_combine (pipeline, 0,
 | 
			
		||||
                                   "RGBA = REPLACE(PREVIOUS)",
 | 
			
		||||
                                   NULL);
 | 
			
		||||
  cogl_pipeline_set_layer_combine (pipeline, 1,
 | 
			
		||||
                                   "RGBA = ADD(TEXTURE_0, TEXTURE_1)",
 | 
			
		||||
                                   NULL);
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 10, 10);
 | 
			
		||||
 | 
			
		||||
  test_utils_check_pixel (test_fb, 5, 5, 0xffff00ff);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (tex_2d);
 | 
			
		||||
  cogl_object_unref (tex_3d);
 | 
			
		||||
  cogl_object_unref (pipeline);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
test_texture_3d (void)
 | 
			
		||||
{
 | 
			
		||||
  TestState state;
 | 
			
		||||
 | 
			
		||||
  state.fb_width = cogl_framebuffer_get_width (test_fb);
 | 
			
		||||
  state.fb_height = cogl_framebuffer_get_height (test_fb);
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_orthographic (test_fb,
 | 
			
		||||
                                 0, 0, /* x_1, y_1 */
 | 
			
		||||
                                 state.fb_width, /* x_2 */
 | 
			
		||||
                                 state.fb_height /* y_2 */,
 | 
			
		||||
                                 -1, 100 /* near/far */);
 | 
			
		||||
 | 
			
		||||
  draw_frame (&state);
 | 
			
		||||
  validate_result ();
 | 
			
		||||
 | 
			
		||||
  test_multi_texture (&state);
 | 
			
		||||
 | 
			
		||||
  if (cogl_test_verbose ())
 | 
			
		||||
    g_print ("OK\n");
 | 
			
		||||
}
 | 
			
		||||
@@ -60,22 +60,4 @@ test_texture_no_allocate (void)
 | 
			
		||||
  texture_2d = cogl_texture_2d_new_with_size (test_ctx,
 | 
			
		||||
                                              64, 64);
 | 
			
		||||
  cogl_object_unref (texture_2d);
 | 
			
		||||
 | 
			
		||||
  /* 3D texture */
 | 
			
		||||
  if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_3D))
 | 
			
		||||
    {
 | 
			
		||||
      CoglTexture3D *texture_3d =
 | 
			
		||||
        cogl_texture_3d_new_with_size (test_ctx,
 | 
			
		||||
                                       64, 64, 64);
 | 
			
		||||
      cogl_object_unref (texture_3d);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Rectangle texture */
 | 
			
		||||
  if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
 | 
			
		||||
    {
 | 
			
		||||
      CoglTextureRectangle *texture_rect =
 | 
			
		||||
        cogl_texture_rectangle_new_with_size (test_ctx,
 | 
			
		||||
                                              64, 64);
 | 
			
		||||
      cogl_object_unref (texture_rect);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,176 +0,0 @@
 | 
			
		||||
#include <cogl/cogl.h>
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "test-declarations.h"
 | 
			
		||||
#include "test-utils.h"
 | 
			
		||||
 | 
			
		||||
#define DRAW_SIZE 64
 | 
			
		||||
 | 
			
		||||
static CoglPipeline *
 | 
			
		||||
create_base_pipeline (void)
 | 
			
		||||
{
 | 
			
		||||
  CoglBitmap *bmp;
 | 
			
		||||
  CoglTextureRectangle *tex;
 | 
			
		||||
  CoglPipeline *pipeline;
 | 
			
		||||
  uint8_t tex_data[] =
 | 
			
		||||
    {
 | 
			
		||||
      0x44, 0x44, 0x44, 0x88, 0x88, 0x88,
 | 
			
		||||
      0xcc, 0xcc, 0xcc, 0xff, 0xff, 0xff
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  bmp = cogl_bitmap_new_for_data (test_ctx,
 | 
			
		||||
                                  2, 2, /* width/height */
 | 
			
		||||
                                  COGL_PIXEL_FORMAT_RGB_888,
 | 
			
		||||
                                  2 * 3, /* rowstride */
 | 
			
		||||
                                  tex_data);
 | 
			
		||||
 | 
			
		||||
  tex = cogl_texture_rectangle_new_from_bitmap (bmp);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (bmp);
 | 
			
		||||
 | 
			
		||||
  pipeline = cogl_pipeline_new (test_ctx);
 | 
			
		||||
 | 
			
		||||
  cogl_pipeline_set_layer_filters (pipeline,
 | 
			
		||||
                                   0, /* layer */
 | 
			
		||||
                                   COGL_PIPELINE_FILTER_NEAREST,
 | 
			
		||||
                                   COGL_PIPELINE_FILTER_NEAREST);
 | 
			
		||||
 | 
			
		||||
  cogl_pipeline_set_layer_texture (pipeline,
 | 
			
		||||
                                   0, /* layer */
 | 
			
		||||
                                   tex);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (tex);
 | 
			
		||||
 | 
			
		||||
  return pipeline;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
check_colors (int x_offset,
 | 
			
		||||
              int y_offset,
 | 
			
		||||
              const uint8_t expected_colors[9])
 | 
			
		||||
{
 | 
			
		||||
  int x, y;
 | 
			
		||||
 | 
			
		||||
  for (y = 0; y < 4; y++)
 | 
			
		||||
    for (x = 0; x < 4; x++)
 | 
			
		||||
      {
 | 
			
		||||
        uint32_t color = expected_colors[x + y * 4];
 | 
			
		||||
        test_utils_check_region (test_fb,
 | 
			
		||||
                                 x * DRAW_SIZE / 4 + 1 + x_offset,
 | 
			
		||||
                                 y * DRAW_SIZE / 4 + 1 + y_offset,
 | 
			
		||||
                                 DRAW_SIZE / 4 - 2,
 | 
			
		||||
                                 DRAW_SIZE / 4 - 2,
 | 
			
		||||
                                 0xff |
 | 
			
		||||
                                 (color << 8) |
 | 
			
		||||
                                 (color << 16) |
 | 
			
		||||
                                 (color << 24));
 | 
			
		||||
      }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
test_pipeline (CoglPipeline *pipeline,
 | 
			
		||||
               int x_offset,
 | 
			
		||||
               int y_offset,
 | 
			
		||||
               const uint8_t expected_colors[9])
 | 
			
		||||
{
 | 
			
		||||
  float x1 = x_offset;
 | 
			
		||||
  float y1 = y_offset;
 | 
			
		||||
  float x2 = x1 + DRAW_SIZE;
 | 
			
		||||
  float y2 = y1 + DRAW_SIZE;
 | 
			
		||||
  int y, x;
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_draw_textured_rectangle (test_fb,
 | 
			
		||||
                                            pipeline,
 | 
			
		||||
                                            x1, y1,
 | 
			
		||||
                                            x2, y2,
 | 
			
		||||
                                            -0.5f, /* s1 */
 | 
			
		||||
                                            -0.5f, /* t1 */
 | 
			
		||||
                                            1.5f, /* s2 */
 | 
			
		||||
                                            1.5f /* t2 */);
 | 
			
		||||
 | 
			
		||||
  check_colors (x_offset, y_offset, expected_colors);
 | 
			
		||||
 | 
			
		||||
  /* Also try drawing each quadrant of the rectangle with a small
 | 
			
		||||
   * rectangle */
 | 
			
		||||
 | 
			
		||||
  for (y = -1; y < 3; y++)
 | 
			
		||||
    for (x = -1; x < 3; x++)
 | 
			
		||||
      {
 | 
			
		||||
        x1 = x_offset + (x + 1) * DRAW_SIZE / 4 + DRAW_SIZE;
 | 
			
		||||
        y1 = y_offset + (y + 1) * DRAW_SIZE / 4;
 | 
			
		||||
        x2 = x1 + DRAW_SIZE / 4;
 | 
			
		||||
        y2 = y1 + DRAW_SIZE / 4;
 | 
			
		||||
 | 
			
		||||
        cogl_framebuffer_draw_textured_rectangle (test_fb,
 | 
			
		||||
                                                  pipeline,
 | 
			
		||||
                                                  x1, y1,
 | 
			
		||||
                                                  x2, y2,
 | 
			
		||||
                                                  x / 2.0f, /* s1 */
 | 
			
		||||
                                                  y / 2.0f, /* t1 */
 | 
			
		||||
                                                  (x + 1) / 2.0f, /* s2 */
 | 
			
		||||
                                                  (y + 1) / 2.0f /* t2 */);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
  check_colors (x_offset + DRAW_SIZE, y_offset, expected_colors);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
test_wrap_rectangle_textures (void)
 | 
			
		||||
{
 | 
			
		||||
  float fb_width = cogl_framebuffer_get_width (test_fb);
 | 
			
		||||
  float fb_height = cogl_framebuffer_get_height (test_fb);
 | 
			
		||||
  CoglPipeline *base_pipeline;
 | 
			
		||||
  CoglPipeline *clamp_pipeline;
 | 
			
		||||
  CoglPipeline *repeat_pipeline;
 | 
			
		||||
  /* The textures are drawn with the texture coordinates from
 | 
			
		||||
   * -0.5→1.5. That means we get one complete copy of the texture and
 | 
			
		||||
   * an extra half of the texture surrounding it. The drawing is
 | 
			
		||||
   * tested against a 4x4 grid of colors. The center 2x2 colours
 | 
			
		||||
   * specify the normal texture colors and the other colours specify
 | 
			
		||||
   * what the wrap mode should generate */
 | 
			
		||||
  static const uint8_t clamp_colors[] =
 | 
			
		||||
    {
 | 
			
		||||
      0x44, 0x44, 0x88, 0x88,
 | 
			
		||||
      0x44, 0x44, 0x88, 0x88,
 | 
			
		||||
      0xcc, 0xcc, 0xff, 0xff,
 | 
			
		||||
      0xcc, 0xcc, 0xff, 0xff
 | 
			
		||||
    };
 | 
			
		||||
  static const uint8_t repeat_colors[] =
 | 
			
		||||
    {
 | 
			
		||||
      0xff, 0xcc, 0xff, 0xcc,
 | 
			
		||||
      0x88, 0x44, 0x88, 0x44,
 | 
			
		||||
      0xff, 0xcc, 0xff, 0xcc,
 | 
			
		||||
      0x88, 0x44, 0x88, 0x44
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  cogl_framebuffer_orthographic (test_fb,
 | 
			
		||||
                                 0, 0, /* x_1, y_1 */
 | 
			
		||||
                                 fb_width, /* x_2 */
 | 
			
		||||
                                 fb_height /* y_2 */,
 | 
			
		||||
                                 -1, 100 /* near/far */);
 | 
			
		||||
 | 
			
		||||
  base_pipeline = create_base_pipeline ();
 | 
			
		||||
 | 
			
		||||
  clamp_pipeline = cogl_pipeline_copy (base_pipeline);
 | 
			
		||||
  cogl_pipeline_set_layer_wrap_mode (clamp_pipeline,
 | 
			
		||||
                                     0, /* layer */
 | 
			
		||||
                                     COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
 | 
			
		||||
 | 
			
		||||
  repeat_pipeline = cogl_pipeline_copy (base_pipeline);
 | 
			
		||||
  cogl_pipeline_set_layer_wrap_mode (repeat_pipeline,
 | 
			
		||||
                                     0, /* layer */
 | 
			
		||||
                                     COGL_PIPELINE_WRAP_MODE_REPEAT);
 | 
			
		||||
 | 
			
		||||
  test_pipeline (clamp_pipeline,
 | 
			
		||||
                 0, 0, /* x/y offset */
 | 
			
		||||
                 clamp_colors);
 | 
			
		||||
 | 
			
		||||
  test_pipeline (repeat_pipeline,
 | 
			
		||||
                 0, DRAW_SIZE * 2, /* x/y offset */
 | 
			
		||||
                 repeat_colors);
 | 
			
		||||
 | 
			
		||||
  cogl_object_unref (repeat_pipeline);
 | 
			
		||||
  cogl_object_unref (clamp_pipeline);
 | 
			
		||||
  cogl_object_unref (base_pipeline);
 | 
			
		||||
}
 | 
			
		||||
@@ -14,7 +14,7 @@ shift
 | 
			
		||||
TEST_BINARY=$1
 | 
			
		||||
shift
 | 
			
		||||
 | 
			
		||||
UNIT_TESTS_FILE=$1
 | 
			
		||||
UNIT_TESTS=$1
 | 
			
		||||
shift
 | 
			
		||||
 | 
			
		||||
. "$ENVIRONMENT_CONFIG"
 | 
			
		||||
@@ -32,13 +32,15 @@ EXIT=0
 | 
			
		||||
MISSING_FEATURE="WARNING: Missing required feature";
 | 
			
		||||
KNOWN_FAILURE="WARNING: Test is known to fail";
 | 
			
		||||
 | 
			
		||||
echo "Key:"
 | 
			
		||||
echo "ok = Test passed"
 | 
			
		||||
echo "n/a = Driver is missing a feature required for the test"
 | 
			
		||||
echo "FAIL = Unexpected failure"
 | 
			
		||||
echo "FIXME = Test failed, but it was an expected failure"
 | 
			
		||||
echo "PASS! = Unexpected pass"
 | 
			
		||||
echo ""
 | 
			
		||||
if [ -z "$RUN_TESTS_QUIET" ]; then
 | 
			
		||||
  echo "Key:"
 | 
			
		||||
  echo "ok = Test passed"
 | 
			
		||||
  echo "n/a = Driver is missing a feature required for the test"
 | 
			
		||||
  echo "FAIL = Unexpected failure"
 | 
			
		||||
  echo "FIXME = Test failed, but it was an expected failure"
 | 
			
		||||
  echo "PASS! = Unexpected pass"
 | 
			
		||||
  echo ""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
get_status()
 | 
			
		||||
{
 | 
			
		||||
@@ -88,28 +90,36 @@ run_test()
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [ -z "$UNIT_TESTS" ]; then
 | 
			
		||||
  echo Missing unit-tests file or names
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
TITLE_FORMAT="%35s"
 | 
			
		||||
printf "$TITLE_FORMAT" "Test"
 | 
			
		||||
 | 
			
		||||
if test "$HAVE_GL" -eq 1; then
 | 
			
		||||
  GL_FORMAT=" %6s %8s %7s %6s %6s"
 | 
			
		||||
  printf "$GL_FORMAT" "GL+GLSL" "GL-NPT" "GL3"
 | 
			
		||||
  GL_FORMAT=" %6s %8s %7s %6s"
 | 
			
		||||
  printf "$GL_FORMAT" "GL+GLSL" "GL3"
 | 
			
		||||
fi
 | 
			
		||||
if test "$HAVE_GLES2" -eq 1; then
 | 
			
		||||
  GLES2_FORMAT=" %6s %7s"
 | 
			
		||||
  printf "$GLES2_FORMAT" "ES2" "ES2-NPT"
 | 
			
		||||
  GLES2_FORMAT=" %6s"
 | 
			
		||||
  printf "$GLES2_FORMAT" "ES2"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo ""
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
if [ ! -f "$UNIT_TESTS_FILE" ]; then
 | 
			
		||||
  echo Missing unit-tests file
 | 
			
		||||
  exit 1
 | 
			
		||||
if [ -f "$UNIT_TESTS" ]; then
 | 
			
		||||
  UNIT_TESTS="$(cat $UNIT_TESTS)"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
for test in $(cat "$UNIT_TESTS_FILE")
 | 
			
		||||
if [ -z "$RUN_TESTS_QUIET" ] || [ "$(echo "$UNIT_TESTS" | wc -w )" -gt 1 ]; then
 | 
			
		||||
  echo ""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
for test in $UNIT_TESTS
 | 
			
		||||
do
 | 
			
		||||
  printf $TITLE_FORMAT "$test:"
 | 
			
		||||
  export COGL_DEBUG=
 | 
			
		||||
 | 
			
		||||
  if test "$HAVE_GL" -eq 1; then
 | 
			
		||||
@@ -124,10 +134,6 @@ do
 | 
			
		||||
    export COGL_DEBUG=disable-fixed,disable-arbfp
 | 
			
		||||
    run_test "$test" gl_glsl
 | 
			
		||||
 | 
			
		||||
    export COGL_DRIVER=gl
 | 
			
		||||
    export COGL_DEBUG=disable-npot-textures
 | 
			
		||||
    run_test "$test" gl_npot
 | 
			
		||||
 | 
			
		||||
    export COGL_DRIVER=gl3
 | 
			
		||||
    export COGL_DEBUG=
 | 
			
		||||
    run_test "$test" gl3
 | 
			
		||||
@@ -137,23 +143,16 @@ do
 | 
			
		||||
    export COGL_DRIVER=gles2
 | 
			
		||||
    export COGL_DEBUG=
 | 
			
		||||
    run_test "$test" gles2
 | 
			
		||||
 | 
			
		||||
    export COGL_DRIVER=gles2
 | 
			
		||||
    export COGL_DEBUG=disable-npot-textures
 | 
			
		||||
    run_test "$test" gles2_npot
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  printf $TITLE_FORMAT "$test:"
 | 
			
		||||
  if test "$HAVE_GL" -eq 1; then
 | 
			
		||||
    printf "$GL_FORMAT" \
 | 
			
		||||
      "$(get_status "$gl_glsl_result")" \
 | 
			
		||||
      "$(get_status "$gl_npot_result")" \
 | 
			
		||||
      "$(get_status "$gl3_result")"
 | 
			
		||||
  fi
 | 
			
		||||
  if test "$HAVE_GLES2" -eq 1; then
 | 
			
		||||
    printf "$GLES2_FORMAT" \
 | 
			
		||||
      "$(get_status "$gles2_result")" \
 | 
			
		||||
      "$(get_status "$gles2_npot_result")"
 | 
			
		||||
      "$(get_status "$gles2_result")"
 | 
			
		||||
  fi
 | 
			
		||||
  echo ""
 | 
			
		||||
done
 | 
			
		||||
 
 | 
			
		||||
@@ -23,19 +23,21 @@ libmutter_cogl_test_unit = executable('test-unit',
 | 
			
		||||
  install: false,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
find_unit_tests = find_program('meson/find-unit-tests.sh')
 | 
			
		||||
cogl_unit_unit_tests = custom_target('cogl-tests-unit-unit-tests',
 | 
			
		||||
  output: 'unit-tests',
 | 
			
		||||
  input: libmutter_cogl,
 | 
			
		||||
  command: [find_unit_tests, '@INPUT@', '@OUTPUT@'],
 | 
			
		||||
  install: false,
 | 
			
		||||
)
 | 
			
		||||
cogl_unit_tests = run_command(
 | 
			
		||||
  find_program('meson/find-unit-tests.sh'), cogl_srcdir, '/dev/stdout',
 | 
			
		||||
  check: true,
 | 
			
		||||
).stdout().strip().split('\n')
 | 
			
		||||
 | 
			
		||||
test('cogl/unit', cogl_run_tests,
 | 
			
		||||
  args: [
 | 
			
		||||
    cogl_config_env,
 | 
			
		||||
    libmutter_cogl_test_unit,
 | 
			
		||||
    cogl_unit_unit_tests
 | 
			
		||||
  ],
 | 
			
		||||
  is_parallel: false,
 | 
			
		||||
)
 | 
			
		||||
foreach test_target: cogl_unit_tests
 | 
			
		||||
  test_name = '-'.join(test_target.split('_'))
 | 
			
		||||
  test(test_name, cogl_run_tests,
 | 
			
		||||
    suite: ['cogl', 'cogl/unit'],
 | 
			
		||||
    env: ['RUN_TESTS_QUIET=1'],
 | 
			
		||||
    args: [
 | 
			
		||||
      cogl_config_env,
 | 
			
		||||
      libmutter_cogl_test_unit,
 | 
			
		||||
      'unit_test_' + test_target
 | 
			
		||||
    ],
 | 
			
		||||
    is_parallel: false,
 | 
			
		||||
  )
 | 
			
		||||
endforeach
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user