summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-27 15:08:10 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-27 15:08:10 +0200
commitac82488c022665492713d633d832480063f67067 (patch)
treeab9e230bc8ad1055fe080506dfc784fc088c43cb /src
parentb92393878f81ec008ac7f383f63afe648bc5f80f (diff)
downloadunity-window-decorator-ac82488c022665492713d633d832480063f67067.tar.gz
unity-window-decorator-ac82488c022665492713d633d832480063f67067.tar.bz2
Moved composite handling and opengl painting into separate plugins.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am13
-rw-r--r--src/display.cpp91
-rw-r--r--src/event.cpp182
-rw-r--r--src/fragment.cpp1086
-rw-r--r--src/icon.cpp17
-rw-r--r--src/main.cpp75
-rw-r--r--src/matrix.cpp402
-rw-r--r--src/option.cpp2
-rw-r--r--src/paint.cpp1191
-rw-r--r--src/privatedisplay.h133
-rw-r--r--src/privatefragment.h27
-rw-r--r--src/privatescreen.h125
-rw-r--r--src/privatetexture.h35
-rw-r--r--src/privatewindow.h43
-rw-r--r--src/screen.cpp1638
-rw-r--r--src/texture.cpp496
-rw-r--r--src/vector.cpp217
-rw-r--r--src/window.cpp609
18 files changed, 203 insertions, 6179 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4696106..715647d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,28 +12,23 @@ bin_PROGRAMS = compiz
compiz_LDADD = @COMPIZ_LIBS@ @GL_LIBS@ -lm
compiz_LDFLAGS = -export-dynamic
compiz_SOURCES = \
+ display.cpp \
+ screen.cpp \
+ window.cpp \
metadata.cpp \
action.cpp \
option.cpp \
string.cpp \
- fragment.cpp \
match.cpp \
main.cpp \
object.cpp \
core.cpp \
- display.cpp \
- screen.cpp \
- window.cpp \
event.cpp \
- texture.cpp \
- paint.cpp \
plugin.cpp \
session.cpp \
- matrix.cpp \
output.cpp \
rect.cpp \
size.cpp \
point.cpp \
windowgeometry.cpp \
- icon.cpp \
- vector.cpp
+ icon.cpp
diff --git a/src/display.cpp b/src/display.cpp
index 5553030..cde39da 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -42,7 +42,6 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
-#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/shape.h>
@@ -273,24 +272,6 @@ CompScreen::showDesktop (CompDisplay *d,
}
bool
-CompScreen::toggleSlowAnimations (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- s->priv->slowAnimations = !s->priv->slowAnimations;
-
- return true;
-}
-
-bool
CompWindow::raiseInitiate (CompDisplay *d,
CompAction *action,
CompAction::State state,
@@ -531,7 +512,6 @@ CompWindow::shade (CompDisplay *d,
const CompMetadata::OptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
{ "active_plugins", "list", "<type>string</type>", 0, 0 },
- { "texture_filter", "int", RESTOSTRING (0, 2), 0, 0 },
{ "click_to_focus", "bool", 0, 0, 0 },
{ "autoraise", "bool", 0, 0, 0 },
{ "autoraise_delay", "int", 0, 0, 0 },
@@ -563,7 +543,6 @@ const CompMetadata::OptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] =
{ "run_command9_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
{ "run_command10_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
{ "run_command11_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "slow_animations_key", "key", 0, CompScreen::toggleSlowAnimations, 0 },
{ "raise_window_key", "key", 0, CompWindow::raiseInitiate, 0 },
{ "raise_window_button", "button", 0, CompWindow::raiseInitiate, 0 },
{ "lower_window_key", "key", 0, CompWindow::lowerInitiate, 0 },
@@ -745,8 +724,6 @@ CompDisplay::init (const char *name)
{
Window focus;
int revertTo, i;
- int compositeMajor, compositeMinor;
- int fixesMinor;
int xkbOpcode;
int firstScreen, lastScreen;
@@ -789,33 +766,6 @@ CompDisplay::init (const char *name)
priv->lastPing = 1;
- if (!XQueryExtension (priv->dpy,
- COMPOSITE_NAME,
- &priv->compositeOpcode,
- &priv->compositeEvent,
- &priv->compositeError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No composite extension");
- return false;
- }
-
- XCompositeQueryVersion (priv->dpy, &compositeMajor, &compositeMinor);
- if (compositeMajor == 0 && compositeMinor < 2)
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "Old composite extension");
- return false;
- }
-
- if (!XDamageQueryExtension (priv->dpy, &priv->damageEvent,
- &priv->damageError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No damage extension");
- return false;
- }
-
if (!XSyncQueryExtension (priv->dpy, &priv->syncEvent, &priv->syncError))
{
compLogMessage (this, "core", CompLogLevelFatal,
@@ -823,15 +773,6 @@ CompDisplay::init (const char *name)
return false;
}
- if (!XFixesQueryExtension (priv->dpy, &priv->fixesEvent, &priv->fixesError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No fixes extension");
- return false;
- }
-
- XFixesQueryVersion (priv->dpy, &priv->fixesVersion, &fixesMinor);
-
priv->randrExtension = XRRQueryExtension (priv->dpy, &priv->randrEvent,
&priv->randrError);
@@ -956,12 +897,6 @@ CompDisplay::screens ()
return priv->screens;
}
-GLenum
-CompDisplay::textureFilter ()
-{
- return priv->textureFilter;
-}
-
CompOption *
CompDisplay::getOption (const char *name)
{
@@ -1169,20 +1104,6 @@ CompDisplay::setOption (const char *name,
return true;
}
break;
- case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
- if (o->set (value))
- {
- foreach (CompScreen *s, priv->screens)
- s->damageScreen ();
-
- if (!o->value ().i ())
- priv->textureFilter = GL_NEAREST;
- else
- priv->textureFilter = GL_LINEAR;
-
- return true;
- }
- break;
case COMP_DISPLAY_OPTION_PING_DELAY:
if (o->set (value))
{
@@ -1348,6 +1269,10 @@ CompDisplay::processEvents ()
{
XEvent event;
+ /* remove destroyed windows */
+ foreach (CompScreen *s, priv->screens)
+ s->removeDestroyed ();
+
if (priv->dirtyPluginList)
priv->updatePlugins ();
@@ -1670,13 +1595,6 @@ PrivateDisplay::handleSelectionClear (XEvent *event)
}
-void
-CompDisplay::clearTargetOutput (unsigned int mask)
-{
- if (targetScreen)
- targetScreen->clearOutput (targetOutput, mask);
-}
-
#define HOME_IMAGEDIR ".compiz/images"
bool
@@ -2459,7 +2377,6 @@ PrivateDisplay::PrivateDisplay (CompDisplay *display) :
screens (),
watchFdHandle (0),
screenInfo (0),
- textureFilter (GL_LINEAR),
activeWindow (0),
below (None),
modMap (0),
diff --git a/src/event.cpp b/src/event.cpp
index b2eb09c..b83a86b 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -44,46 +44,7 @@
static Window xdndWindow = None;
static Window edgeWindow = None;
-void
-PrivateWindow::handleDamageRect (CompWindow *w,
- int x,
- int y,
- int width,
- int height)
-{
- REGION region;
- bool initial = false;
-
- if (!w->priv->redirected || w->priv->bindFailed)
- return;
- if (!w->priv->damaged)
- {
- w->priv->damaged = initial = true;
- w->priv->invisible = WINDOW_INVISIBLE (w->priv);
- }
-
- region.extents.x1 = x;
- region.extents.y1 = y;
- region.extents.x2 = region.extents.x1 + width;
- region.extents.y2 = region.extents.y1 + height;
-
- if (!w->damageRect (initial, &region.extents))
- {
- region.extents.x1 += w->priv->attrib.x + w->priv->attrib.border_width;
- region.extents.y1 += w->priv->attrib.y + w->priv->attrib.border_width;
- region.extents.x2 += w->priv->attrib.x + w->priv->attrib.border_width;
- region.extents.y2 += w->priv->attrib.y + w->priv->attrib.border_width;
-
- region.rects = &region.extents;
- region.numRects = region.size = 1;
-
- w->priv->screen->damageRegion (&region);
- }
-
- if (initial)
- w->damageOutputExtents ();
-}
bool
CompWindow::handleSyncAlarm ()
@@ -94,21 +55,7 @@ CompWindow::handleSyncAlarm ()
if (resize (priv->syncGeometry))
{
- XRectangle *rects;
- int nDamage;
-
- nDamage = priv->nDamage;
- rects = priv->damageRects;
- while (nDamage--)
- {
- PrivateWindow::handleDamageRect (this,
- rects[nDamage].x,
- rects[nDamage].y,
- rects[nDamage].width,
- rects[nDamage].height);
- }
-
- priv->nDamage = 0;
+ windowNotify (CompWindowNotifySyncAlarm);
}
else
{
@@ -1012,28 +959,6 @@ PrivateDisplay::handleActionEvent (XEvent *event)
}
void
-CompScreen::handleExposeEvent (XExposeEvent *event)
-{
- if (priv->output == event->window)
- return;
-
- priv->exposeRects.push_back (CompRect (event->x, event->x + event->width,
- event->y, event->y + event->height));
-
- if (event->count == 0)
- {
- CompRect rect;
- while (!priv->exposeRects.empty())
- {
- rect = priv->exposeRects.front ();
- priv->exposeRects.pop_front ();
-
- damageRegion (rect.region ());
- }
- }
-}
-
-void
CompDisplay::handleCompizEvent (const char *plugin,
const char *event,
CompOption *option,
@@ -1080,10 +1005,6 @@ CompDisplay::handleEvent (XEvent *event)
}
switch (event->type) {
- case Expose:
- foreach (s, priv->screens)
- s->handleExposeEvent (&event->xexpose);
- break;
case SelectionRequest:
priv->handleSelectionRequest (event);
break;
@@ -1107,13 +1028,8 @@ CompDisplay::handleEvent (XEvent *event)
s = findScreen (event->xcreatewindow.parent);
if (s)
{
- /* The first time some client asks for the composite
- * overlay window, the X server creates it, which causes
- * an errorneous CreateNotify event. We catch it and
- * ignore it. */
- if (s->overlay () != event->xcreatewindow.window)
- new CompWindow (s, event->xcreatewindow.window,
- s->getTopWindow ());
+ new CompWindow (s, event->xcreatewindow.window,
+ s->getTopWindow ());
}
break;
case DestroyNotify:
@@ -1320,31 +1236,6 @@ CompDisplay::handleEvent (XEvent *event)
if (w)
w->updateIconGeometry ();
}
- else if (event->xproperty.atom == priv->atoms.winOpacity)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateOpacity ();
- }
- else if (event->xproperty.atom == priv->atoms.winBrightness)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateBrightness ();
- }
- else if (event->xproperty.atom == priv->atoms.winSaturation)
- {
- w = findWindow (event->xproperty.window);
- if (w)
- w->updateSaturation ();
- }
- else if (event->xproperty.atom == priv->atoms.xBackground[0] ||
- event->xproperty.atom == priv->atoms.xBackground[1])
- {
- s = findScreen (event->xproperty.window);
- if (s)
- s->updateBackground ();
- }
else if (event->xproperty.atom == priv->atoms.wmStrut ||
event->xproperty.atom == priv->atoms.wmStrutPartial)
{
@@ -1403,38 +1294,6 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xclient.message_type == priv->atoms.winOpacity)
- {
- w = findWindow (event->xclient.window);
- if (w && (w->type () & CompWindowTypeDesktopMask) == 0)
- {
- GLushort opacity = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winOpacity, opacity);
- }
- }
- else if (event->xclient.message_type == priv->atoms.winBrightness)
- {
- w = findWindow (event->xclient.window);
- if (w)
- {
- GLushort brightness = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winBrightness,
- brightness);
- }
- }
- else if (event->xclient.message_type == priv->atoms.winSaturation)
- {
- w = findWindow (event->xclient.window);
- if (w)
- {
- GLushort saturation = event->xclient.data.l[0] >> 16;
-
- setWindowProp32 (w->id (), priv->atoms.winSaturation,
- saturation);
- }
- }
else if (event->xclient.message_type == priv->atoms.winState)
{
w = findWindow (event->xclient.window);
@@ -1865,49 +1724,16 @@ CompDisplay::handleEvent (XEvent *event)
}
break;
default:
- if (event->type == priv->damageEvent + XDamageNotify)
- {
- XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
-
- if (lastDamagedWindow && de->drawable == lastDamagedWindow->id ())
- {
- w = lastDamagedWindow;
- }
- else
- {
- w = findWindow (de->drawable);
- if (w)
- lastDamagedWindow = w;
- }
-
- if (w)
- w->processDamage (de);
- }
- else if (priv->shapeExtension &&
+ if (priv->shapeExtension &&
event->type == priv->shapeEvent + ShapeNotify)
{
w = findWindow (((XShapeEvent *) event)->window);
if (w)
{
if (w->mapNum ())
- {
- w->addDamage ();
w->updateRegion ();
- w->addDamage ();
- }
}
}
- else if (priv->randrExtension &&
- event->type == priv->randrEvent + RRScreenChangeNotify)
- {
- XRRScreenChangeNotifyEvent *rre;
-
- rre = (XRRScreenChangeNotifyEvent *) event;
-
- s = findScreen (rre->root);
- if (s)
- s->detectRefreshRate ();
- }
else if (event->type == priv->syncEvent + XSyncAlarmNotify)
{
XSyncAlarmNotifyEvent *sa;
diff --git a/src/fragment.cpp b/src/fragment.cpp
deleted file mode 100644
index f5ccb9a..0000000
--- a/src/fragment.cpp
+++ /dev/null
@@ -1,1086 +0,0 @@
-/*
- * Copyright © 2007 Novell, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
-
-#include <boost/function.hpp>
-#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
-#define foreach BOOST_FOREACH
-
-#include <compiz-core.h>
-#include <comptexture.h>
-#include <compfragment.h>
-#include <compscreen.h>
-#include "privatefragment.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#define COMP_FUNCTION_TYPE_ARB 0
-#define COMP_FUNCTION_TYPE_NUM 1
-
-#define COMP_FUNCTION_ARB_MASK (1 << 0)
-#define COMP_FUNCTION_MASK (COMP_FUNCTION_ARB_MASK)
-
-namespace CompFragment {
-
- class Program {
- public:
- Program (CompScreen *s) :
- s (s),
- signature (0),
- blending (false),
- name (0),
- type (GL_FRAGMENT_PROGRAM_ARB)
- {};
- ~Program ()
- {
- if (name)
- (*s->deletePrograms) (1, &name);
- };
-
- public:
- CompScreen *s;
-
- std::list<FunctionId> signature;
-
- bool blending;
-
- GLuint name;
- GLenum type;
- };
-
- typedef enum {
- OpTypeData,
- OpTypeDataStore,
- OpTypeDataOffset,
- OpTypeDataBlend,
- OpTypeHeaderTemp,
- OpTypeHeaderParam,
- OpTypeHeaderAttrib,
- OpTypeColor,
- OpTypeFetch,
- OpTypeLoad
- } OpType;
-
- class HeaderOp {
- public:
- HeaderOp () : type(OpTypeHeaderTemp), name ("") {};
- public:
- OpType type;
- CompString name;
- };
-
- class BodyOp {
- public:
- BodyOp () :
- type(OpTypeData),
- data (""),
- dst (""),
- src (""),
- target (0)
- {
- foreach (CompString &str, noOffset)
- str = "";
- foreach (CompString &str, offset)
- str = "";
- };
-
- public:
- OpType type;
- CompString data;
- CompString dst;
- CompString src;
- unsigned int target;
- CompString noOffset[COMP_FETCH_TARGET_NUM];
- CompString offset[COMP_FETCH_TARGET_NUM];
-
- };
-
- class PrivateFunctionData {
- public:
- PrivateFunctionData () : header (0), body (0), status (true) {};
- PrivateFunctionData (const PrivateFunctionData&, CompString);
-
- public:
- std::vector<HeaderOp> header;
- std::vector<BodyOp> body;
- bool status;
- };
-
- class Function {
- public:
- Function ():
- id (0),
- name (""),
- mask (0)
- {};
-
- public:
- FunctionId id;
- CompString name;
- PrivateFunctionData data[COMP_FUNCTION_TYPE_NUM];
- unsigned int mask;
- };
-
- class PrivateAttrib {
- public:
- PrivateAttrib () :
- opacity (0xffff),
- brightness (0xffff),
- saturation (0xffff),
- nTexture (0),
- nFunction (0),
- nParam (0)
- {};
-
- public:
- GLushort opacity;
- GLushort brightness;
- GLushort saturation;
- int nTexture;
- FunctionId function[MAX_FRAGMENT_FUNCTIONS];
- int nFunction;
- int nParam;
- };
-
- typedef boost::function<void (BodyOp *, int)> DataOpCallBack;
-
- class InitialLoadFunction : public Function {
- public:
- InitialLoadFunction ()
- {
- id = 0;
- name = "__core_load";
- mask = COMP_FUNCTION_MASK;
-
- BodyOp b;
- b.type = OpTypeLoad;
- b.noOffset[0] = "TEX output, fragment.texcoord[0], texture[0], 2D;";
- b.noOffset[1] = "TEX output, fragment.texcoord[0], texture[0], RECT;";
- b.offset[0] = "TEX output, __tmp_texcoord0, texture[0], 2D;";
- b.offset[1] = "TEX output, __tmp_texcoord0, texture[0], 2D;";
- data[0].body.push_back (b);
- };
- };
-
- static InitialLoadFunction initialLoadFunction;
-
- static Function *
- findFragmentFunction (CompScreen *s,
- FunctionId id)
- {
- foreach (Function *f, s->fragmentStorage ()->functions)
- if (f->id == id)
- return f;
- return NULL;
- }
-
- static Function *
- findFragmentFunctionWithName (CompScreen *s,
- CompString name)
- {
- foreach (Function *f, s->fragmentStorage ()->functions)
- if (f->name.compare (name) == 0)
- return f;
- return NULL;
- }
-
- static Program *
- findFragmentProgram (CompScreen *s,
- FunctionId *signature,
- unsigned int nSignature)
- {
- unsigned int i;
-
- foreach (Program *p, s->fragmentStorage ()->programs)
- {
- if (p->signature.size () != nSignature)
- continue;
-
- i = 0;
- foreach (FunctionId id, p->signature)
- if (i == nSignature || signature[i++] != id)
- break;
-
- if (i == nSignature)
- return p;
- }
- return NULL;
- }
-
- static unsigned int
- functionMaskToType (int mask)
- {
- static struct {
- unsigned int type;
- unsigned int mask;
- } maskToType[] = {
- { COMP_FUNCTION_TYPE_ARB, COMP_FUNCTION_ARB_MASK }
- };
-
- unsigned int i;
-
- for (i = 0; i < sizeof (maskToType) / sizeof (maskToType[0]); i++)
- if (mask & maskToType[i].mask)
- return maskToType[i].type;
-
- return 0;
- }
-
- static void
- forEachDataOpInFunction (std::vector<Function *> list,
- int index,
- int type,
- int loadTarget,
- CompString loadOffset,
- bool *color,
- bool *blend,
- DataOpCallBack callBack)
- {
- Function *f = list[index];
- BodyOp dataOp;
- bool colorDone = false;
- bool blendDone = false;
-
- *color = false;
- *blend = false;
-
- foreach (BodyOp &bodyOp, f->data[type].body)
- {
- switch (bodyOp.type) {
- case OpTypeFetch: {
- CompString offset = loadOffset;
-
- /* add offset */
- if (bodyOp.data.size ())
- {
- if (loadOffset.size ())
- {
- dataOp.type = OpTypeDataOffset;
- dataOp.data =
- compPrintf ("ADD __tmp_texcoord%d, %s, %s;",
- index, loadOffset.c_str (),
- bodyOp.data.c_str ());
-
- callBack (&dataOp, index);
-
- offset = compPrintf ("__tmp_texcoord%d", index);
- }
- else
- {
- offset = bodyOp.data;
- }
- }
-
- forEachDataOpInFunction (list, index - 1, type,
- bodyOp.target,
- offset, &colorDone, &blendDone,
- callBack);
-
- if (bodyOp.dst.compare("output"))
- {
- dataOp.type = OpTypeDataStore;
- dataOp.data =
- compPrintf ("MOV %s, output;", bodyOp.dst.c_str ());
-
- /* move to destination */
- callBack (&dataOp, index);
- }
- } break;
- case OpTypeLoad:
- if (loadOffset.size ())
- {
- dataOp.type = OpTypeDataOffset;
- dataOp.data =
- compPrintf ("ADD __tmp_texcoord0, fragment.texcoord[0], %s;",
- loadOffset.c_str ());
-
- callBack (&dataOp, index);
-
- dataOp.data = bodyOp.offset[loadTarget];
- }
- else
- {
- dataOp.data = bodyOp.noOffset[loadTarget];
- }
-
- dataOp.type = OpTypeData;
-
- callBack (&dataOp, index);
-
- break;
- case OpTypeColor:
- if (!colorDone)
- {
- dataOp.type = OpTypeData;
- dataOp.data =
- compPrintf ("MUL %s, fragment.color, %s;",
- bodyOp.dst.c_str (),
- bodyOp.src.c_str ());
-
- callBack (&dataOp, index);
- }
- else if (bodyOp.dst.compare (bodyOp.src))
- {
- dataOp.type = OpTypeData;
- dataOp.data =
- compPrintf ("MOV %s, %s;",
- bodyOp.dst.c_str (),
- bodyOp.src.c_str ());
-
- callBack (&dataOp, index);
- }
- *color = true;
- break;
- case OpTypeDataBlend:
- *blend = true;
- /* fall-through */
- case OpTypeData:
- callBack (&bodyOp, index);
- break;
- case OpTypeDataStore:
- case OpTypeDataOffset:
- case OpTypeHeaderTemp:
- case OpTypeHeaderParam:
- case OpTypeHeaderAttrib:
- break;
- }
- }
-
- if (colorDone)
- *color = true;
-
- if (blendDone)
- *blend = true;
- }
-
- static int
- forEachHeaderOpWithType (std::vector<HeaderOp> list,
- int index,
- OpType type,
- CompString prefix,
- CompString functionPrefix,
- int count,
- DataOpCallBack callBack)
- {
- BodyOp dataOp;
-
- dataOp.type = OpTypeData;
-
- foreach (HeaderOp &header, list)
- {
- if (header.type == type)
- {
- if (count)
- {
- dataOp.data = ", ";
- }
- else
- {
- dataOp.data = prefix;
- }
-
- dataOp.data += functionPrefix;
- dataOp.data += "_";
- dataOp.data += header.name;
- callBack (&dataOp, index);
-
- count++;
- }
- }
-
- return count;
- }
-
- static bool
- forEachDataOp (std::vector<Function *> list,
- int type,
- DataOpCallBack callBack)
- {
- BodyOp dataOp;
- bool colorDone;
- bool blendDone;
- int count, nList = list.size ();
-
- dataOp.type = OpTypeData;
-
- count = 1;
-
- dataOp.data = "TEMP output";
-
- callBack (&dataOp, nList);
-
- foreach (Function *f, list)
- count = forEachHeaderOpWithType (f->data[type].header,
- nList, OpTypeHeaderTemp,
- "", f->name, count, callBack);
-
- dataOp.data = ";";
-
- callBack (&dataOp, nList);
-
- count = 0;
-
- foreach (Function *f, list)
- count = forEachHeaderOpWithType (f->data[type].header,
- nList, OpTypeHeaderParam,
- "PARAM ", f->name, count,
- callBack);
-
- if (count)
- {
- dataOp.data = ";";
-
- callBack (&dataOp, nList);
- }
-
- count = 0;
-
- foreach (Function *f, list)
- count = forEachHeaderOpWithType (f->data[type].header,
- nList, OpTypeHeaderAttrib,
- "ATTRIB ", f->name, count,
- callBack);
-
- if (count)
- {
- dataOp.data = ";";
-
- callBack (&dataOp, nList);
- }
-
- forEachDataOpInFunction (list, nList - 1, type, 0, NULL,
- &colorDone, &blendDone,
- callBack);
-
- if (colorDone)
- dataOp.data = "MOV result.color, output;END";
- else
- dataOp.data = "MUL result.color, fragment.color, output;END";
-
- callBack (&dataOp, nList);
-
- return blendDone;
- }
-
- static void
- addFetchOffsetVariables (BodyOp *op,
- int index,
- bool *indices,
- CompString *data)
- {
- if (op->type == OpTypeDataOffset)
- {
- if (!indices[index])
- {
- data->append (compPrintf ("TEMP __tmp_texcoord%d;", index));
- indices[index] = true;
- }
- }
- }
-
- static void
- addData (BodyOp *op,
- CompString *data)
- {
- data->append (op->data);
- }
-
- static Program *
- buildFragmentProgram (CompScreen *s,
- PrivateAttrib *attrib)
- {
- Program *program;
- std::vector<Function *> functionList (1);
- int mask = COMP_FUNCTION_MASK;
- int type;
- GLint errorPos;
- CompString fetchData;
- bool indices[MAX_FRAGMENT_FUNCTIONS];
- int i;
-
- program = new Program (s);
- if (!program)
- return NULL;
-
- functionList[0] = &initialLoadFunction;
-
- for (i = 0; i < attrib->nFunction; i++)
- {
- Function *f = findFragmentFunction (s, attrib->function[i]);
-
- if (f)
- functionList.push_back (f);
- }
-
- foreach (Function *f, functionList)
- mask &= f->mask;
-
- if (!mask)
- {
- compLogMessage (NULL, "core", CompLogLevelWarn,
- "fragment functions can't be linked together "
- "because a common type doesn't exist");
- }
-
- if (!mask || functionList.size () == 1)
- {
- delete program;
- return NULL;
- }
-
- for (i = 0; i < attrib->nFunction; i++)
- program->signature.push_back (attrib->function[i]);
-
- type = functionMaskToType (mask);
-
- fetchData = "!!ARBfp1.0";
-
- foreach (bool &val, indices)
- val = false;
-
- forEachDataOp (functionList, type,
- boost::bind (addFetchOffsetVariables, _1, _2, indices, &fetchData));
-
- program->blending = forEachDataOp (functionList, type,
- boost::bind (addData, _1, &fetchData));
-
- program->type = GL_FRAGMENT_PROGRAM_ARB;
-
- glGetError ();
-
- (*s->genPrograms) (1, &program->name);
- (*s->bindProgram) (GL_FRAGMENT_PROGRAM_ARB, program->name);
- (*s->programString) (GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- fetchData.size (), fetchData.c_str ());
-
- glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError () != GL_NO_ERROR || errorPos != -1)
- {
- compLogMessage (NULL, "core", CompLogLevelError,
- "failed to load fragment program");
-
- (*s->deletePrograms) (1, &program->name);
-
- program->name = 0;
- program->type = 0;
- }
-
- return program;
- }
-
- static GLuint
- getFragmentProgram (CompScreen *s,
- PrivateAttrib *attrib,
- GLenum *type,
- bool *blending)
- {
- Program *program;
-
- if (!attrib->nFunction)
- return 0;
-
- program = findFragmentProgram (s, attrib->function, attrib->nFunction);
- if (!program)
- {
- program = buildFragmentProgram (s, attrib);
- if (program)
- {
- s->fragmentStorage ()->programs.push_back (program);
- }
- }
-
- if (program)
- {
- *type = program->type;
- *blending = program->blending;
-
- return program->name;
- }
-
- return 0;
- }
-
-
- /* performs simple variable substitution */
- static CompString
- copyData (std::vector<HeaderOp> header,
- const CompString prefix,
- CompString data)
- {
- CompString inPrefix = "_";
- inPrefix += prefix;
-
- CompString copy;
-
- foreach (HeaderOp &h, header)
- {
- size_t pos = data.find (h.name);
- while (pos != std::string::npos)
- {
- data.insert (pos,inPrefix);
- pos += inPrefix.size () + h.name.size ();
- pos = data.find (h.name, pos);
- }
- }
- return copy;
- }
-
- PrivateFunctionData::PrivateFunctionData (const PrivateFunctionData& src,
- CompString dstPrefix) :
- header (src.header),
- body (0)
- {
-
- foreach (BodyOp b, src.body)
- {
- BodyOp dst;
- dst.type = b.type;
-
- switch (b.type) {
- case OpTypeFetch:
- dst.dst = copyData (header, dstPrefix, b.dst);
- if (b.data.size ())
- dst.data = copyData (header, dstPrefix, b.data);
- else
- dst.data = "";
-
- dst.target = b.target;
- break;
- case OpTypeLoad:
- case OpTypeHeaderTemp:
- case OpTypeHeaderParam:
- case OpTypeHeaderAttrib:
- break;
- case OpTypeData:
- case OpTypeDataBlend:
- case OpTypeDataStore:
- case OpTypeDataOffset:
- dst.data = copyData (header, dstPrefix, b.data);
- break;
- case OpTypeColor:
- dst.dst = copyData (header, dstPrefix, b.dst);
- dst.src = copyData (header, dstPrefix, b.src);
- break;
- }
- body.push_back (dst);
- }
- }
-
- static bool
- addHeaderOpToFunctionData (PrivateFunctionData *data,
- const char *name,
- OpType type)
- {
- static const char *reserved[] = {
- "output",
- "__tmp_texcoord",
- "fragment",
- "program",
- "result",
- "state",
- "texture"
- };
- HeaderOp header;
- CompString n (name);
-
- foreach (const char *word, reserved)
- {
- if (n.find (word) != std::string::npos)
- {
- compLogMessage (NULL, "core", CompLogLevelWarn,
- "%s is a reserved word", word);
- return false;
- }
- }
-
-
- header.type = type;
- header.name = n;
- data->header.push_back (header);
-
- return true;
- }
-
- FunctionData::FunctionData () :
- priv (new PrivateFunctionData ())
- {
- }
-
- FunctionData::~FunctionData ()
- {
- delete priv;
- }
-
- bool
- FunctionData::status ()
- {
- return priv->status;
- }
-
- void
- FunctionData::addTempHeaderOp (const char *name)
- {
- priv->status &=
- addHeaderOpToFunctionData (priv, name, OpTypeHeaderTemp);
- }
-
- void
- FunctionData::addParamHeaderOp (const char *name)
- {
- priv->status &=
- addHeaderOpToFunctionData (priv, name, OpTypeHeaderParam);
- }
-
- void
- FunctionData::addAttribHeaderOp (const char *name)
- {
- priv->status &=
- addHeaderOpToFunctionData (priv, name, OpTypeHeaderAttrib);
- }
-
-
- void
- FunctionData::addFetchOp (const char *dst, const char *offset, int target)
- {
- BodyOp b;
-
- b.type = OpTypeFetch;
- b.dst = CompString (dst);
- b.target = target;
-
- if (offset)
- b.data = CompString (offset);
- else
- b.data = CompString ("");
-
- priv->body.push_back (b);
- }
-
- void
- FunctionData::addColorOp (const char *dst, const char *src)
- {
- BodyOp b;
-
- b.type = OpTypeColor;
- b.dst = CompString (dst);
- b.src = CompString (src);
-
- priv->body.push_back (b);
- }
-
- void
- FunctionData::addDataOp (const char *str, ...)
- {
- BodyOp b;
- va_list ap;
-
- b.type = OpTypeData;
- va_start (ap, str);
- b.data = compPrintf(str, ap);
- va_end (ap);
-
- priv->body.push_back (b);
- }
-
- void
- FunctionData::addBlendOp (const char *str, ...)
- {
- BodyOp b;
- va_list ap;
-
- b.type = OpTypeDataBlend;
- va_start (ap, str);
- b.data = compPrintf(str, ap);
- va_end (ap);
-
- priv->body.push_back (b);
- }
-
- FunctionId
- FunctionData::createFragmentFunction (CompScreen *s, const char *name)
- {
- Function *function = new Function ();
- CompString validName = name;
- unsigned int i = 0;
-
-
- while (findFragmentFunctionWithName (s, validName))
- {
- validName = compPrintf ("%s%d", name, i++);
- }
-
- function->data[COMP_FUNCTION_TYPE_ARB] =
- PrivateFunctionData (*priv, validName);
-
- function->name = validName;
- function->mask = COMP_FUNCTION_ARB_MASK;
- function->id = s->fragmentStorage ()->lastFunctionId++;
-
- s->fragmentStorage ()->functions.push_back (function);
-
- return function->id;
- }
-
- Attrib::Attrib (const CompWindowPaintAttrib *paint) :
- priv (new PrivateAttrib ())
- {
- priv->opacity = paint->opacity;
- priv->brightness = paint->brightness;
- priv->saturation = paint->saturation;
- priv->nTexture = 0;
- priv->nFunction = 0;
- priv->nParam = 0;
-
- foreach (FunctionId &f, priv->function)
- f = 0;
- };
-
- Attrib::Attrib (const Attrib &fa) :
- priv (new PrivateAttrib ())
- {
- priv->opacity = fa.priv->opacity;
- priv->brightness = fa.priv->brightness;
- priv->saturation = fa.priv->saturation;
- priv->nTexture = fa.priv->nTexture;
- priv->nFunction = fa.priv->nFunction;
- priv->nParam = fa.priv->nParam;
-
- for (int i = 0; i < MAX_FRAGMENT_FUNCTIONS; i++)
- priv->function[i] = fa.priv->function[i];
- }
-
- Attrib::~Attrib ()
- {
- delete priv;
- }
-
- unsigned int
- Attrib::allocTextureUnits (unsigned int nTexture)
- {
- unsigned int first = priv->nTexture;
-
- priv->nTexture += nTexture;
-
- /* 0 is reserved for source texture */
- return 1 + first;
- }
-
- unsigned int
- Attrib::allocParameters (unsigned int nParam)
- {
- unsigned int first = priv->nParam;
-
- priv->nParam += nParam;
-
- return first;
- }
-
- void
- Attrib::addFunction (FunctionId function)
- {
- if (priv->nFunction < MAX_FRAGMENT_FUNCTIONS)
- priv->function[priv->nFunction++] = function;
- }
-
- bool
- Attrib::enable (CompScreen *s, bool *blending)
- {
- GLuint name;
- GLenum type;
- bool programBlending;
-
- if (!s->fragmentProgram ())
- return false;
-
- name = getFragmentProgram (s, priv, &type, &programBlending);
- if (!name)
- return false;
-
- *blending = !programBlending;
-
- glEnable (GL_FRAGMENT_PROGRAM_ARB);
-
- (*s->bindProgram) (type, name);
-
- return true;
- }
-
- void
- Attrib::disable (CompScreen *s)
- {
- glDisable (GL_FRAGMENT_PROGRAM_ARB);
- }
-
- unsigned short
- Attrib::getSaturation ()
- {
- return priv->saturation;
- }
-
- unsigned short
- Attrib::getBrightness ()
- {
- return priv->brightness;
- }
-
- unsigned short
- Attrib::getOpacity ()
- {
- return priv->opacity;
- }
-
- void
- Attrib::setSaturation (unsigned short value)
- {
- priv->saturation = value;
- }
-
- void
- Attrib::setBrightness (unsigned short value)
- {
- priv->brightness = value;
- }
-
-
- void
- Attrib::setOpacity (unsigned short value)
- {
- priv->opacity = value;
- }
-
- bool
- Attrib::hasFunctions ()
- {
- return priv->nFunction > 0;
- }
-
- void destroyFragmentFunction (CompScreen *s, FunctionId id)
- {
- Function *function;
- Program *program;
-
- function = findFragmentFunction (s, id);
-
- if (!function)
- return;
-
- std::vector<Program *>::iterator it;
-
- do {
- it = s->fragmentStorage ()->programs.begin ();
- for (; it != s->fragmentStorage ()->programs.end (); it++)
- {
- program = (*it);
- foreach (FunctionId i, program->signature)
- if (i == id)
- break;
- program = NULL;
- }
-
- if (program)
- {
- delete program;
- s->fragmentStorage ()->programs.erase (it);
- }
-
- } while (program);
-
-
- std::vector<Function *>::iterator fi =
- std::find (s->fragmentStorage ()->functions.begin (),
- s->fragmentStorage ()->functions.end (),
- function);
- if (fi != s->fragmentStorage ()->functions.end ())
- s->fragmentStorage ()->functions.erase (fi);
-
- delete (function);
- }
-
- FunctionId
- getSaturateFragmentFunction (CompScreen *s,
- CompTexture *texture,
- int param)
- {
- int target;
-
- if (param >= 64)
- return 0;
-
- if (texture->target () == GL_TEXTURE_2D)
- target = COMP_FETCH_TARGET_2D;
- else
- target = COMP_FETCH_TARGET_RECT;
-
- if (!s->fragmentStorage ()->saturateFunction [target][param])
- {
- static const char *saturateData =
- "MUL temp, output, { 1.0, 1.0, 1.0, 0.0 };"
- "DP3 temp, temp, program.env[%d];"
- "LRP output.xyz, program.env[%d].w, output, temp;";
- FunctionData data;
-
- data.addTempHeaderOp ("temp");
- data.addFetchOp ("output", NULL, target);
- data.addColorOp ("output", "output");
-
- data.addDataOp (saturateData, param, param);
-
- if (!data.status ())
- return 0;
-
- s->fragmentStorage ()->saturateFunction [target][param] =
- data.createFragmentFunction (s, "__core_saturate");
-
- }
-
- return s->fragmentStorage ()->saturateFunction [target][param];
- }
-
- Storage::Storage () :
- lastFunctionId (0),
- functions (0),
- programs (0)
- {
- for (int i = 0; i < 64; i++)
- {
- saturateFunction[0][i] = 0;
- saturateFunction[1][i] = 0;
- }
- }
-
- Storage::~Storage ()
- {
- foreach (Program *p, programs)
- delete p;
- programs.clear ();
- foreach (Function *f, functions)
- delete f;
- functions.clear ();
- }
-
-};
diff --git a/src/icon.cpp b/src/icon.cpp
index f15a278..5dcdd0d 100644
--- a/src/icon.cpp
+++ b/src/icon.cpp
@@ -2,7 +2,6 @@
CompIcon::CompIcon (CompScreen *screen, unsigned int width,
unsigned int height) :
- mTexture (screen),
mWidth (width),
mHeight (height),
mData (new unsigned char[width * height * 4]),
@@ -12,21 +11,7 @@ CompIcon::CompIcon (CompScreen *screen, unsigned int width,
CompIcon::~CompIcon ()
{
- free (mData);
-}
-
-CompTexture &
-CompIcon::texture ()
-{
- if (mUpdateTex)
- {
- mUpdateTex = false;
- mTexture.reset ();
- if (!mTexture.imageBufferToTexture (&mTexture,
- reinterpret_cast<const char *> (mData), mWidth, mHeight))
- mTexture.reset ();
- }
- return mTexture;
+ delete mData;
}
unsigned int
diff --git a/src/main.cpp b/src/main.cpp
index bc27859..cb7c675 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -49,17 +49,11 @@ char *backgroundImage = NULL;
REGION emptyRegion;
REGION infiniteRegion;
-GLushort defaultColor[4] = { 0xffff, 0xffff, 0xffff, 0xffff };
-Window currentRoot = 0;
-
-int defaultRefreshRate = 50;
-const char *defaultTextureFilter = "Good";
bool shutDown = false;
bool restartSignal = false;
CompWindow *lastFoundWindow = 0;
-CompWindow *lastDamagedWindow = 0;
bool replaceCurrentWm = false;
bool indirectRendering = false;
@@ -68,9 +62,7 @@ bool noDetection = false;
bool useDesktopHints = true;
bool onlyCurrentScreen = false;
-#ifdef USE_COW
bool useCow = true;
-#endif
CompMetadata *coreMetadata = NULL;
@@ -80,8 +72,6 @@ usage (void)
printf ("Usage: %s "
"[--display DISPLAY] "
"[--bg-image PNG] "
- "[--refresh-rate RATE]\n "
- "[--fast-filter] "
"[--indirect-rendering] "
"[--loose-binding] "
"[--replace]\n "
@@ -90,13 +80,7 @@ usage (void)
"[--no-detection]\n "
"[--ignore-desktop-hints] "
"[--only-current-screen]"
-
-#ifdef USE_COW
" [--use-root-window]\n "
-#else
- "\n "
-#endif
-
"[--version] "
"[--help] "
"[PLUGIN]...\n",
@@ -127,8 +111,6 @@ signalHandler (int sig)
typedef struct _CompIOCtx {
unsigned int offset;
char *pluginData;
- char *textureFilterData;
- char *refreshRateData;
} CompIOCtx;
static int
@@ -152,9 +134,6 @@ readCoreXmlCallback (void *context,
if (ctx->pluginData)
info.data = ctx->pluginData;
break;
- case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
- if (ctx->textureFilterData)
- info.data = ctx->textureFilterData;
default:
break;
}
@@ -163,28 +142,9 @@ readCoreXmlCallback (void *context,
buffer + i, length - i);
}
- i += CompMetadata::readXmlChunk ("</display><screen>", &offset,
+ i += CompMetadata::readXmlChunk ("</display></core></compiz>", &offset,
buffer + i, length - 1);
- for (j = 0; j < COMP_SCREEN_OPTION_NUM; j++)
- {
- CompMetadata::OptionInfo info = coreScreenOptionInfo[j];
-
- switch (j) {
- case COMP_SCREEN_OPTION_REFRESH_RATE:
- if (ctx->refreshRateData)
- info.data = ctx->refreshRateData;
- default:
- break;
- }
-
- i += CompMetadata::readXmlChunkFromOptionInfo (&info, &offset,
- buffer + i, length - i);
- }
-
- i += CompMetadata::readXmlChunk ("</screen></core></compiz>", &offset,
- buffer + i, length - i);
-
if (!offset && length > (int)i)
buffer[i++] = '\0';
@@ -202,7 +162,6 @@ main (int argc, char **argv)
int i, nPlugin = 0;
Bool disableSm = FALSE;
char *clientId = NULL;
- char *refreshRateArg = NULL;
programName = argv[0];
programArgc = argc;
@@ -247,22 +206,6 @@ main (int argc, char **argv)
if (i + 1 < argc)
displayName = argv[++i];
}
- else if (!strcmp (argv[i], "--refresh-rate"))
- {
- if (i + 1 < argc)
- {
- refreshRateArg = programArgv[++i];
- defaultRefreshRate = atoi (refreshRateArg);
- defaultRefreshRate = RESTRICT_VALUE (defaultRefreshRate,
- 1, 1000);
- }
- }
- else if (!strcmp (argv[i], "--fast-filter"))
- {
- ctx.textureFilterData =
- const_cast<char *> ("<default>Fast</default>");
- defaultTextureFilter = "Fast";
- }
else if (!strcmp (argv[i], "--indirect-rendering"))
{
indirectRendering = TRUE;
@@ -279,14 +222,10 @@ main (int argc, char **argv)
{
onlyCurrentScreen = TRUE;
}
-
-#ifdef USE_COW
else if (!strcmp (argv[i], "--use-root-window"))
{
useCow = FALSE;
}
-#endif
-
else if (!strcmp (argv[i], "--replace"))
{
replaceCurrentWm = TRUE;
@@ -321,15 +260,6 @@ main (int argc, char **argv)
}
}
- if (refreshRateArg)
- {
- ctx.refreshRateData = (char *) malloc (strlen (refreshRateArg) + 256);
- if (ctx.refreshRateData)
- sprintf (ctx.refreshRateData,
- "<min>1</min><default>%s</default>",
- refreshRateArg);
- }
-
if (nPlugin)
{
int size = 256;
@@ -360,9 +290,6 @@ main (int argc, char **argv)
if (!coreMetadata->addFromIO (readCoreXmlCallback, NULL, &ctx))
return 1;
- if (ctx.refreshRateData)
- free (ctx.refreshRateData);
-
if (ctx.pluginData)
free (ctx.pluginData);
diff --git a/src/matrix.cpp b/src/matrix.cpp
deleted file mode 100644
index 4718b69..0000000
--- a/src/matrix.cpp
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (C) 1999-2005 Brian Paul 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, 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
- * BRIAN PAUL 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.
- *
- * From Mesa 3-D graphics library.
- */
-
-#include <compiz.h>
-#include <string.h>
-#include <math.h>
-#include <compiz-core.h>
-#include <compmatrix.h>
-
-/**
- * Identity matrix.
- */
-static const float identity[16] = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
-};
-
-#define A(row, col) a[(col << 2) + row]
-#define B(row, col) b[(col << 2) + row]
-#define P(row, col) product[(col << 2) + row]
-
-/**
- * Perform a full 4x4 matrix multiplication.
- *
- * \param a matrix.
- * \param b matrix.
- * \param product will receive the product of \p a and \p b.
- *
- * \warning Is assumed that \p product != \p b. \p product == \p a is allowed.
- *
- * \note KW: 4*16 = 64 multiplications
- *
- * \author This \c matmul was contributed by Thomas Malik
- */
-static void
-matmul4 (float *product,
- const float *a,
- const float *b)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- {
- const float ai0 = A(i,0), ai1 = A(i,1), ai2 = A(i,2), ai3 = A(i,3);
-
- P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
- P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
- P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
- P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
- }
-}
-
-CompMatrix::CompMatrix ()
-{
- memcpy (m, identity, sizeof (m));
-}
-
-void
-CompMatrix::reset ()
-{
- memcpy (m, identity, sizeof (m));
-}
-
-const float *
-CompMatrix::getMatrix () const
-{
- return m;
-}
-
-CompMatrix&
-CompMatrix::operator*= (const CompMatrix& rhs)
-{
- *this = *this * rhs;
-
- return *this;
-}
-
-CompMatrix
-operator* (const CompMatrix& lhs,
- const CompMatrix& rhs)
-{
- CompMatrix result;
-
- matmul4 (result.m, lhs.m, rhs.m);
-
- return result;
-}
-
-CompVector
-operator* (const CompMatrix& lhs,
- const CompVector& rhs)
-{
- CompVector result;
- const float *a = lhs.m;
- int i;
-
- for (i = 0; i < 4; i++)
- {
- result[i] = A(i,0) * rhs[0] + A(i,1) * rhs[1] +
- A(i,2) * rhs[2] + A(i,3) * rhs[3];
- }
-
- return result;
-}
-
-#undef A
-#undef B
-#undef P
-
-/**
- * Generate a 4x4 transformation matrix from glRotate parameters, and
- * post-multiply the input matrix by it.
- *
- * \author
- * This function was contributed by Erich Boleyn (erich@uruk.org).
- * Optimizations contributed by Rudolf Opalla (rudi@khm.de).
- */
-void
-CompMatrix::rotate (const float angle,
- const float xRot,
- const float yRot,
- const float zRot)
-{
- float x = xRot, y = yRot, z = zRot;
- float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c;
- float matrix[16];
- Bool optimized;
-
- s = (float) sin (angle * DEG2RAD);
- c = (float) cos (angle * DEG2RAD);
-
- memcpy (matrix, identity, sizeof (matrix));
- optimized = FALSE;
-
-#define M(row, col) matrix[col * 4 + row]
-
- if (x == 0.0f)
- {
- if (y == 0.0f)
- {
- if (z != 0.0f)
- {
- optimized = TRUE;
- /* rotate only around z-axis */
- M(0,0) = c;
- M(1,1) = c;
- if (z < 0.0f)
- {
- M(0,1) = s;
- M(1,0) = -s;
- }
- else
- {
- M(0,1) = -s;
- M(1,0) = s;
- }
- }
- }
- else if (z == 0.0f)
- {
- optimized = TRUE;
- /* rotate only around y-axis */
- M(0,0) = c;
- M(2,2) = c;
- if (y < 0.0f)
- {
- M(0,2) = -s;
- M(2,0) = s;
- }
- else
- {
- M(0,2) = s;
- M(2,0) = -s;
- }
- }
- }
- else if (y == 0.0f)
- {
- if (z == 0.0f)
- {
- optimized = TRUE;
- /* rotate only around x-axis */
- M(1,1) = c;
- M(2,2) = c;
- if (x < 0.0f)
- {
- M(1,2) = s;
- M(2,1) = -s;
- }
- else
- {
- M(1,2) = -s;
- M(2,1) = s;
- }
- }
- }
-
- if (!optimized)
- {
- const float mag = sqrtf (x * x + y * y + z * z);
-
- if (mag <= 1.0e-4)
- {
- /* no rotation, leave mat as-is */
- return;
- }
-
- x /= mag;
- y /= mag;
- z /= mag;
-
-
- /*
- * Arbitrary axis rotation matrix.
- *
- * This is composed of 5 matrices, Rz, Ry, T, Ry', Rz', multiplied
- * like so: Rz * Ry * T * Ry' * Rz'. T is the final rotation
- * (which is about the X-axis), and the two composite transforms
- * Ry' * Rz' and Rz * Ry are (respectively) the rotations necessary
- * from the arbitrary axis to the X-axis then back. They are
- * all elementary rotations.
- *
- * Rz' is a rotation about the Z-axis, to bring the axis vector
- * into the x-z plane. Then Ry' is applied, rotating about the
- * Y-axis to bring the axis vector parallel with the X-axis. The
- * rotation about the X-axis is then performed. Ry and Rz are
- * simply the respective inverse transforms to bring the arbitrary
- * axis back to it's original orientation. The first transforms
- * Rz' and Ry' are considered inverses, since the data from the
- * arbitrary axis gives you info on how to get to it, not how
- * to get away from it, and an inverse must be applied.
- *
- * The basic calculation used is to recognize that the arbitrary
- * axis vector (x, y, z), since it is of unit length, actually
- * represents the sines and cosines of the angles to rotate the
- * X-axis to the same orientation, with theta being the angle about
- * Z and phi the angle about Y (in the order described above)
- * as follows:
- *
- * cos ( theta ) = x / sqrt ( 1 - z^2 )
- * sin ( theta ) = y / sqrt ( 1 - z^2 )
- *
- * cos ( phi ) = sqrt ( 1 - z^2 )
- * sin ( phi ) = z
- *
- * Note that cos ( phi ) can further be inserted to the above
- * formulas:
- *
- * cos ( theta ) = x / cos ( phi )
- * sin ( theta ) = y / sin ( phi )
- *
- * ...etc. Because of those relations and the standard trigonometric
- * relations, it is pssible to reduce the transforms down to what
- * is used below. It may be that any primary axis chosen will give the
- * same results (modulo a sign convention) using thie method.
- *
- * Particularly nice is to notice that all divisions that might
- * have caused trouble when parallel to certain planes or
- * axis go away with care paid to reducing the expressions.
- * After checking, it does perform correctly under all cases, since
- * in all the cases of division where the denominator would have
- * been zero, the numerator would have been zero as well, giving
- * the expected result.
- */
-
- xx = x * x;
- yy = y * y;
- zz = z * z;
- xy = x * y;
- yz = y * z;
- zx = z * x;
- xs = x * s;
- ys = y * s;
- zs = z * s;
- one_c = 1.0f - c;
-
- /* We already hold the identity-matrix so we can skip some statements */
- M(0,0) = (one_c * xx) + c;
- M(0,1) = (one_c * xy) - zs;
- M(0,2) = (one_c * zx) + ys;
-/* M(0,3) = 0.0F; */
-
- M(1,0) = (one_c * xy) + zs;
- M(1,1) = (one_c * yy) + c;
- M(1,2) = (one_c * yz) - xs;
-/* M(1,3) = 0.0F; */
-
- M(2,0) = (one_c * zx) - ys;
- M(2,1) = (one_c * yz) + xs;
- M(2,2) = (one_c * zz) + c;
-/* M(2,3) = 0.0F; */
-
-/*
- M(3,0) = 0.0F;
- M(3,1) = 0.0F;
- M(3,2) = 0.0F;
- M(3,3) = 1.0F;
-*/
- }
-#undef M
-
- matmul4 (m, m, matrix);
-}
-
-void
-CompMatrix::rotate (const float angle,
- const CompVector& vector)
-{
- rotate (angle,
- vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
-}
-
-/**
- * Multiply a matrix with a general scaling matrix.
- *
- * \param matrix matrix.
- * \param x x axis scale factor.
- * \param y y axis scale factor.
- * \param z z axis scale factor.
- *
- * Multiplies in-place the elements of \p matrix by the scale factors.
- */
-void
-CompMatrix::scale (const float x,
- const float y,
- const float z)
-{
- m[0] *= x; m[4] *= y; m[8] *= z;
- m[1] *= x; m[5] *= y; m[9] *= z;
- m[2] *= x; m[6] *= y; m[10] *= z;
- m[3] *= x; m[7] *= y; m[11] *= z;
-}
-
-void
-CompMatrix::scale (const CompVector& vector)
-{
- scale (vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
-}
-
-/**
- * Multiply a matrix with a translation matrix.
- *
- * \param matrix matrix.
- * \param x translation vector x coordinate.
- * \param y translation vector y coordinate.
- * \param z translation vector z coordinate.
- *
- * Adds the translation coordinates to the elements of \p matrix in-place.
- */
-void
-CompMatrix::translate (const float x,
- const float y,
- const float z)
-{
- m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
- m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
- m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
- m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
-}
-
-void
-CompMatrix::translate (const CompVector& vector)
-{
- translate (vector[CompVector::x],
- vector[CompVector::y],
- vector[CompVector::z]);
-}
-
-void
-CompMatrix::toScreenSpace (CompOutput *output,
- float z)
-{
- translate (-0.5f, -0.5f, z);
- scale (1.0f / output->width (), -1.0f / output->height (), 1.0f);
- translate (-output->x1 (), -output->y2 (), 0.0f);
-}
diff --git a/src/option.cpp b/src/option.cpp
index 4178756..d100a8c 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -210,6 +210,8 @@ CompOption::Value::f ()
return priv->value.f;
}
+static unsigned short defaultColor[4] = { 0x0, 0x0, 0x0, 0xffff};
+
unsigned short*
CompOption::Value::c ()
{
diff --git a/src/paint.cpp b/src/paint.cpp
deleted file mode 100644
index c2e6f4e..0000000
--- a/src/paint.cpp
+++ /dev/null
@@ -1,1191 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <boost/foreach.hpp>
-#define foreach BOOST_FOREACH
-
-#include <compiz-core.h>
-
-#include "privatescreen.h"
-#include "privatewindow.h"
-
-CompScreenPaintAttrib defaultScreenPaintAttrib = {
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
-};
-
-CompWindowPaintAttrib defaultWindowPaintAttrib = {
- OPAQUE, BRIGHT, COLOR, 1.0f, 1.0f, 0.0f, 0.0f
-};
-
-void
-CompScreen::preparePaint (int msSinceLastPaint)
- WRAPABLE_HND_FUNC(preparePaint, msSinceLastPaint)
-
-void
-CompScreen::donePaint ()
- WRAPABLE_HND_FUNC(donePaint)
-
-void
-CompScreen::applyTransform (const CompScreenPaintAttrib *sAttrib,
- CompOutput *output,
- CompTransform *transform)
-{
- WRAPABLE_HND_FUNC(applyTransform, sAttrib, output, transform)
-
- transform->translate (sAttrib->xTranslate,
- sAttrib->yTranslate,
- sAttrib->zTranslate + sAttrib->zCamera);
- transform->rotate (sAttrib->xRotate, 0.0f, 1.0f, 0.0f);
- transform->rotate (sAttrib->vRotate,
- cosf (sAttrib->xRotate * DEG2RAD),
- 0.0f,
- sinf (sAttrib->xRotate * DEG2RAD));
- transform->rotate (sAttrib->yRotate, 0.0f, 1.0f, 0.0f);
-}
-
-void
-PrivateScreen::paintBackground (Region region,
- bool transformed)
-{
- CompTexture *bg = &backgroundTexture;
- BoxPtr pBox = region->rects;
- int n, nBox = region->numRects;
- GLfloat *d, *data;
-
- if (!nBox)
- return;
-
- if (desktopWindowCount)
- {
- if (bg->name ())
- {
- bg->reset ();
- }
-
- backgroundLoaded = false;
-
- return;
- }
- else
- {
- if (!backgroundLoaded)
- updateScreenBackground (bg);
-
- backgroundLoaded = true;
- }
-
- data = (GLfloat *) malloc (sizeof (GLfloat) * nBox * 16);
- if (!data)
- return;
-
- d = data;
- n = nBox;
- while (n--)
- {
- *d++ = COMP_TEX_COORD_X (&bg->matrix (), pBox->x1);
- *d++ = COMP_TEX_COORD_Y (&bg->matrix (), pBox->y2);
-
- *d++ = pBox->x1;
- *d++ = pBox->y2;
-
- *d++ = COMP_TEX_COORD_X (&bg->matrix (), pBox->x2);
- *d++ = COMP_TEX_COORD_Y (&bg->matrix (), pBox->y2);
-
- *d++ = pBox->x2;
- *d++ = pBox->y2;
-
- *d++ = COMP_TEX_COORD_X (&bg->matrix (), pBox->x2);
- *d++ = COMP_TEX_COORD_Y (&bg->matrix (), pBox->y1);
-
- *d++ = pBox->x2;
- *d++ = pBox->y1;
-
- *d++ = COMP_TEX_COORD_X (&bg->matrix (), pBox->x1);
- *d++ = COMP_TEX_COORD_Y (&bg->matrix (), pBox->y1);
-
- *d++ = pBox->x1;
- *d++ = pBox->y1;
-
- pBox++;
- }
-
- glTexCoordPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, data);
- glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, data + 2);
-
- if (bg->name ())
- {
- if (transformed)
- bg->enable (CompTexture::Good);
- else
- bg->enable (CompTexture::Fast);
-
- glDrawArrays (GL_QUADS, 0, nBox * 4);
-
- bg->disable ();
- }
- else
- {
- glColor4us (0, 0, 0, 0);
- glDrawArrays (GL_QUADS, 0, nBox * 4);
- glColor4usv (defaultColor);
- }
-
- free (data);
-}
-
-
-/* This function currently always performs occlusion detection to
- minimize paint regions. OpenGL precision requirements are no good
- enough to guarantee that the results from using occlusion detection
- is the same as without. It's likely not possible to see any
- difference with most hardware but occlusion detection in the
- transformed screen case should be made optional for those who do
- see a difference. */
-void
-PrivateScreen::paintOutputRegion (const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
-{
- static Region tmpRegion = NULL;
- CompWindow *w;
- int count, windowMask, odMask;
- CompWindow *fullscreenWindow = NULL;
- bool status;
- bool withOffset = false;
- CompTransform vTransform;
- int offX, offY;
- Region clip = region;
-
- CompWindowList pl;
- CompWindowList::reverse_iterator rit;
-
- if (!tmpRegion)
- {
- tmpRegion = XCreateRegion ();
- if (!tmpRegion)
- return;
- }
-
- if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
- {
- windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
- count = 1;
- }
- else
- {
- windowMask = 0;
- count = 0;
- }
-
- XSubtractRegion (region, &emptyRegion, tmpRegion);
-
- pl = screen->getWindowPaintList ();
-
- if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
- {
- /* detect occlusions */
- for (rit = pl.rbegin (); rit != pl.rend(); rit++)
- {
- w = (*rit);
-
- if (w->destroyed ())
- continue;
-
- if (!w->shaded ())
- {
- if (w->attrib ().map_state != IsViewable || !w->damaged ())
- continue;
- }
-
- /* copy region */
- XSubtractRegion (tmpRegion, &emptyRegion, w->clip ());
-
- odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;
-
- if ((windowPaintOffset.x () != 0 || windowPaintOffset.x () != 0) &&
- !w->onAllViewports ())
- {
- withOffset = true;
-
- w->getMovementForOffset (windowPaintOffset.x (),
- windowPaintOffset.y (),
- &offX, &offY);
-
- vTransform = *transform;
- vTransform.translate (offX, offY, 0);
-
- XOffsetRegion (w->clip (), -offX, -offY);
-
- odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
- status = w->paint (&w->paintAttrib (), &vTransform,
- tmpRegion, odMask);
- }
- else
- {
- withOffset = false;
- status = w->paint (&w->paintAttrib (), transform, tmpRegion,
- odMask);
- }
-
- if (status)
- {
- if (withOffset)
- {
- XOffsetRegion (w->region (), offX, offY);
- XSubtractRegion (tmpRegion, w->region (), tmpRegion);
- XOffsetRegion (w->region (), -offX, -offY);
- }
- else
- XSubtractRegion (tmpRegion, w->region (), tmpRegion);
-
- /* unredirect top most fullscreen windows. */
- if (count == 0 &&
- opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value ().b ())
- {
- if (XEqualRegion (w->region (), &this->region) &&
- !REGION_NOT_EMPTY (tmpRegion))
- {
- fullscreenWindow = w;
- }
- else
- {
- for (unsigned int i = 0; i < outputDevs.size (); i++)
- if (XEqualRegion (w->region (),
- outputDevs[i].region ()))
- fullscreenWindow = w;
- }
- }
- }
-
- count++;
- }
- }
-
- if (fullscreenWindow)
- fullscreenWindow->unredirect ();
-
- if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
- paintBackground (tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK));
-
- /* paint all windows from bottom to top */
- foreach (w, pl)
- {
- if (w->destroyed ())
- continue;
-
- if (w == fullscreenWindow)
- continue;
-
- if (!w->shaded ())
- {
- if (w->attrib ().map_state != IsViewable || !w->damaged ())
- continue;
- }
-
- if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
- clip = w->clip ();
-
- if ((windowPaintOffset.x () != 0 || windowPaintOffset.y () != 0) &&
- !w->onAllViewports ())
- {
- w->getMovementForOffset (windowPaintOffset.x (),
- windowPaintOffset.y (),
- &offX, &offY);
-
- vTransform = *transform;
- vTransform.translate (offX, offY, 0);
- w->paint (&w->paintAttrib (), &vTransform, clip,
- windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
- }
- else
- {
- w->paint (&w->paintAttrib (), transform, clip, windowMask);
- }
- }
-}
-
-void
-CompScreen::enableOutputClipping (const CompTransform *transform,
- Region region,
- CompOutput *output)
-{
- WRAPABLE_HND_FUNC(enableOutputClipping, transform, region, output)
-
- GLdouble h = priv->size.height ();
-
- GLdouble p1[2] = { region->extents.x1, h - region->extents.y2 };
- GLdouble p2[2] = { region->extents.x2, h - region->extents.y1 };
-
- GLdouble halfW = output->width () / 2.0;
- GLdouble halfH = output->height () / 2.0;
-
- GLdouble cx = output->x1 () + halfW;
- GLdouble cy = (h - output->y2 ()) + halfH;
-
- GLdouble top[4] = { 0.0, halfH / (cy - p1[1]), 0.0, 0.5 };
- GLdouble bottom[4] = { 0.0, halfH / (cy - p2[1]), 0.0, 0.5 };
- GLdouble left[4] = { halfW / (cx - p1[0]), 0.0, 0.0, 0.5 };
- GLdouble right[4] = { halfW / (cx - p2[0]), 0.0, 0.0, 0.5 };
-
- glPushMatrix ();
- glLoadMatrixf (transform->getMatrix ());
-
- glClipPlane (GL_CLIP_PLANE0, top);
- glClipPlane (GL_CLIP_PLANE1, bottom);
- glClipPlane (GL_CLIP_PLANE2, left);
- glClipPlane (GL_CLIP_PLANE3, right);
-
- glEnable (GL_CLIP_PLANE0);
- glEnable (GL_CLIP_PLANE1);
- glEnable (GL_CLIP_PLANE2);
- glEnable (GL_CLIP_PLANE3);
-
- glPopMatrix ();
-}
-
-void
-CompScreen::disableOutputClipping ()
-{
- WRAPABLE_HND_FUNC(disableOutputClipping)
-
- glDisable (GL_CLIP_PLANE0);
- glDisable (GL_CLIP_PLANE1);
- glDisable (GL_CLIP_PLANE2);
- glDisable (GL_CLIP_PLANE3);
-}
-
-#define CLIP_PLANE_MASK (PAINT_SCREEN_TRANSFORMED_MASK | \
- PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
-
-void
-CompScreen::paintTransformedOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC(paintTransformedOutput, sAttrib, transform,
- region, output, mask)
-
- CompTransform sTransform = *transform;
-
- if (mask & PAINT_SCREEN_CLEAR_MASK)
- priv->display->clearTargetOutput (GL_COLOR_BUFFER_BIT);
-
- setLighting (true);
-
- applyTransform (sAttrib, output, &sTransform);
-
- if ((mask & CLIP_PLANE_MASK) == CLIP_PLANE_MASK)
- {
- enableOutputClipping (&sTransform, region, output);
-
- sTransform.toScreenSpace (output, -sAttrib->zTranslate);
-
- glPushMatrix ();
- glLoadMatrixf (sTransform.getMatrix ());
-
- priv->paintOutputRegion (&sTransform, region, output, mask);
-
- glPopMatrix ();
-
- disableOutputClipping ();
- }
- else
- {
- sTransform.toScreenSpace (output, -sAttrib->zTranslate);
-
- glPushMatrix ();
- glLoadMatrixf (sTransform.getMatrix ());
-
- priv->paintOutputRegion (&sTransform, region, output, mask);
-
- glPopMatrix ();
- }
-}
-
-bool
-CompScreen::paintOutput (const CompScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC_RETURN(bool, paintOutput, sAttrib, transform,
- region, output, mask)
-
- CompTransform sTransform = *transform;
-
- if (mask & PAINT_SCREEN_REGION_MASK)
- {
- if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
- {
- if (mask & PAINT_SCREEN_FULL_MASK)
- {
- region = output->region ();
- paintTransformedOutput (sAttrib, &sTransform, region,
- output, mask);
-
- return true;
- }
-
- return false;
- }
-
- /* fall through and redraw region */
- }
- else if (mask & PAINT_SCREEN_FULL_MASK)
- {
- paintTransformedOutput (sAttrib, &sTransform, output->region (),
- output, mask);
-
- return true;
- }
- else
- return false;
-
- setLighting (false);
-
- sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
-
- glPushMatrix ();
- glLoadMatrixf (sTransform.getMatrix ());
-
- priv->paintOutputRegion (&sTransform, region, output, mask);
-
- glPopMatrix ();
-
- return true;
-}
-
-#define ADD_RECT(data, m, n, x1, y1, x2, y2) \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_X (&m[it], x1); \
- *(data)++ = COMP_TEX_COORD_Y (&m[it], y1); \
- } \
- *(data)++ = (x1); \
- *(data)++ = (y1); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_X (&m[it], x1); \
- *(data)++ = COMP_TEX_COORD_Y (&m[it], y2); \
- } \
- *(data)++ = (x1); \
- *(data)++ = (y2); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_X (&m[it], x2); \
- *(data)++ = COMP_TEX_COORD_Y (&m[it], y2); \
- } \
- *(data)++ = (x2); \
- *(data)++ = (y2); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_X (&m[it], x2); \
- *(data)++ = COMP_TEX_COORD_Y (&m[it], y1); \
- } \
- *(data)++ = (x2); \
- *(data)++ = (y1); \
- *(data)++ = 0.0
-
-#define ADD_QUAD(data, m, n, x1, y1, x2, y2) \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_XY (&m[it], x1, y1); \
- *(data)++ = COMP_TEX_COORD_YX (&m[it], x1, y1); \
- } \
- *(data)++ = (x1); \
- *(data)++ = (y1); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_XY (&m[it], x1, y2); \
- *(data)++ = COMP_TEX_COORD_YX (&m[it], x1, y2); \
- } \
- *(data)++ = (x1); \
- *(data)++ = (y2); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_XY (&m[it], x2, y2); \
- *(data)++ = COMP_TEX_COORD_YX (&m[it], x2, y2); \
- } \
- *(data)++ = (x2); \
- *(data)++ = (y2); \
- *(data)++ = 0.0; \
- for (it = 0; it < n; it++) \
- { \
- *(data)++ = COMP_TEX_COORD_XY (&m[it], x2, y1); \
- *(data)++ = COMP_TEX_COORD_YX (&m[it], x2, y1); \
- } \
- *(data)++ = (x2); \
- *(data)++ = (y1); \
- *(data)++ = 0.0;
-
-
-bool
-CompWindow::moreVertices (int newSize)
-{
- if (newSize > priv->vertexSize)
- {
- GLfloat *vertices;
-
- vertices = (GLfloat *)
- realloc (priv->vertices, sizeof (GLfloat) * newSize);
- if (!vertices)
- return false;
-
- priv->vertices = vertices;
- priv->vertexSize = newSize;
- }
-
- return true;
-}
-
-bool
-CompWindow::moreIndices (int newSize)
-{
- if (newSize > priv->indexSize)
- {
- GLushort *indices;
-
- indices = (GLushort *)
- realloc (priv->indices, sizeof (GLushort) * newSize);
- if (!indices)
- return false;
-
- priv->indices = indices;
- priv->indexSize = newSize;
- }
-
- return true;
-}
-
-void
-CompWindow::drawGeometry ()
-{
- WRAPABLE_HND_FUNC(drawGeometry)
-
- int texUnit = priv->texUnits;
- int currentTexUnit = 0;
- int stride = priv->vertexStride;
- GLfloat *vertices = priv->vertices + (stride - 3);
-
- stride *= sizeof (GLfloat);
-
- glVertexPointer (3, GL_FLOAT, stride, vertices);
-
- while (texUnit--)
- {
- if (texUnit != currentTexUnit)
- {
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
- currentTexUnit = texUnit;
- }
- vertices -= priv->texCoordSize;
- glTexCoordPointer (priv->texCoordSize, GL_FLOAT, stride, vertices);
- }
-
- glDrawArrays (GL_QUADS, 0, priv->vCount);
-
- /* disable all texture coordinate arrays except 0 */
- texUnit = priv->texUnits;
- if (texUnit > 1)
- {
- while (--texUnit)
- {
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
- }
-
- (*priv->screen->clientActiveTexture) (GL_TEXTURE0_ARB);
- }
-}
-
-void
-CompWindow::addGeometry (CompTexture::Matrix *matrix,
- int nMatrix,
- Region region,
- Region clip)
-{
- WRAPABLE_HND_FUNC(addGeometry, matrix, nMatrix, region, clip)
-
- BoxRec full;
-
- priv->texUnits = nMatrix;
-
- full = clip->extents;
- if (region->extents.x1 > full.x1)
- full.x1 = region->extents.x1;
- if (region->extents.y1 > full.y1)
- full.y1 = region->extents.y1;
- if (region->extents.x2 < full.x2)
- full.x2 = region->extents.x2;
- if (region->extents.y2 < full.y2)
- full.y2 = region->extents.y2;
-
- if (full.x1 < full.x2 && full.y1 < full.y2)
- {
- BoxPtr pBox;
- int nBox;
- BoxPtr pClip;
- int nClip;
- BoxRec cbox;
- int vSize;
- int n, it, x1, y1, x2, y2;
- GLfloat *d;
- bool rect = true;
-
- for (it = 0; it < nMatrix; it++)
- {
- if (matrix[it].xy != 0.0f || matrix[it].yx != 0.0f)
- {
- rect = false;
- break;
- }
- }
-
- pBox = region->rects;
- nBox = region->numRects;
-
- vSize = 3 + nMatrix * 2;
-
- n = priv->vCount / 4;
-
- if ((n + nBox) * vSize * 4 > priv->vertexSize)
- {
- if (!moreVertices ((n + nBox) * vSize * 4))
- return;
- }
-
- d = priv->vertices + (priv->vCount * vSize);
-
- while (nBox--)
- {
- x1 = pBox->x1;
- y1 = pBox->y1;
- x2 = pBox->x2;
- y2 = pBox->y2;
-
- pBox++;
-
- if (x1 < full.x1)
- x1 = full.x1;
- if (y1 < full.y1)
- y1 = full.y1;
- if (x2 > full.x2)
- x2 = full.x2;
- if (y2 > full.y2)
- y2 = full.y2;
-
- if (x1 < x2 && y1 < y2)
- {
- nClip = clip->numRects;
-
- if (nClip == 1)
- {
- if (rect)
- {
- ADD_RECT (d, matrix, nMatrix, x1, y1, x2, y2);
- }
- else
- {
- ADD_QUAD (d, matrix, nMatrix, x1, y1, x2, y2);
- }
-
- n++;
- }
- else
- {
- pClip = clip->rects;
-
- if (((n + nClip) * vSize * 4) > priv->vertexSize)
- {
- if (!moreVertices ((n + nClip) * vSize * 4))
- return;
-
- d = priv->vertices + (n * vSize * 4);
- }
-
- while (nClip--)
- {
- cbox = *pClip;
-
- pClip++;
-
- if (cbox.x1 < x1)
- cbox.x1 = x1;
- if (cbox.y1 < y1)
- cbox.y1 = y1;
- if (cbox.x2 > x2)
- cbox.x2 = x2;
- if (cbox.y2 > y2)
- cbox.y2 = y2;
-
- if (cbox.x1 < cbox.x2 && cbox.y1 < cbox.y2)
- {
- if (rect)
- {
- ADD_RECT (d, matrix, nMatrix,
- cbox.x1, cbox.y1, cbox.x2, cbox.y2);
- }
- else
- {
- ADD_QUAD (d, matrix, nMatrix,
- cbox.x1, cbox.y1, cbox.x2, cbox.y2);
- }
-
- n++;
- }
- }
- }
- }
- }
-
- priv->vCount = n * 4;
- priv->vertexStride = vSize;
- priv->texCoordSize = 2;
- }
-}
-
-static bool
-enableFragmentProgramAndDrawGeometry (CompWindow *w,
- CompTexture *texture,
- CompFragment::Attrib &attrib,
- CompTexture::Filter filter,
- unsigned int mask)
-{
- CompFragment::Attrib fa (attrib);
- CompScreen *s = w->screen ();
- bool blending;
-
- if (s->canDoSaturated () && attrib.getSaturation () != COLOR)
- {
- int param, function;
-
- param = fa.allocParameters (1);
- function =
- CompFragment::getSaturateFragmentFunction (s, texture, param);
-
- fa.addFunction (function);
-
- (*s->programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
- RED_SATURATION_WEIGHT,
- GREEN_SATURATION_WEIGHT,
- BLUE_SATURATION_WEIGHT,
- attrib.getSaturation () / 65535.0f);
- }
-
- if (!fa.enable (s, &blending))
- return false;
-
- texture->enable (filter);
-
- if (mask & PAINT_WINDOW_BLEND_MASK)
- {
- if (blending)
- glEnable (GL_BLEND);
-
- if (attrib.getOpacity () != OPAQUE || attrib.getBrightness () != BRIGHT)
- {
- GLushort color;
-
- color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
-
- s->setTexEnvMode (GL_MODULATE);
- glColor4us (color, color, color, attrib.getOpacity ());
-
- w->drawGeometry ();
-
- glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
- }
- else
- {
- w->drawGeometry ();
- }
-
- if (blending)
- glDisable (GL_BLEND);
- }
- else if (attrib.getBrightness () != BRIGHT)
- {
- s->setTexEnvMode (GL_MODULATE);
- glColor4us (attrib.getBrightness (), attrib.getBrightness (),
- attrib.getBrightness (), BRIGHT);
-
- w->drawGeometry ();
-
- glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
- }
- else
- {
- w->drawGeometry ();
- }
-
- texture->disable ();
-
- fa.disable (s);
-
- return true;
-}
-
-static void
-enableFragmentOperationsAndDrawGeometry (CompWindow *w,
- CompTexture *texture,
- CompFragment::Attrib &attrib,
- CompTexture::Filter filter,
- unsigned int mask)
-{
- CompScreen *s = w->screen ();
-
- if (s->canDoSaturated () && attrib.getSaturation () != COLOR)
- {
- GLfloat constant[4];
-
- if (mask & PAINT_WINDOW_BLEND_MASK)
- glEnable (GL_BLEND);
-
- texture->enable (filter);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PRIMARY_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- glColor4f (1.0f, 1.0f, 1.0f, 0.5f);
-
- s->activeTexture (GL_TEXTURE1_ARB);
-
- texture->enable (filter);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
-
- if (s->canDoSlightlySaturated () && attrib.getSaturation () > 0)
- {
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT;
- constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT;
- constant[2] = 0.5f + 0.5f * BLUE_SATURATION_WEIGHT;
- constant[3] = 1.0;
-
- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
-
- s->activeTexture (GL_TEXTURE2_ARB);
-
- texture->enable (filter);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
-
- constant[3] = attrib.getSaturation () / 65535.0f;
-
- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
-
- if (attrib.getOpacity () < OPAQUE ||
- attrib.getBrightness () != BRIGHT)
- {
- s->activeTexture (GL_TEXTURE3_ARB);
-
- texture->enable (filter);
-
- constant[3] = attrib.getOpacity () / 65535.0f;
- constant[0] = constant[1] = constant[2] = constant[3] *
- attrib.getBrightness () / 65535.0f;
-
- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
-
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
-
- w->drawGeometry ();
-
- texture->disable ();
-
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- s->activeTexture (GL_TEXTURE2_ARB);
- }
- else
- {
- w->drawGeometry ();
- }
-
- texture->disable ();
-
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- s->activeTexture (GL_TEXTURE1_ARB);
- }
- else
- {
- glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
-
- constant[3] = attrib.getOpacity () / 65535.0f;
- constant[0] = constant[1] = constant[2] = constant[3] *
- attrib.getBrightness ()/ 65535.0f;
-
- constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
- constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
- constant[2] = 0.5f + 0.5f * BLUE_SATURATION_WEIGHT * constant[2];
-
- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
-
- w->drawGeometry ();
- }
-
- texture->disable ();
-
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- s->activeTexture (GL_TEXTURE0_ARB);
-
- texture->disable ();
-
- glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
-
- if (mask & PAINT_WINDOW_BLEND_MASK)
- glDisable (GL_BLEND);
- }
- else
- {
- texture->enable (filter);
-
- if (mask & PAINT_WINDOW_BLEND_MASK)
- {
- glEnable (GL_BLEND);
- if (attrib.getOpacity ()!= OPAQUE ||
- attrib.getBrightness () != BRIGHT)
- {
- GLushort color;
-
- color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
-
- s->setTexEnvMode (GL_MODULATE);
- glColor4us (color, color, color, attrib.getOpacity ());
-
- w->drawGeometry ();
-
- glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
- }
- else
- {
- w->drawGeometry ();
- }
-
- glDisable (GL_BLEND);
- }
- else if (attrib.getBrightness () != BRIGHT)
- {
- s->setTexEnvMode (GL_MODULATE);
- glColor4us (attrib.getBrightness (), attrib.getBrightness (),
- attrib.getBrightness (), BRIGHT);
-
- w->drawGeometry ();
-
- glColor4usv (defaultColor);
- s->setTexEnvMode (GL_REPLACE);
- }
- else
- {
- w->drawGeometry ();
- }
-
- texture->disable ();
- }
-}
-
-void
-CompWindow::drawTexture (CompTexture *texture,
- CompFragment::Attrib &attrib,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC(drawTexture, texture, attrib, mask)
-
- CompTexture::Filter filter;
-
- if (mask & (PAINT_WINDOW_TRANSFORMED_MASK |
- PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK))
- filter = priv->screen->filter (SCREEN_TRANS_FILTER);
- else
- filter = priv->screen->filter (NOTHING_TRANS_FILTER);
-
- if ((!attrib.hasFunctions () && (!priv->screen->lighting () ||
- attrib.getSaturation () == COLOR || attrib.getSaturation () == 0)) ||
- !enableFragmentProgramAndDrawGeometry (this,
- texture,
- attrib,
- filter,
- mask))
- {
- enableFragmentOperationsAndDrawGeometry (this,
- texture,
- attrib,
- filter,
- mask);
- }
-}
-
-bool
-CompWindow::draw (const CompTransform *transform,
- CompFragment::Attrib &fragment,
- Region region,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC_RETURN(bool, draw, transform, fragment, region, mask)
-
- if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
- region = &infiniteRegion;
-
- if (!region->numRects)
- return true;
-
- if (priv->attrib.map_state != IsViewable)
- return true;
-
- if (!priv->texture.hasPixmap () && !bind ())
- return false;
-
- if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- mask |= PAINT_WINDOW_BLEND_MASK;
-
- priv->vCount = priv->indexCount = 0;
- addGeometry (&priv->matrix, 1, priv->region, region);
- if (priv->vCount)
- drawTexture (&priv->texture, fragment, mask);
-
- return true;
-}
-
-bool
-CompWindow::paint (const CompWindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
-{
- WRAPABLE_HND_FUNC_RETURN(bool, paint, attrib, transform, region, mask)
-
- CompFragment::Attrib fragment (attrib);
- bool status;
-
- priv->lastPaint = *attrib;
-
- if (priv->alpha || attrib->opacity != OPAQUE)
- mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
-
- priv->lastMask = mask;
-
- if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
- {
- if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
- return false;
-
- if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
- return false;
-
- if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- return false;
-
- if (priv->shaded)
- return false;
-
- return true;
- }
-
- if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
- return true;
-
- if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
- mask & PAINT_WINDOW_WITH_OFFSET_MASK)
- {
- glPushMatrix ();
- glLoadMatrixf (transform->getMatrix ());
- }
-
- status = draw (transform, fragment, region, mask);
-
- if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
- mask & PAINT_WINDOW_WITH_OFFSET_MASK)
- glPopMatrix ();
-
- return status;
-}
diff --git a/src/privatedisplay.h b/src/privatedisplay.h
index aaf3f3c..8a852b2 100644
--- a/src/privatedisplay.h
+++ b/src/privatedisplay.h
@@ -8,71 +8,69 @@
#include <compmetadata.h>
#define COMP_DISPLAY_OPTION_ACTIVE_PLUGINS 0
-#define COMP_DISPLAY_OPTION_TEXTURE_FILTER 1
-#define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 2
-#define COMP_DISPLAY_OPTION_AUTORAISE 3
-#define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 4
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 5
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 6
-#define COMP_DISPLAY_OPTION_MAIN_MENU_KEY 7
-#define COMP_DISPLAY_OPTION_RUN_DIALOG_KEY 8
-#define COMP_DISPLAY_OPTION_COMMAND0 9
-#define COMP_DISPLAY_OPTION_COMMAND1 10
-#define COMP_DISPLAY_OPTION_COMMAND2 11
-#define COMP_DISPLAY_OPTION_COMMAND3 12
-#define COMP_DISPLAY_OPTION_COMMAND4 13
-#define COMP_DISPLAY_OPTION_COMMAND5 14
-#define COMP_DISPLAY_OPTION_COMMAND6 15
-#define COMP_DISPLAY_OPTION_COMMAND7 16
-#define COMP_DISPLAY_OPTION_COMMAND8 17
-#define COMP_DISPLAY_OPTION_COMMAND9 18
-#define COMP_DISPLAY_OPTION_COMMAND10 19
-#define COMP_DISPLAY_OPTION_COMMAND11 20
-#define COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY 21
-#define COMP_DISPLAY_OPTION_RUN_COMMAND1_KEY 22
-#define COMP_DISPLAY_OPTION_RUN_COMMAND2_KEY 23
-#define COMP_DISPLAY_OPTION_RUN_COMMAND3_KEY 24
-#define COMP_DISPLAY_OPTION_RUN_COMMAND4_KEY 25
-#define COMP_DISPLAY_OPTION_RUN_COMMAND5_KEY 26
-#define COMP_DISPLAY_OPTION_RUN_COMMAND6_KEY 27
-#define COMP_DISPLAY_OPTION_RUN_COMMAND7_KEY 28
-#define COMP_DISPLAY_OPTION_RUN_COMMAND8_KEY 29
-#define COMP_DISPLAY_OPTION_RUN_COMMAND9_KEY 30
-#define COMP_DISPLAY_OPTION_RUN_COMMAND10_KEY 31
-#define COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY 32
-#define COMP_DISPLAY_OPTION_SLOW_ANIMATIONS_KEY 33
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 34
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 35
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 36
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 37
-#define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 38
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 39
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 40
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 41
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 42
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 43
-#define COMP_DISPLAY_OPTION_SCREENSHOT 44
-#define COMP_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 45
-#define COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT 46
-#define COMP_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 47
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 48
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 49
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 50
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 51
-#define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 52
-#define COMP_DISPLAY_OPTION_AUDIBLE_BELL 53
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 54
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 55
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 56
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 57
-#define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 58
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 59
-#define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 60
-#define COMP_DISPLAY_OPTION_TERMINAL 61
-#define COMP_DISPLAY_OPTION_RUN_TERMINAL_KEY 62
-#define COMP_DISPLAY_OPTION_PING_DELAY 63
-#define COMP_DISPLAY_OPTION_EDGE_DELAY 64
-#define COMP_DISPLAY_OPTION_NUM 65
+#define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 1
+#define COMP_DISPLAY_OPTION_AUTORAISE 2
+#define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 3
+#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 4
+#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 5
+#define COMP_DISPLAY_OPTION_MAIN_MENU_KEY 6
+#define COMP_DISPLAY_OPTION_RUN_DIALOG_KEY 7
+#define COMP_DISPLAY_OPTION_COMMAND0 8
+#define COMP_DISPLAY_OPTION_COMMAND1 9
+#define COMP_DISPLAY_OPTION_COMMAND2 10
+#define COMP_DISPLAY_OPTION_COMMAND3 11
+#define COMP_DISPLAY_OPTION_COMMAND4 12
+#define COMP_DISPLAY_OPTION_COMMAND5 13
+#define COMP_DISPLAY_OPTION_COMMAND6 14
+#define COMP_DISPLAY_OPTION_COMMAND7 15
+#define COMP_DISPLAY_OPTION_COMMAND8 16
+#define COMP_DISPLAY_OPTION_COMMAND9 17
+#define COMP_DISPLAY_OPTION_COMMAND10 18
+#define COMP_DISPLAY_OPTION_COMMAND11 19
+#define COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY 20
+#define COMP_DISPLAY_OPTION_RUN_COMMAND1_KEY 21
+#define COMP_DISPLAY_OPTION_RUN_COMMAND2_KEY 22
+#define COMP_DISPLAY_OPTION_RUN_COMMAND3_KEY 23
+#define COMP_DISPLAY_OPTION_RUN_COMMAND4_KEY 24
+#define COMP_DISPLAY_OPTION_RUN_COMMAND5_KEY 25
+#define COMP_DISPLAY_OPTION_RUN_COMMAND6_KEY 26
+#define COMP_DISPLAY_OPTION_RUN_COMMAND7_KEY 27
+#define COMP_DISPLAY_OPTION_RUN_COMMAND8_KEY 28
+#define COMP_DISPLAY_OPTION_RUN_COMMAND9_KEY 29
+#define COMP_DISPLAY_OPTION_RUN_COMMAND10_KEY 30
+#define COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY 31
+#define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 32
+#define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 33
+#define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 34
+#define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 35
+#define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 36
+#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 37
+#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 38
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 39
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 40
+#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 41
+#define COMP_DISPLAY_OPTION_SCREENSHOT 42
+#define COMP_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 43
+#define COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT 44
+#define COMP_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 45
+#define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 46
+#define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 47
+#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 48
+#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 49
+#define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 50
+#define COMP_DISPLAY_OPTION_AUDIBLE_BELL 51
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 52
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 53
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 54
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 55
+#define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 56
+#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 57
+#define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 58
+#define COMP_DISPLAY_OPTION_TERMINAL 59
+#define COMP_DISPLAY_OPTION_RUN_TERMINAL_KEY 60
+#define COMP_DISPLAY_OPTION_PING_DELAY 61
+#define COMP_DISPLAY_OPTION_EDGE_DELAY 62
+#define COMP_DISPLAY_OPTION_NUM 63
extern const CompMetadata::OptionInfo
coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM];
@@ -161,10 +159,7 @@ class PrivateDisplay {
CompWatchFdHandle watchFdHandle;
- int compositeEvent, compositeError, compositeOpcode;
- int damageEvent, damageError;
int syncEvent, syncError;
- int fixesEvent, fixesError, fixesVersion;
bool randrExtension;
int randrEvent, randrError;
@@ -185,8 +180,6 @@ class PrivateDisplay {
unsigned int lastPing;
CompCore::Timer pingTimer;
- GLenum textureFilter;
-
Window activeWindow;
Window below;
diff --git a/src/privatefragment.h b/src/privatefragment.h
deleted file mode 100644
index 68c9e47..0000000
--- a/src/privatefragment.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _PRIVATEFRAGMENT_H
-#define _PRIVATEFRAGMENT_H
-
-#include <vector>
-
-#include <compfragment.h>
-
-namespace CompFragment {
-
- class Function;
- class Program;
-
- class Storage {
- public:
- Storage ();
- ~Storage ();
-
- public:
- int lastFunctionId;
- std::vector<Function *> functions;
- std::vector<Program *> programs;
-
- FunctionId saturateFunction[2][64];
- };
-};
-
-#endif
diff --git a/src/privatescreen.h b/src/privatescreen.h
index d2c1660..028af17 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -5,49 +5,25 @@
#include <compscreen.h>
#include <compsize.h>
#include <comppoint.h>
-#include <comptexture.h>
-#include <compfragment.h>
-#include "privatefragment.h"
-
-extern char *backgroundImage;
-
-extern Window currentRoot;
extern CompWindow *lastFoundWindow;
extern CompWindow *lastDamagedWindow;
-extern bool replaceCurrentWm;
-extern bool indirectRendering;
-extern bool strictBinding;
-extern bool useCow;
-extern bool noDetection;
extern bool useDesktopHints;
extern bool onlyCurrentScreen;
extern int defaultRefreshRate;
extern const char *defaultTextureFilter;
-#define RED_SATURATION_WEIGHT 0.30f
-#define GREEN_SATURATION_WEIGHT 0.59f
-#define BLUE_SATURATION_WEIGHT 0.11f
-
-#define COMP_SCREEN_OPTION_DETECT_REFRESH_RATE 0
-#define COMP_SCREEN_OPTION_LIGHTING 1
-#define COMP_SCREEN_OPTION_REFRESH_RATE 2
-#define COMP_SCREEN_OPTION_HSIZE 3
-#define COMP_SCREEN_OPTION_VSIZE 4
-#define COMP_SCREEN_OPTION_OPACITY_STEP 5
-#define COMP_SCREEN_OPTION_UNREDIRECT_FS 6
-#define COMP_SCREEN_OPTION_DEFAULT_ICON 7
-#define COMP_SCREEN_OPTION_SYNC_TO_VBLANK 8
-#define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 9
-#define COMP_SCREEN_OPTION_DETECT_OUTPUTS 10
-#define COMP_SCREEN_OPTION_OUTPUTS 11
-#define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 12
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 13
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 14
-#define COMP_SCREEN_OPTION_TEXTURE_COMPRESSION 15
-#define COMP_SCREEN_OPTION_FORCE_INDEPENDENT 16
-#define COMP_SCREEN_OPTION_NUM 17
+#define COMP_SCREEN_OPTION_HSIZE 0
+#define COMP_SCREEN_OPTION_VSIZE 1
+#define COMP_SCREEN_OPTION_DEFAULT_ICON 2
+#define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 3
+#define COMP_SCREEN_OPTION_DETECT_OUTPUTS 4
+#define COMP_SCREEN_OPTION_OUTPUTS 5
+#define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 6
+#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 7
+#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 8
+#define COMP_SCREEN_OPTION_NUM 9
#define OUTPUT_OVERLAP_MODE_SMART 0
#define OUTPUT_OVERLAP_MODE_PREFER_LARGER 1
@@ -60,10 +36,6 @@ extern const char *defaultTextureFilter;
#define FOCUS_PREVENTION_LEVEL_VERYHIGH 3
#define FOCUS_PREVENTION_LEVEL_LAST FOCUS_PREVENTION_LEVEL_VERYHIGH
-#define COMP_SCREEN_DAMAGE_PENDING_MASK (1 << 0)
-#define COMP_SCREEN_DAMAGE_REGION_MASK (1 << 1)
-#define COMP_SCREEN_DAMAGE_ALL_MASK (1 << 2)
-
extern const CompMetadata::OptionInfo
coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM];
@@ -124,9 +96,6 @@ class PrivateScreen {
void
reshape (int w, int h);
- void
- updateScreenBackground (CompTexture *texture);
-
bool
handleStartupSequenceTimeout();
@@ -146,9 +115,6 @@ class PrivateScreen {
getDesktopHints ();
void
- makeOutputWindow ();
-
- void
grabUngrabOneKey (unsigned int modifiers,
int keycode,
bool grab);
@@ -177,15 +143,7 @@ class PrivateScreen {
void
computeWorkareaForBox (BoxPtr pBox, XRectangle *area);
- void
- paintBackground (Region region,
- bool transformed);
- void
- paintOutputRegion (const CompTransform *transform,
- Region region,
- CompOutput *output,
- unsigned int mask);
public:
@@ -202,29 +160,14 @@ class PrivateScreen {
unsigned int nDesktop;
unsigned int currentDesktop;
REGION region;
- Region damage;
- unsigned long damageMask;
+
Window root;
- Window overlay;
- Window output;
+
XWindowAttributes attrib;
Window grabWindow;
- CompFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];
- int textureRectangle;
- int textureNonPowerOfTwo;
- int textureEnvCombine;
- int textureEnvCrossbar;
- int textureBorderClamp;
- int textureCompression;
- GLint maxTextureSize;
- int fbo;
- int fragmentProgram;
- int maxTextureUnits;
+
Cursor invisibleCursor;
- std::list <CompRect> exposeRects;
- CompTexture backgroundTexture;
- Bool backgroundLoaded;
- unsigned int pendingDestroys;
+
int desktopWindowCount;
unsigned int mapNum;
unsigned int activeNum;
@@ -234,31 +177,21 @@ class PrivateScreen {
CompOutput fullscreenOutput;
bool hasOverlappingOutputs;
-
- CompPoint windowPaintOffset;
-
XRectangle lastViewport;
CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
int currentHistory;
- int overlayWindowCount;
-
CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
SnMonitorContext *snContext;
std::list<CompStartupSequence *> startupSequences;
CompCore::Timer startupSequenceTimer;
- CompTexture::Filter filter[3];
-
std::list<CompGroup *> groups;
CompIcon *defaultIcon;
- Bool canDoSaturated;
- Bool canDoSlightlySaturated;
-
Window wmSnSelectionWindow;
Atom wmSnAtom;
Time wmSnTimestamp;
@@ -274,25 +207,8 @@ class PrivateScreen {
std::list<Grab *> grabs;
- CompPoint rasterPos;
- struct timeval lastRedraw;
- int nextRedraw;
- int redrawTime;
- int optimalRedrawTime;
- int frameStatus;
- int timeMult;
- Bool idle;
- int timeLeft;
- Bool pendingCommands;
-
- CompFragment::Storage fragmentStorage;
-
- GLfloat projection[16];
-
- Bool clearBuffers;
-
- Bool lighting;
- Bool slowAnimations;
+ unsigned int pendingDestroys;
+
XRectangle workArea;
@@ -301,17 +217,10 @@ class PrivateScreen {
unsigned long *desktopHintData;
int desktopHintSize;
- GLXContext ctx;
-
- CompOption::Vector opt;
-
- CompCore::Timer paintTimer;
- GLXGetProcAddressProc getProcAddress;
+ CompOption::Vector opt;
- Region tmpRegion;
- Region outputRegion;
};
#endif
diff --git a/src/privatetexture.h b/src/privatetexture.h
deleted file mode 100644
index 809925f..0000000
--- a/src/privatetexture.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _PRIVATETEXTURE_H
-#define _PRIVATETEXTURE_H
-
-#include <comptexture.h>
-
-class CompScreen;
-
-class PrivateTexture {
- public:
- PrivateTexture (CompTexture *, CompScreen *);
- ~PrivateTexture ();
-
- bool loadImageData (const char *image,
- unsigned int width,
- unsigned int height,
- GLenum format,
- GLenum type);
-
- public:
- CompScreen *screen;
- CompTexture *texture;
- GLuint name;
- GLenum target;
- GLfloat dx, dy;
- GLXPixmap pixmap;
- GLenum filter;
- GLenum wrap;
- CompTexture::Matrix matrix;
- Bool damaged;
- Bool mipmap;
- unsigned int width;
- unsigned int height;
-};
-
-#endif
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 12da68a..1111f4e 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -4,11 +4,9 @@
#include <compiz-core.h>
#include <compwindow.h>
#include <comppoint.h>
-#include <comptexture.h>
#define WINDOW_INVISIBLE(w) \
((w)->attrib.map_state != IsViewable || \
- (!(w)->damaged) || \
(w)->attrib.x + (w)->width + (w)->output.right <= 0 || \
(w)->attrib.y + (w)->height + (w)->output.bottom <= 0 || \
(w)->attrib.x - (w)->output.left >= (int) (w)->screen->size().width () || \
@@ -152,16 +150,13 @@ class PrivateWindow {
Window transientFor;
Window clientLeader;
XSizeHints sizeHints;
- Pixmap pixmap;
- CompTexture texture;
- CompTexture::Matrix matrix;
- Damage damage;
+
bool inputHint;
bool alpha;
- GLint width;
- GLint height;
+ int width;
+ int height;
Region region;
- Region clip;
+
unsigned int wmType;
unsigned int type;
unsigned int state;
@@ -171,11 +166,9 @@ class PrivateWindow {
unsigned int mwmFunc;
bool invisible;
bool destroyed;
- bool damaged;
- bool redirected;
+
bool managed;
- bool bindFailed;
- bool overlayWindow;
+
int destroyRefCnt;
int unmapRefCnt;
@@ -205,14 +198,6 @@ class PrivateWindow {
unsigned int lastPong;
bool alive;
- GLushort opacity;
- GLushort brightness;
- GLushort saturation;
-
- CompWindowPaintAttrib paint;
- CompWindowPaintAttrib lastPaint;
-
- unsigned int lastMask;
CompWindowExtents input;
CompWindowExtents output;
@@ -240,19 +225,9 @@ class PrivateWindow {
bool closeRequests;
Time lastCloseRequestTime;
- XRectangle *damageRects;
- int sizeDamage;
- int nDamage;
-
- GLfloat *vertices;
- int vertexSize;
- int vertexStride;
- GLushort *indices;
- int indexSize;
- int vCount;
- int texUnits;
- int texCoordSize;
- int indexCount;
+
+
+
};
#endif
diff --git a/src/screen.cpp b/src/screen.cpp
index 069c3a7..d37e236 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -192,7 +192,6 @@ PrivateScreen::updateOutputDevices ()
int x, y, bits;
unsigned int width, height;
int x1, y1, x2, y2;
- Region region;
char str[10];
foreach (CompOption::Value &value, list)
@@ -261,61 +260,6 @@ PrivateScreen::updateOutputDevices ()
screen->updateWorkarea ();
- screen->setDefaultViewport ();
- screen->damageScreen ();
-
- region = XCreateRegion ();
- if (region)
- {
- REGION r;
-
- r.rects = &r.extents;
- r.numRects = 1;
-
- for (unsigned int i = 0; i < outputDevs.size () - 1; i++)
- for (unsigned int j = i + 1; j < outputDevs.size (); j++)
- {
- XIntersectRegion (outputDevs[i].region (),
- outputDevs[j].region (),
- region);
- if (REGION_NOT_EMPTY (region))
- hasOverlappingOutputs = true;
- }
- XSubtractRegion (&emptyRegion, &emptyRegion, region);
-
- if (display->screenInfo ().size ())
- {
- for (unsigned int i = 0; i < display->screenInfo ().size (); i++)
- {
- r.extents.x1 = display->screenInfo ()[i].x_org;
- r.extents.y1 = display->screenInfo ()[i].y_org;
- r.extents.x2 = r.extents.x1 + display->screenInfo ()[i].width;
- r.extents.y2 = r.extents.y1 + display->screenInfo ()[i].height;
-
- XUnionRegion (region, &r, region);
- }
- }
- else
- {
- r.extents.x1 = 0;
- r.extents.y1 = 0;
- r.extents.x2 = size.width ();
- r.extents.y2 = size.height ();
-
- XUnionRegion (region, &r, region);
- }
-
- /* remove all output regions from visible screen region */
- for (unsigned int i = 0; i < outputDevs.size (); i++)
- XSubtractRegion (region, outputDevs[i].region (), region);
-
- /* we should clear color buffers before swapping if we have visible
- regions without output */
- clearBuffers = REGION_NOT_EMPTY (region);
-
- XDestroyRegion (region);
- }
-
screen->outputChangeNotify ();
}
@@ -391,15 +335,7 @@ CompScreen::setOption (const char *name,
return false;
switch (index) {
- case COMP_SCREEN_OPTION_DETECT_REFRESH_RATE:
- if (o->set (value))
- {
- if (value.b ())
- detectRefreshRate ();
- return true;
- }
- break;
case COMP_SCREEN_OPTION_DETECT_OUTPUTS:
if (o->set (value))
{
@@ -409,17 +345,6 @@ CompScreen::setOption (const char *name,
return true;
}
break;
- case COMP_SCREEN_OPTION_REFRESH_RATE:
- if (priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().b ())
- return false;
-
- if (o->set (value))
- {
- priv->redrawTime = 1000 / o->value ().i ();
- priv->optimalRedrawTime = priv->redrawTime;
- return true;
- }
- break;
case COMP_SCREEN_OPTION_HSIZE:
if (o->set (value))
{
@@ -476,13 +401,6 @@ CompScreen::setOption (const char *name,
return true;
}
break;
- case COMP_SCREEN_OPTION_FORCE_INDEPENDENT:
- if (o->set (value))
- {
- priv->updateOutputDevices ();
- return true;
- }
- break;
default:
if (CompOption::setScreenOption (this, *o, value))
return true;
@@ -493,15 +411,9 @@ CompScreen::setOption (const char *name,
}
const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
- { "detect_refresh_rate", "bool", 0, 0, 0 },
- { "lighting", "bool", 0, 0, 0 },
- { "refresh_rate", "int", "<min>1</min>", 0, 0 },
{ "hsize", "int", "<min>1</min><max>32</max>", 0, 0 },
{ "vsize", "int", "<min>1</min><max>32</max>", 0, 0 },
- { "opacity_step", "int", "<min>1</min>", 0, 0 },
- { "unredirect_fullscreen_windows", "bool", 0, 0, 0 },
{ "default_icon", "string", 0, 0, 0 },
- { "sync_to_vblank", "bool", 0, 0, 0 },
{ "number_of_desktops", "int", "<min>1</min>", 0, 0 },
{ "detect_outputs", "bool", 0, 0, 0 },
{ "outputs", "list", "<type>string</type>", 0, 0 },
@@ -510,8 +422,6 @@ const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
{ "focus_prevention_level", "int",
RESTOSTRING (0, FOCUS_PREVENTION_LEVEL_LAST), 0, 0 },
{ "focus_prevention_match", "match", 0, 0, 0 },
- { "texture_compression", "bool", 0, 0, 0 },
- { "force_independent_output_painting", "bool", 0, 0, 0 }
};
void
@@ -656,49 +566,6 @@ PrivateScreen::updateScreenEdges ()
}
}
-static void
-frustum (GLfloat *m,
- GLfloat left,
- GLfloat right,
- GLfloat bottom,
- GLfloat top,
- GLfloat nearval,
- GLfloat farval)
-{
- GLfloat x, y, a, b, c, d;
-
- x = (2.0 * nearval) / (right - left);
- y = (2.0 * nearval) / (top - bottom);
- a = (right + left) / (right - left);
- b = (top + bottom) / (top - bottom);
- c = -(farval + nearval) / ( farval - nearval);
- d = -(2.0 * farval * nearval) / (farval - nearval);
-
-#define M(row,col) m[col*4+row]
- M(0,0) = x; M(0,1) = 0.0f; M(0,2) = a; M(0,3) = 0.0f;
- M(1,0) = 0.0f; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0f;
- M(2,0) = 0.0f; M(2,1) = 0.0f; M(2,2) = c; M(2,3) = d;
- M(3,0) = 0.0f; M(3,1) = 0.0f; M(3,2) = -1.0f; M(3,3) = 0.0f;
-#undef M
-
-}
-
-static void
-perspective (GLfloat *m,
- GLfloat fovy,
- GLfloat aspect,
- GLfloat zNear,
- GLfloat zFar)
-{
- GLfloat xmin, xmax, ymin, ymax;
-
- ymax = zNear * tan (fovy * M_PI / 360.0);
- ymin = -ymax;
- xmin = ymin * aspect;
- xmax = ymax * aspect;
-
- frustum (m, xmin, xmax, ymin, ymax, zNear, zFar);
-}
void
CompScreen::setCurrentOutput (unsigned int outputNum)
@@ -712,31 +579,8 @@ CompScreen::setCurrentOutput (unsigned int outputNum)
void
PrivateScreen::reshape (int w, int h)
{
-
-#ifdef USE_COW
- if (useCow)
- XMoveResizeWindow (display->dpy (), overlay, 0, 0, w, h);
-#endif
-
display->updateScreenInfo();
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glMatrixMode (GL_MODELVIEW);
- glLoadIdentity ();
- glDepthRange (0, 1);
- glViewport (-1, -1, 2, 2);
- glRasterPos2f (0, 0);
-
- rasterPos = CompPoint (0, 0);
-
- perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
-
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- glMultMatrixf (projection);
- glMatrixMode (GL_MODELVIEW);
-
region.rects = &region.extents;
region.numRects = 1;
region.extents.x1 = 0;
@@ -766,158 +610,10 @@ CompScreen::configure (XConfigureEvent *ce)
priv->reshape (ce->width, ce->height);
priv->detectOutputDevices ();
-
- damageScreen ();
}
}
-FuncPtr
-CompScreen::getProcAddress (const char *name)
-{
- static void *dlhand = NULL;
- FuncPtr funcPtr = NULL;
-
- if (priv->getProcAddress)
- funcPtr = priv->getProcAddress ((GLubyte *) name);
-
- if (!funcPtr)
- {
- if (!dlhand)
- dlhand = dlopen (NULL, RTLD_LAZY);
-
- if (dlhand)
- {
- dlerror ();
- funcPtr = (FuncPtr) dlsym (dlhand, name);
- if (dlerror () != NULL)
- funcPtr = NULL;
- }
- }
- return funcPtr;
-}
-
-void
-PrivateScreen::updateScreenBackground (CompTexture *texture)
-{
- Display *dpy = display->dpy ();
- Atom pixmapAtom, actualType;
- int actualFormat, i, status;
- unsigned int width = 1, height = 1, depth = 0;
- unsigned long nItems;
- unsigned long bytesAfter;
- unsigned char *prop;
- Pixmap pixmap = 0;
-
- pixmapAtom = XInternAtom (dpy, "PIXMAP", FALSE);
-
- for (i = 0; pixmap == 0 && i < 2; i++)
- {
- status = XGetWindowProperty (dpy, root,
- display->atoms ().xBackground[i],
- 0, 4, FALSE, AnyPropertyType,
- &actualType, &actualFormat, &nItems,
- &bytesAfter, &prop);
-
- if (status == Success && nItems && prop)
- {
- if (actualType == pixmapAtom &&
- actualFormat == 32 &&
- nItems == 1)
- {
- Pixmap p;
-
- memcpy (&p, prop, 4);
-
- if (p)
- {
- unsigned int ui;
- int i;
- Window w;
-
- if (XGetGeometry (dpy, p, &w, &i, &i,
- &width, &height, &ui, &depth))
- {
- if ((int) depth == attrib.depth)
- pixmap = p;
- }
- }
- }
-
- XFree (prop);
- }
- }
-
- if (pixmap)
- {
-/* FIXME:
- if (pixmap == texture->pixmap)
- return;
-*/
- texture->reset ();
-
- if (!texture->bindPixmap (pixmap, width, height, depth))
- {
- compLogMessage (NULL, "core", CompLogLevelWarn,
- "Couldn't bind background pixmap 0x%x to "
- "texture", (int) pixmap);
- }
- }
- else
- {
- texture->reset ();
- }
-
- if (!texture->name () && backgroundImage)
- CompTexture::readImageToTexture (screen, texture, backgroundImage,
- &width, &height);
-
- if (texture->target () == GL_TEXTURE_2D)
- {
- glBindTexture (texture->target (), texture->name ());
- glTexParameteri (texture->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri (texture->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
- glBindTexture (texture->target (), 0);
- }
-}
-
-void
-CompScreen::detectRefreshRate ()
-{
- if (!noDetection &&
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().b ())
- {
- CompString name;
- CompOption::Value value;
-
- value.set ((int) 0);
-
- if (priv->display->XRandr())
- {
- XRRScreenConfiguration *config;
-
- config = XRRGetScreenInfo (priv->display->dpy (), priv->root);
- value.set ((int) XRRConfigCurrentRate (config));
-
- XRRFreeScreenConfigInfo (config);
- }
-
- if (value.i () == 0)
- value.set ((int) defaultRefreshRate);
-
- name = priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].name ();
-
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (false);
- core->setOptionForPlugin (this, "core", name.c_str (), value);
- priv->opt[COMP_SCREEN_OPTION_DETECT_REFRESH_RATE].value ().set (true);
- }
- else
- {
- priv->redrawTime = 1000 /
- priv->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value ().i ();
- priv->optimalRedrawTime = priv->redrawTime;
- }
-}
void
PrivateScreen::setSupportingWmCheck ()
@@ -1003,11 +699,14 @@ PrivateScreen::setSupported ()
data[i++] = display->atoms ().winOpacity;
data[i++] = display->atoms ().winBrightness;
+#warning fixme
+#if 0
if (canDoSaturated)
{
data[i++] = display->atoms ().winSaturation;
data[i++] = display->atoms ().winStateDisplayModal;
}
+#endif
data[i++] = display->atoms ().wmAllowedActions;
@@ -1131,123 +830,6 @@ PrivateScreen::getDesktopHints ()
}
void
-CompScreen::showOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeBounding,
- 0, 0, 0);
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeInput,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
-
- damageScreen ();
- }
-#endif
-
-}
-
-void
-CompScreen::hideOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeBounding,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
- }
-#endif
-
-}
-
-void
-CompScreen::updateOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- Display *dpy = priv->display->dpy ();
- XserverRegion region;
- static Region tmpRegion = NULL;
-
- if (!tmpRegion)
- {
- tmpRegion = XCreateRegion ();
- if (!tmpRegion)
- return;
- }
-
- XSubtractRegion (&priv->region, &emptyRegion, tmpRegion);
-
-
- for (CompWindowList::reverse_iterator rit = priv->windows.rbegin ();
- rit != priv->windows.rend (); rit++)
- if ((*rit)->overlayWindow ())
- {
- XSubtractRegion (tmpRegion, (*rit)->region (), tmpRegion);
- }
-
- XShapeCombineRegion (dpy, priv->output, ShapeBounding,
- 0, 0, tmpRegion, ShapeSet);
-
-
- region = XFixesCreateRegion (dpy, NULL, 0);
-
- XFixesSetWindowShapeRegion (dpy,
- priv->output,
- ShapeInput,
- 0, 0, region);
-
- XFixesDestroyRegion (dpy, region);
- }
-#endif
-
-}
-
-void
-PrivateScreen::makeOutputWindow ()
-{
-
-#ifdef USE_COW
- if (useCow)
- {
- overlay = XCompositeGetOverlayWindow (display->dpy (), root);
- output = overlay;
-
- XSelectInput (display->dpy (), output, ExposureMask);
- }
- else
-#endif
-
- output = overlay = root;
-
- screen->showOutputWindow ();
-}
-
-void
CompScreen::enterShowDesktopMode ()
{
WRAPABLE_HND_FUNC(enterShowDesktopMode)
@@ -1336,33 +918,16 @@ CompScreen::leaveShowDesktopMode (CompWindow *window)
(unsigned char *) &data, 1);
}
-CompWindowList
-CompScreen::getWindow