~linaro-graphics-wg/compiz-plugins-main/oneiric-gles2

« back to all changes in this revision

Viewing changes to scaleaddon/src/scaleaddon.cpp

  • Committer: Travis Watkins
  • Date: 2011-10-20 08:48:04 UTC
  • Revision ID: travis.watkins@linaro.org-20111020084804-116tyyy0dqt7k1zd
add code from GLES2 port

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
}
92
92
 
93
93
void
94
 
ScaleAddonWindow::drawTitle ()
 
94
ScaleAddonWindow::drawTitle (const GLMatrix &transform)
95
95
{
96
96
    float         x, y, width, height;
97
97
    ScalePosition pos = sWindow->getCurrentPosition ();
103
103
    x = pos.x () + window->x () + geom.width () * pos.scale / 2 - width / 2;
104
104
    y = pos.y () + window->y () + geom.height () * pos.scale / 2 - height / 2;
105
105
 
106
 
    text.draw (floor (x), floor (y), 1.0f);
 
106
    text.draw (transform, floor (x), floor (y), 1.0f);
107
107
}
108
108
 
109
109
void
110
 
ScaleAddonWindow::drawHighlight ()
 
110
ScaleAddonWindow::drawHighlight (const GLMatrix &transform)
111
111
{
112
 
    GLboolean     wasBlend;
113
 
    GLint         oldBlendSrc, oldBlendDst;
 
112
    GLint oldBlendSrc, oldBlendDst, oldBlendSrcAlpha, oldBlendDstAlpha;
 
113
    GLushort colorData[4];
 
114
    GLfloat  vertexData[12];
 
115
    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
114
116
    float         x, y, width, height;
115
117
    ScalePosition pos = sWindow->getCurrentPosition ();
116
118
    CompRect      geom = window->borderRect ();
130
132
    x = floor (x + 0.5f);
131
133
    y = floor (y + 0.5f);
132
134
 
133
 
    wasBlend = glIsEnabled (GL_BLEND);
 
135
#ifdef USE_GLES
 
136
    glGetIntegerv (GL_BLEND_SRC_RGB, &oldBlendSrc);
 
137
    glGetIntegerv (GL_BLEND_DST_RGB, &oldBlendDst);
 
138
    glGetIntegerv (GL_BLEND_SRC_ALPHA, &oldBlendSrcAlpha);
 
139
    glGetIntegerv (GL_BLEND_DST_ALPHA, &oldBlendDstAlpha);
 
140
#else
134
141
    glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
135
142
    glGetIntegerv (GL_BLEND_DST, &oldBlendDst);
136
 
 
137
 
    if (!wasBlend)
138
 
        glEnable (GL_BLEND);
 
143
#endif
139
144
 
140
145
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
141
146
 
142
 
    glColor4us (as->optionGetHighlightColorRed (),
143
 
                as->optionGetHighlightColorGreen (),
144
 
                as->optionGetHighlightColorBlue (),
145
 
                as->optionGetHighlightColorAlpha ());
146
 
 
147
 
    glRectf (x, y + height, x + width, y);
148
 
 
149
 
    glColor4usv (defaultColor);
150
 
 
151
 
    if (!wasBlend)
152
 
        glDisable (GL_BLEND);
 
147
    streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
148
 
 
149
    colorData[0] = as->optionGetHighlightColorRed ();
 
150
    colorData[1] = as->optionGetHighlightColorGreen ();
 
151
    colorData[2] = as->optionGetHighlightColorBlue ();
 
152
    colorData[3] = as->optionGetHighlightColorAlpha ();
 
153
 
 
154
    streamingBuffer->addColors (1, colorData);
 
155
 
 
156
    vertexData[0]  = x;
 
157
    vertexData[1]  = y;
 
158
    vertexData[2]  = 0.0f;
 
159
    vertexData[3]  = x;
 
160
    vertexData[4]  = y + height;
 
161
    vertexData[5]  = 0.0f;
 
162
    vertexData[6]  = x + width;
 
163
    vertexData[7]  = y;
 
164
    vertexData[8]  = 0.0f;
 
165
    vertexData[9]  = x + width;
 
166
    vertexData[10] = y + height;
 
167
    vertexData[11] = 0.0f;
 
168
 
 
169
    streamingBuffer->addVertices (4, vertexData);
 
170
 
 
171
    streamingBuffer->end ();
 
172
    streamingBuffer->render (transform);
 
173
 
 
174
#ifdef USE_GLES
 
175
    glBlendFuncSeparate (oldBlendSrc, oldBlendDst,
 
176
                         oldBlendSrcAlpha, oldBlendDstAlpha);
 
177
#else
153
178
    glBlendFunc (oldBlendSrc, oldBlendDst);
 
179
#endif
154
180
}
155
181
 
156
182
void
415
441
        if (as->optionGetWindowHighlight ())
416
442
        {
417
443
            if (window->id () == as->highlightedWindow)
418
 
                drawHighlight ();
 
444
                drawHighlight (transform);
419
445
        }
420
446
 
421
447
        if (textAvailable)
422
 
            drawTitle ();
 
448
            drawTitle (transform);
423
449
    }
424
450
}
425
451