Remote changes at Tue Aug 8 15:00:19 EDT 2017 by chuan on vivaldi
This commit is contained in:
parent
d905f10595
commit
660d41a69b
|
|
@ -10,8 +10,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
char *getenv();
|
char *getenv();
|
||||||
|
|
||||||
|
/*
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
*/
|
||||||
|
#include <CAIRO/cairo.h>
|
||||||
|
|
||||||
#include "tcltk/tclmagic.h"
|
#include "tcltk/tclmagic.h"
|
||||||
#include "utils/magic.h"
|
#include "utils/magic.h"
|
||||||
|
|
@ -21,21 +24,24 @@ char *getenv();
|
||||||
#include "windows/windows.h"
|
#include "windows/windows.h"
|
||||||
#include "graphics/graphics.h"
|
#include "graphics/graphics.h"
|
||||||
#include "graphics/graphicsInt.h"
|
#include "graphics/graphicsInt.h"
|
||||||
#include "grTOGLInt.h"
|
//#include "grTOGLInt.h"
|
||||||
|
#include "grTCairoInt.h"
|
||||||
|
|
||||||
extern char *DBWStyleType;
|
extern char *DBWStyleType;
|
||||||
extern GLXContext grXcontext;
|
extern GLXContext grXcontext;
|
||||||
extern Display *grXdpy;
|
extern Display *grXdpy;
|
||||||
|
|
||||||
|
extern cairo_t *grCairoContext;
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* GrOGLSetCMap --
|
* GrOGLSetCMap --
|
||||||
*
|
*
|
||||||
* OpenGL uses RGB values as read from the colormap file,
|
* OpenGL uses RGB values as read from the colormap file,
|
||||||
* directly, so there is no need to install colors into a
|
* directly, so there is no need to install colors into a
|
||||||
* colormap. Therefore, this is a null routine.
|
* colormap. Therefore, this is a null routine.
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects: None.
|
* Side Effects: None.
|
||||||
*
|
*
|
||||||
|
|
@ -47,183 +53,206 @@ GrTOGLSetCMap ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect grtoglLines[TOGL_BATCH_SIZE];
|
Rect grtcairoLines[TCAIRO_BATCH_SIZE];
|
||||||
int grtoglNbLines = 0;
|
int grtcairoNbLines = 0;
|
||||||
TOGLRect grtoglRects[TOGL_BATCH_SIZE];
|
TCairoRect grtcairoRects[TCAIRO_BATCH_SIZE];
|
||||||
int grtoglNbRects = 0;
|
int grtcairoNbRects = 0;
|
||||||
Rect grtoglDiagonal[TOGL_BATCH_SIZE];
|
Rect grtcairoDiagonal[TCAIRO_BATCH_SIZE];
|
||||||
int grtoglNbDiagonal = 0;
|
int grtcairoNbDiagonal = 0;
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* grtoglDrawLines:
|
* grtoglDrawLines:
|
||||||
* This routine draws a batch of lines.
|
* This routine draws a batch of lines.
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Draw a bunch of lines.
|
* Draw a bunch of lines.
|
||||||
*---------------------------------------------------------
|
*---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
grtoglDrawLines(lines, nb)
|
grtcairoDrawLines(lines, nb)
|
||||||
Rect lines[];
|
Rect lines[];
|
||||||
int nb;
|
int nb;
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
#ifdef OGL_SERVER_SIDE_ONLY
|
||||||
|
int i;
|
||||||
|
|
||||||
#ifdef OGL_SERVER_SIDE_ONLY
|
glBegin(GL_LINES);
|
||||||
|
for (i = 0; i < nb; i++)
|
||||||
|
{
|
||||||
|
glVertex2i(lines[i].r_ll.p_x, lines[i].r_ll.p_y);
|
||||||
|
glVertex2i(lines[i].r_ur.p_x, lines[i].r_ur.p_y);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
#else
|
||||||
|
glVertexPointer(2, GL_INT, 0, (GLvoid *)lines);
|
||||||
|
glDrawArrays(GL_LINES, 0, nb << 1);
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
for (i = 0; i < nb; i++)
|
||||||
glBegin(GL_LINES);
|
{
|
||||||
for (i = 0; i < nb; i++)
|
cairo_move_to(grCairoContext, lines[i].r_ll.p_x, lines[i].r_ll.p_y);
|
||||||
{
|
cairo_line_to(grCairoContext, lines[i].r_ur.p_x, lines[i].r_ur.p_y);
|
||||||
glVertex2i(lines[i].r_ll.p_x, lines[i].r_ll.p_y);
|
}
|
||||||
glVertex2i(lines[i].r_ur.p_x, lines[i].r_ur.p_y);
|
// cairo_set_source_rgba(grCairoContext, r, g, b, a);
|
||||||
}
|
// cairo_set_line_width(grCairoContext, width);
|
||||||
glEnd();
|
cairo_stroke(grCairoContext);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
glVertexPointer(2, GL_INT, 0, (GLvoid *)lines);
|
|
||||||
glDrawArrays(GL_LINES, 0, nb << 1);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* grtoglDrawLine:
|
* grtoglDrawLine:
|
||||||
* This routine draws a line.
|
* This routine draws a line.
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Draw a line for (x1, y1) to (x2, y2) inclusive.
|
* Draw a line for (x1, y1) to (x2, y2) inclusive.
|
||||||
*---------------------------------------------------------
|
*---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
grtoglDrawLine (x1, y1, x2, y2)
|
grtcairoDrawLine (x1, y1, x2, y2)
|
||||||
int x1, y1; /* Screen coordinates of first point. */
|
int x1, y1; /* Screen coordinates of first point. */
|
||||||
int x2, y2; /* Screen coordinates of second point. */
|
int x2, y2; /* Screen coordinates of second point. */
|
||||||
{
|
{
|
||||||
/* Treat straight and diagonal lines separately. Some */
|
/* Treat straight and diagonal lines separately. Some */
|
||||||
/* implementations of OpenGL make straight lines twice as thick */
|
/* implementations of OpenGL make straight lines twice as thick */
|
||||||
/* when smoothing is enabled. */
|
/* when smoothing is enabled. */
|
||||||
|
|
||||||
if ((x1 == x2) || (y1 == y2))
|
if ((x1 == x2) || (y1 == y2))
|
||||||
{
|
{
|
||||||
if (grtoglNbLines == TOGL_BATCH_SIZE) GR_TOGL_FLUSH_LINES();
|
if (grtcairoNbLines == TCAIRO_BATCH_SIZE) GR_TCAIRO_FLUSH_LINES();
|
||||||
grtoglLines[grtoglNbLines].r_ll.p_x = x1;
|
grtcairoLines[grtcairoNbLines].r_ll.p_x = x1;
|
||||||
grtoglLines[grtoglNbLines].r_ll.p_y = y1;
|
grtcairoLines[grtcairoNbLines].r_ll.p_y = y1;
|
||||||
grtoglLines[grtoglNbLines].r_ur.p_x = x2;
|
grtcairoLines[grtcairoNbLines].r_ur.p_x = x2;
|
||||||
grtoglLines[grtoglNbLines].r_ur.p_y = y2;
|
grtcairoLines[grtcairoNbLines].r_ur.p_y = y2;
|
||||||
grtoglNbLines++;
|
grtcairoNbLines++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (grtoglNbDiagonal == TOGL_BATCH_SIZE) GR_TOGL_FLUSH_DIAGONAL();
|
if (grtcairoNbDiagonal == TCAIRO_BATCH_SIZE) GR_TCAIRO_FLUSH_DIAGONAL();
|
||||||
grtoglDiagonal[grtoglNbDiagonal].r_ll.p_x = x1;
|
grtcairoDiagonal[grtcairoNbDiagonal].r_ll.p_x = x1;
|
||||||
grtoglDiagonal[grtoglNbDiagonal].r_ll.p_y = y1;
|
grtcairoDiagonal[grtcairoNbDiagonal].r_ll.p_y = y1;
|
||||||
grtoglDiagonal[grtoglNbDiagonal].r_ur.p_x = x2;
|
grtcairoDiagonal[grtcairoNbDiagonal].r_ur.p_x = x2;
|
||||||
grtoglDiagonal[grtoglNbDiagonal].r_ur.p_y = y2;
|
grtcairoDiagonal[grtcairoNbDiagonal].r_ur.p_y = y2;
|
||||||
grtoglNbDiagonal++;
|
grtcairoNbDiagonal++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* grtoglFillRects:
|
* grtoglFillRects:
|
||||||
* This routine draws a bunch of solid rectangles.
|
* This routine draws a bunch of solid rectangles.
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Drawing.
|
* Drawing.
|
||||||
*---------------------------------------------------------
|
*---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
grtoglFillRects(rects, nb)
|
grtcairoFillRects(rects, nb)
|
||||||
TOGLRect rects[];
|
TCairoRect rects[];
|
||||||
int nb;
|
int nb;
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
#ifdef OGL_SERVER_SIDE_ONLY
|
||||||
|
|
||||||
#ifdef OGL_SERVER_SIDE_ONLY
|
int i;
|
||||||
|
|
||||||
int i;
|
for (i = 0; i < nb; i++)
|
||||||
|
{
|
||||||
|
glRecti(rects[i].r_ll.p_x, rects[i].r_ll.p_y,
|
||||||
|
rects[i].r_ur.p_x, rects[i].r_ur.p_y);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nb; i++)
|
#else
|
||||||
{
|
|
||||||
glRecti(rects[i].r_ll.p_x, rects[i].r_ll.p_y,
|
|
||||||
rects[i].r_ur.p_x, rects[i].r_ur.p_y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
glVertexPointer(2, GL_INT, 0, (GLvoid *)rects);
|
||||||
|
glDrawArrays(GL_QUADS, 0, nb << 2);
|
||||||
|
|
||||||
glVertexPointer(2, GL_INT, 0, (GLvoid *)rects);
|
#endif
|
||||||
glDrawArrays(GL_QUADS, 0, nb << 2);
|
*/
|
||||||
|
int i;
|
||||||
|
|
||||||
#endif
|
for (i = 0; i < nb; i++)
|
||||||
|
{
|
||||||
|
cairo_rectangle(rects[i].r_ll.p_x, rects[i].r_ll.p_y,
|
||||||
|
rects[i].r_ur.p_x, rects[i].r_ur.p_y);
|
||||||
|
}
|
||||||
|
// cairo_set_source_rgba(grCairoContext, r, g, b, a);
|
||||||
|
cairo_fill(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* grtoglFillRect:
|
* grtoglFillRect:
|
||||||
* This routine draws a solid rectangle.
|
* This routine draws a solid rectangle.
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Drawing.
|
* Drawing.
|
||||||
*---------------------------------------------------------
|
*---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
grtoglFillRect(r)
|
grtcairoFillRect(r)
|
||||||
Rect *r; /* Address of a rectangle in screen
|
Rect *r; /* Address of a rectangle in screen
|
||||||
* coordinates.
|
* coordinates.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (grtoglNbRects == TOGL_BATCH_SIZE) GR_TOGL_FLUSH_RECTS();
|
if (grtcairoNbRects == TCAIRO_BATCH_SIZE) GR_TCAIRO_FLUSH_RECTS();
|
||||||
grtoglRects[grtoglNbRects].r_ll.p_x = r->r_ll.p_x;
|
grtcairoRects[grtcairoNbRects].r_ll.p_x = r->r_ll.p_x;
|
||||||
grtoglRects[grtoglNbRects].r_ll.p_y = r->r_ll.p_y;
|
grtcairoRects[grtcairoNbRects].r_ll.p_y = r->r_ll.p_y;
|
||||||
|
|
||||||
grtoglRects[grtoglNbRects].r_ur.p_x = r->r_ur.p_x;
|
grtcairoRects[grtcairoNbRects].r_ur.p_x = r->r_ur.p_x;
|
||||||
grtoglRects[grtoglNbRects].r_ur.p_y = r->r_ur.p_y;
|
grtcairoRects[grtcairoNbRects].r_ur.p_y = r->r_ur.p_y;
|
||||||
|
|
||||||
#ifndef OGL_SERVER_SIDE_ONLY
|
#ifndef OGL_SERVER_SIDE_ONLY
|
||||||
grtoglRects[grtoglNbRects].r_ul.p_x = r->r_ll.p_x;
|
grtcairoRects[grtcairoNbRects].r_ul.p_x = r->r_ll.p_x;
|
||||||
grtoglRects[grtoglNbRects].r_ul.p_y = r->r_ur.p_y;
|
grtcairoRects[grtcairoNbRects].r_ul.p_y = r->r_ur.p_y;
|
||||||
|
|
||||||
grtoglRects[grtoglNbRects].r_lr.p_x = r->r_ur.p_x;
|
grtcairoRects[grtcairoNbRects].r_lr.p_x = r->r_ur.p_x;
|
||||||
grtoglRects[grtoglNbRects].r_lr.p_y = r->r_ll.p_y;
|
grtcairoRects[grtcairoNbRects].r_lr.p_y = r->r_ll.p_y;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
grtoglNbRects++;
|
grtcairoNbRects++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------
|
/*---------------------------------------------------------
|
||||||
* grtoglFillPolygon:
|
* grtoglFillPolygon:
|
||||||
* This routine draws a solid (convex) polygon
|
* This routine draws a solid (convex) polygon
|
||||||
*
|
*
|
||||||
* Results: None.
|
* Results: None.
|
||||||
*
|
*
|
||||||
* Side Effects:
|
* Side Effects:
|
||||||
* Drawing.
|
* Drawing.
|
||||||
*---------------------------------------------------------
|
*---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
grtoglFillPolygon(tp, np)
|
grtoglFillPolygon(tp, np)
|
||||||
Point *tp;
|
Point *tp;
|
||||||
int np;
|
int np;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
/*
|
||||||
glEnable(GL_POLYGON_SMOOTH);
|
glEnable(GL_POLYGON_SMOOTH);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
for (i = 0; i < np; i++)
|
for (i = 0; i < np; i++)
|
||||||
glVertex2i(tp[i].p_x, tp[i].p_y);
|
glVertex2i(tp[i].p_x, tp[i].p_y);
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_POLYGON_SMOOTH);
|
glDisable(GL_POLYGON_SMOOTH);
|
||||||
|
*/
|
||||||
|
cairo_move_to(tp[0].p_x, tp[0].p_y);
|
||||||
|
for (i = 1; i < np; i++)
|
||||||
|
cairo_line_to(tp[i].p_x, tp[i].p_y);
|
||||||
|
cairo_close_path(grCairoContext);
|
||||||
|
cairo_fill(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,9 @@ extern TCairoRect grtcairoRects[];
|
||||||
|
|
||||||
#define GR_TCAIRO_FLUSH_DIAGONAL() { \
|
#define GR_TCAIRO_FLUSH_DIAGONAL() { \
|
||||||
if (grtcairoNbDiagonal>0) { \
|
if (grtcairoNbDiagonal>0) { \
|
||||||
glEnable(GL_LINE_SMOOTH); \
|
//glEnable(GL_LINE_SMOOTH); \
|
||||||
grtcairoDrawLines(grtcairoDiagonal, grtcairoNbDiagonal); \
|
grtcairoDrawLines(grtcairoDiagonal, grtcairoNbDiagonal); \
|
||||||
glDisable(GL_LINE_SMOOTH); \
|
//glDisable(GL_LINE_SMOOTH); \
|
||||||
grtcairoNbDiagonal=0; \
|
grtcairoNbDiagonal=0; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue