Remove intel_state.c, intel_rotate.[ch]

This commit is contained in:
Keith Whitwell 2007-08-02 14:56:44 +01:00
parent 107206bbbe
commit 3dfe125861
7 changed files with 0 additions and 603 deletions

View file

@ -26,9 +26,7 @@ DRIVER_SOURCES = \
intel_blit.c \
intel_context.c \
intel_ioctl.c \
intel_rotate.c \
intel_screen.c \
intel_state.c \
intel_surface.c \
intel_fbo.c \
intel_depthstencil.c \

View file

@ -330,7 +330,6 @@ intelInitDriverFunctions(struct dd_function_table *functions)
intelInitTextureFuncs(functions);
intelInitPixelFuncs(functions);
intelInitStateFuncs(functions);
intelInitBufferFuncs(functions);
}

View file

@ -334,72 +334,10 @@ extern void intelFlush(GLcontext * ctx);
extern void intelInitDriverFunctions(struct dd_function_table *functions);
/* ================================================================
* intel_state.c:
*/
extern void intelInitStateFuncs(struct dd_function_table *functions);
#define COMPAREFUNC_ALWAYS 0
#define COMPAREFUNC_NEVER 0x1
#define COMPAREFUNC_LESS 0x2
#define COMPAREFUNC_EQUAL 0x3
#define COMPAREFUNC_LEQUAL 0x4
#define COMPAREFUNC_GREATER 0x5
#define COMPAREFUNC_NOTEQUAL 0x6
#define COMPAREFUNC_GEQUAL 0x7
#define STENCILOP_KEEP 0
#define STENCILOP_ZERO 0x1
#define STENCILOP_REPLACE 0x2
#define STENCILOP_INCRSAT 0x3
#define STENCILOP_DECRSAT 0x4
#define STENCILOP_INCR 0x5
#define STENCILOP_DECR 0x6
#define STENCILOP_INVERT 0x7
#define LOGICOP_CLEAR 0
#define LOGICOP_NOR 0x1
#define LOGICOP_AND_INV 0x2
#define LOGICOP_COPY_INV 0x3
#define LOGICOP_AND_RVRSE 0x4
#define LOGICOP_INV 0x5
#define LOGICOP_XOR 0x6
#define LOGICOP_NAND 0x7
#define LOGICOP_AND 0x8
#define LOGICOP_EQUIV 0x9
#define LOGICOP_NOOP 0xa
#define LOGICOP_OR_INV 0xb
#define LOGICOP_COPY 0xc
#define LOGICOP_OR_RVRSE 0xd
#define LOGICOP_OR 0xe
#define LOGICOP_SET 0xf
#define BLENDFACT_ZERO 0x01
#define BLENDFACT_ONE 0x02
#define BLENDFACT_SRC_COLR 0x03
#define BLENDFACT_INV_SRC_COLR 0x04
#define BLENDFACT_SRC_ALPHA 0x05
#define BLENDFACT_INV_SRC_ALPHA 0x06
#define BLENDFACT_DST_ALPHA 0x07
#define BLENDFACT_INV_DST_ALPHA 0x08
#define BLENDFACT_DST_COLR 0x09
#define BLENDFACT_INV_DST_COLR 0x0a
#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
#define BLENDFACT_CONST_COLOR 0x0c
#define BLENDFACT_INV_CONST_COLOR 0x0d
#define BLENDFACT_CONST_ALPHA 0x0e
#define BLENDFACT_INV_CONST_ALPHA 0x0f
#define BLENDFACT_MASK 0x0f
#define MI_BATCH_BUFFER_END (0xA<<23)
extern int intel_translate_compare_func(GLenum func);
extern int intel_translate_stencil_op(GLenum op);
extern int intel_translate_blend_factor(GLenum factor);
extern int intel_translate_logic_op(GLenum opcode);
/*======================================================================
* Inline conversion functions.
* These are better-typed than the macros used previously:

View file

@ -1,237 +0,0 @@
/**
* Routines for simple 2D->2D transformations for rotated, flipped screens.
*
* XXX This code is not intel-specific. Move it into a common/utility
* someday.
*/
#include "intel_rotate.h"
#define MIN2(A, B) ( ((A) < (B)) ? (A) : (B) )
#define ABS(A) ( ((A) < 0) ? -(A) : (A) )
void
matrix23Set(struct matrix23 *m,
int m00, int m01, int m02, int m10, int m11, int m12)
{
m->m00 = m00;
m->m01 = m01;
m->m02 = m02;
m->m10 = m10;
m->m11 = m11;
m->m12 = m12;
}
/*
* Transform (x,y) coordinate by the given matrix.
*/
void
matrix23TransformCoordf(const struct matrix23 *m, float *x, float *y)
{
const float x0 = *x;
const float y0 = *y;
*x = m->m00 * x0 + m->m01 * y0 + m->m02;
*y = m->m10 * x0 + m->m11 * y0 + m->m12;
}
void
matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y)
{
const int x0 = *x;
const int y0 = *y;
*x = m->m00 * x0 + m->m01 * y0 + m->m02;
*y = m->m10 * x0 + m->m11 * y0 + m->m12;
}
/*
* Transform a width and height by the given matrix.
* XXX this could be optimized quite a bit.
*/
void
matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist)
{
int x0 = 0, y0 = 0;
int x1 = *xDist, y1 = 0;
int x2 = 0, y2 = *yDist;
matrix23TransformCoordi(m, &x0, &y0);
matrix23TransformCoordi(m, &x1, &y1);
matrix23TransformCoordi(m, &x2, &y2);
*xDist = (x1 - x0) + (x2 - x0);
*yDist = (y1 - y0) + (y2 - y0);
if (*xDist < 0)
*xDist = -*xDist;
if (*yDist < 0)
*yDist = -*yDist;
}
/**
* Transform the rect defined by (x, y, w, h) by m.
*/
void
matrix23TransformRect(const struct matrix23 *m, int *x, int *y, int *w,
int *h)
{
int x0 = *x, y0 = *y;
int x1 = *x + *w, y1 = *y;
int x2 = *x + *w, y2 = *y + *h;
int x3 = *x, y3 = *y + *h;
matrix23TransformCoordi(m, &x0, &y0);
matrix23TransformCoordi(m, &x1, &y1);
matrix23TransformCoordi(m, &x2, &y2);
matrix23TransformCoordi(m, &x3, &y3);
*w = ABS(x1 - x0) + ABS(x2 - x1);
/**w = ABS(*w);*/
*h = ABS(y1 - y0) + ABS(y2 - y1);
/**h = ABS(*h);*/
*x = MIN2(x0, x1);
*x = MIN2(*x, x2);
*y = MIN2(y0, y1);
*y = MIN2(*y, y2);
}
/*
* Make rotation matrix for width X height screen.
*/
void
matrix23Rotate(struct matrix23 *m, int width, int height, int angle)
{
switch (angle) {
case 0:
matrix23Set(m, 1, 0, 0, 0, 1, 0);
break;
case 90:
matrix23Set(m, 0, 1, 0, -1, 0, width);
break;
case 180:
matrix23Set(m, -1, 0, width, 0, -1, height);
break;
case 270:
matrix23Set(m, 0, -1, height, 1, 0, 0);
break;
default:
/*abort() */ ;
}
}
/*
* Make flip/reflection matrix for width X height screen.
*/
void
matrix23Flip(struct matrix23 *m, int width, int height, int xflip, int yflip)
{
if (xflip) {
m->m00 = -1;
m->m01 = 0;
m->m02 = width - 1;
}
else {
m->m00 = 1;
m->m01 = 0;
m->m02 = 0;
}
if (yflip) {
m->m10 = 0;
m->m11 = -1;
m->m12 = height - 1;
}
else {
m->m10 = 0;
m->m11 = 1;
m->m12 = 0;
}
}
/*
* result = a * b
*/
void
matrix23Multiply(struct matrix23 *result,
const struct matrix23 *a, const struct matrix23 *b)
{
result->m00 = a->m00 * b->m00 + a->m01 * b->m10;
result->m01 = a->m00 * b->m01 + a->m01 * b->m11;
result->m02 = a->m00 * b->m02 + a->m01 * b->m12 + a->m02;
result->m10 = a->m10 * b->m00 + a->m11 * b->m10;
result->m11 = a->m10 * b->m01 + a->m11 * b->m11;
result->m12 = a->m10 * b->m02 + a->m11 * b->m12 + a->m12;
}
#if 000
#include <stdio.h>
int
main(int argc, char *argv[])
{
int width = 500, height = 400;
int rot;
int fx = 0, fy = 0; /* flip x and/or y ? */
int coords[4][2];
/* four corner coords to test with */
coords[0][0] = 0;
coords[0][1] = 0;
coords[1][0] = width - 1;
coords[1][1] = 0;
coords[2][0] = width - 1;
coords[2][1] = height - 1;
coords[3][0] = 0;
coords[3][1] = height - 1;
for (rot = 0; rot < 360; rot += 90) {
struct matrix23 rotate, flip, m;
int i;
printf("Rot %d, xFlip %d, yFlip %d:\n", rot, fx, fy);
/* make transformation matrix 'm' */
matrix23Rotate(&rotate, width, height, rot);
matrix23Flip(&flip, width, height, fx, fy);
matrix23Multiply(&m, &rotate, &flip);
/* xform four coords */
for (i = 0; i < 4; i++) {
int x = coords[i][0];
int y = coords[i][1];
matrix23TransformCoordi(&m, &x, &y);
printf(" %d, %d -> %d %d\n", coords[i][0], coords[i][1], x, y);
}
/* xform width, height */
{
int x = width;
int y = height;
matrix23TransformDistance(&m, &x, &y);
printf(" %d x %d -> %d x %d\n", width, height, x, y);
}
/* xform rect */
{
int x = 50, y = 10, w = 200, h = 100;
matrix23TransformRect(&m, &x, &y, &w, &h);
printf(" %d,%d %d x %d -> %d, %d %d x %d\n", 50, 10, 200, 100,
x, y, w, h);
}
}
return 0;
}
#endif

View file

@ -1,39 +0,0 @@
#ifndef INTEL_ROTATE_H
#define INTEL_ROTATE_H 1
struct matrix23
{
int m00, m01, m02;
int m10, m11, m12;
};
extern void
matrix23Set(struct matrix23 *m,
int m00, int m01, int m02, int m10, int m11, int m12);
extern void matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y);
extern void
matrix23TransformCoordf(const struct matrix23 *m, float *x, float *y);
extern void
matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist);
extern void
matrix23TransformRect(const struct matrix23 *m,
int *x, int *y, int *w, int *h);
extern void
matrix23Rotate(struct matrix23 *m, int width, int height, int angle);
extern void
matrix23Flip(struct matrix23 *m, int width, int height, int xflip, int yflip);
extern void
matrix23Multiply(struct matrix23 *result,
const struct matrix23 *a, const struct matrix23 *b);
#endif /* INTEL_ROTATE_H */

View file

@ -29,7 +29,6 @@
#define _INTEL_SCREEN_H_
#include "dri_util.h"
#include "intel_rotate.h"
#include "i830_common.h"
#include "xmlconfig.h"
#include "dri_bufpool.h"
@ -65,7 +64,6 @@ typedef struct
int irq_active;
int allow_batchbuffer;
struct matrix23 rotMatrix;
/**
@ -112,8 +110,6 @@ extern struct _DriBufferPool *driBatchPoolInit(int fd, unsigned flags,
extern struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen);
extern void
intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea);
extern GLboolean
intelCreatePools(intelScreenPrivate *intelScreen);

View file

@ -1,258 +0,0 @@
/**************************************************************************
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* 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, sub license, 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 (including the
* next paragraph) 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 NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
*
**************************************************************************/
#include "glheader.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
#include "colormac.h"
#include "dd.h"
#include "intel_screen.h"
#include "intel_context.h"
#include "intel_fbo.h"
#include "swrast/swrast.h"
int
intel_translate_compare_func(GLenum func)
{
switch (func) {
case GL_NEVER:
return COMPAREFUNC_NEVER;
case GL_LESS:
return COMPAREFUNC_LESS;
case GL_LEQUAL:
return COMPAREFUNC_LEQUAL;
case GL_GREATER:
return COMPAREFUNC_GREATER;
case GL_GEQUAL:
return COMPAREFUNC_GEQUAL;
case GL_NOTEQUAL:
return COMPAREFUNC_NOTEQUAL;
case GL_EQUAL:
return COMPAREFUNC_EQUAL;
case GL_ALWAYS:
return COMPAREFUNC_ALWAYS;
}
fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
return COMPAREFUNC_ALWAYS;
}
int
intel_translate_stencil_op(GLenum op)
{
switch (op) {
case GL_KEEP:
return STENCILOP_KEEP;
case GL_ZERO:
return STENCILOP_ZERO;
case GL_REPLACE:
return STENCILOP_REPLACE;
case GL_INCR:
return STENCILOP_INCRSAT;
case GL_DECR:
return STENCILOP_DECRSAT;
case GL_INCR_WRAP:
return STENCILOP_INCR;
case GL_DECR_WRAP:
return STENCILOP_DECR;
case GL_INVERT:
return STENCILOP_INVERT;
default:
return STENCILOP_ZERO;
}
}
int
intel_translate_blend_factor(GLenum factor)
{
switch (factor) {
case GL_ZERO:
return BLENDFACT_ZERO;
case GL_SRC_ALPHA:
return BLENDFACT_SRC_ALPHA;
case GL_ONE:
return BLENDFACT_ONE;
case GL_SRC_COLOR:
return BLENDFACT_SRC_COLR;
case GL_ONE_MINUS_SRC_COLOR:
return BLENDFACT_INV_SRC_COLR;
case GL_DST_COLOR:
return BLENDFACT_DST_COLR;
case GL_ONE_MINUS_DST_COLOR:
return BLENDFACT_INV_DST_COLR;
case GL_ONE_MINUS_SRC_ALPHA:
return BLENDFACT_INV_SRC_ALPHA;
case GL_DST_ALPHA:
return BLENDFACT_DST_ALPHA;
case GL_ONE_MINUS_DST_ALPHA:
return BLENDFACT_INV_DST_ALPHA;
case GL_SRC_ALPHA_SATURATE:
return BLENDFACT_SRC_ALPHA_SATURATE;
case GL_CONSTANT_COLOR:
return BLENDFACT_CONST_COLOR;
case GL_ONE_MINUS_CONSTANT_COLOR:
return BLENDFACT_INV_CONST_COLOR;
case GL_CONSTANT_ALPHA:
return BLENDFACT_CONST_ALPHA;
case GL_ONE_MINUS_CONSTANT_ALPHA:
return BLENDFACT_INV_CONST_ALPHA;
}
fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, factor);
return BLENDFACT_ZERO;
}
int
intel_translate_logic_op(GLenum opcode)
{
switch (opcode) {
case GL_CLEAR:
return LOGICOP_CLEAR;
case GL_AND:
return LOGICOP_AND;
case GL_AND_REVERSE:
return LOGICOP_AND_RVRSE;
case GL_COPY:
return LOGICOP_COPY;
case GL_COPY_INVERTED:
return LOGICOP_COPY_INV;
case GL_AND_INVERTED:
return LOGICOP_AND_INV;
case GL_NOOP:
return LOGICOP_NOOP;
case GL_XOR:
return LOGICOP_XOR;
case GL_OR:
return LOGICOP_OR;
case GL_OR_INVERTED:
return LOGICOP_OR_INV;
case GL_NOR:
return LOGICOP_NOR;
case GL_EQUIV:
return LOGICOP_EQUIV;
case GL_INVERT:
return LOGICOP_INV;
case GL_OR_REVERSE:
return LOGICOP_OR_RVRSE;
case GL_NAND:
return LOGICOP_NAND;
case GL_SET:
return LOGICOP_SET;
default:
return LOGICOP_SET;
}
}
static void
intelClearColor(GLcontext * ctx, const GLfloat color[4])
{
struct intel_context *intel = intel_context(ctx);
GLubyte clear[4];
CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]);
CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]);
CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
/* compute both 32 and 16-bit clear values */
intel->ClearColor8888 = INTEL_PACKCOLOR8888(clear[0], clear[1],
clear[2], clear[3]);
intel->ClearColor565 = INTEL_PACKCOLOR565(clear[0], clear[1], clear[2]);
}
/**
* Update the viewport transformation matrix. Depends on:
* - viewport pos/size
* - depthrange
* - window size or FBO size
*/
static void
intelCalcViewport(GLcontext * ctx)
{
struct intel_context *intel = intel_context(ctx);
const GLfloat *v = ctx->Viewport._WindowMap.m;
const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
GLfloat *m = intel->ViewportMatrix.m;
GLfloat yScale, yBias;
struct intel_renderbuffer *irb
= intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
if (irb && !irb->RenderToTexture) {
/* y=0=top */
yScale = -1.0;
yBias = irb->Base.Height;
}
else {
/* y=0=bottom */
yScale = 1.0;
yBias = 0.0;
}
m[MAT_SX] = v[MAT_SX];
m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
m[MAT_SY] = v[MAT_SY] * yScale;
m[MAT_TY] = v[MAT_TY] * yScale + yBias + SUBPIXEL_Y;
m[MAT_SZ] = v[MAT_SZ] * depthScale;
m[MAT_TZ] = v[MAT_TZ] * depthScale;
}
static void
intelViewport(GLcontext * ctx,
GLint x, GLint y, GLsizei width, GLsizei height)
{
intelCalcViewport(ctx);
}
static void
intelDepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
{
intelCalcViewport(ctx);
}
/* Fallback to swrast for select and feedback.
*/
static void
intelRenderMode(GLcontext * ctx, GLenum mode)
{
}
void
intelInitStateFuncs(struct dd_function_table *functions)
{
functions->RenderMode = intelRenderMode;
functions->Viewport = intelViewport;
functions->DepthRange = intelDepthRange;
functions->ClearColor = intelClearColor;
}