|
Line 0
Source/WebCore/platform/graphics/surfaces/TextureBlitter.cpp_sec1
|
|
|
1 |
/* |
| 2 |
* Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions |
| 6 |
* are met: |
| 7 |
* 1. Redistributions of source code must retain the above copyright |
| 8 |
* notice, this list of conditions and the following disclaimer. |
| 9 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer in the |
| 11 |
* documentation and/or other materials provided with the distribution. |
| 12 |
* |
| 13 |
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 |
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 |
* THE POSSIBILITY OF SUCH DAMAGE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "config.h" |
| 27 |
#include "TextureBlitter.h" |
| 28 |
|
| 29 |
#if USE(ACCELERATED_COMPOSITING) |
| 30 |
|
| 31 |
#include "TextureMapperGL.h" |
| 32 |
|
| 33 |
#include <opengl/GLPlatformContext.h> |
| 34 |
#include <wtf/text/WTFString.h> |
| 35 |
|
| 36 |
namespace WebCore { |
| 37 |
|
| 38 |
//#define SHADER_DEBUG |
| 39 |
TextureBlitter* TextureBlitter::m_staticTextureBlitter = 0; |
| 40 |
static const GLfloat vertices[] = { -1.0f, -1.0f, 0.0f, 1.0f, |
| 41 |
-1.0f, 1.0f, 0.0f, 1.0f, |
| 42 |
1.0f, 1.0f, 0.0f, 1.0f, |
| 43 |
1.0f, -1.0f, 0.0f, 1.0f, |
| 44 |
0.0f, 0.0f,0.0f, 1.0f, // Tex coordinates. |
| 45 |
1.0f, 1.0f,1.0f, 0.0f}; |
| 46 |
|
| 47 |
static const int TEXCOORDOFFSET = sizeof(float) * 4 * 4; |
| 48 |
|
| 49 |
#if USE(OPENGL_ES_2) |
| 50 |
static PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArray = 0; |
| 51 |
static PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArrays = 0; |
| 52 |
static PFNGLGENVERTEXARRAYSOESPROC m_glGenVertexArrays = 0; |
| 53 |
static PFNGLISVERTEXARRAYOESPROC m_glIsVertexArray = 0; |
| 54 |
#else |
| 55 |
static PFNGLBINDVERTEXARRAYPROC m_glBindVertexArray = 0; |
| 56 |
static PFNGLDELETEVERTEXARRAYSPROC m_glDeleteVertexArrays = 0; |
| 57 |
static PFNGLGENVERTEXARRAYSPROC m_glGenVertexArrays = 0; |
| 58 |
#endif |
| 59 |
|
| 60 |
#if USE(OPENGL_ES_2) |
| 61 |
static void initializeGLBindings() |
| 62 |
{ |
| 63 |
static bool bindingsInitialized = false; |
| 64 |
if (bindingsInitialized) |
| 65 |
return; |
| 66 |
|
| 67 |
bindingsInitialized = true; |
| 68 |
|
| 69 |
if (GLPlatformContext::supportsGLExtension("GL_OES_vertex_array_object")) { |
| 70 |
m_glBindVertexArray = reinterpret_cast<PFNGLBINDVERTEXARRAYOESPROC>(eglGetProcAddress("glBindVertexArrayOES")); |
| 71 |
m_glGenVertexArrays = reinterpret_cast<PFNGLGENVERTEXARRAYSOESPROC>(eglGetProcAddress("glGenVertexArraysOES")); |
| 72 |
m_glDeleteVertexArrays = reinterpret_cast<PFNGLDELETEVERTEXARRAYSOESPROC>(eglGetProcAddress("glDeleteVertexArraysOES")); |
| 73 |
m_glIsVertexArray = reinterpret_cast<PFNGLISVERTEXARRAYOESPROC>(eglGetProcAddress("glIsVertexArrayOES")); |
| 74 |
} |
| 75 |
} |
| 76 |
#endif |
| 77 |
|
| 78 |
class ScopedToggleGLState |
| 79 |
{ |
| 80 |
WTF_MAKE_NONCOPYABLE(ScopedToggleGLState); |
| 81 |
|
| 82 |
public: |
| 83 |
ScopedToggleGLState() |
| 84 |
{ |
| 85 |
m_enableBlend = toggleState(GL_BLEND); |
| 86 |
m_enableCullFace = toggleState(GL_CULL_FACE); |
| 87 |
m_enableDepthTest = toggleState(GL_DEPTH_TEST); |
| 88 |
m_enableDitherTest = toggleState(GL_DITHER); |
| 89 |
m_enablePolygonOffsetFill = toggleState(GL_POLYGON_OFFSET_FILL); |
| 90 |
m_enableSampleAlpha = toggleState(GL_SAMPLE_ALPHA_TO_COVERAGE); |
| 91 |
m_enableSampleCoverage = toggleState(GL_SAMPLE_COVERAGE); |
| 92 |
m_enableStencilTest = toggleState(GL_STENCIL_TEST); |
| 93 |
} |
| 94 |
|
| 95 |
~ScopedToggleGLState() |
| 96 |
{ |
| 97 |
if (m_enableBlend) |
| 98 |
::glEnable(GL_BLEND); |
| 99 |
|
| 100 |
if (m_enableCullFace) |
| 101 |
::glEnable(GL_CULL_FACE); |
| 102 |
|
| 103 |
if (m_enableDepthTest) |
| 104 |
::glEnable(GL_DEPTH_TEST); |
| 105 |
|
| 106 |
if (m_enableDitherTest) |
| 107 |
::glEnable(GL_DITHER); |
| 108 |
|
| 109 |
if (m_enablePolygonOffsetFill) |
| 110 |
::glEnable(GL_POLYGON_OFFSET_FILL); |
| 111 |
|
| 112 |
if (m_enableSampleAlpha) |
| 113 |
::glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); |
| 114 |
|
| 115 |
if (m_enableSampleCoverage) |
| 116 |
::glEnable(GL_SAMPLE_COVERAGE); |
| 117 |
|
| 118 |
if (m_enableStencilTest) |
| 119 |
::glEnable(GL_STENCIL_TEST); |
| 120 |
} |
| 121 |
|
| 122 |
private: |
| 123 |
bool toggleState(const GLenum capability) |
| 124 |
{ |
| 125 |
bool enabled = ::glIsEnabled(capability); |
| 126 |
|
| 127 |
if (!enabled) |
| 128 |
return false; |
| 129 |
|
| 130 |
::glDisable(capability); |
| 131 |
|
| 132 |
return true; |
| 133 |
} |
| 134 |
|
| 135 |
bool m_enableBlend :1; |
| 136 |
bool m_enableCullFace :1; |
| 137 |
bool m_enableDepthTest :1; |
| 138 |
bool m_enableDitherTest :1; |
| 139 |
bool m_enablePolygonOffsetFill :1; |
| 140 |
bool m_enableSampleAlpha :1; |
| 141 |
bool m_enableSampleCoverage :1; |
| 142 |
bool m_enableStencilTest :1; |
| 143 |
}; |
| 144 |
|
| 145 |
class ScopedStateSaver |
| 146 |
{ |
| 147 |
WTF_MAKE_NONCOPYABLE(ScopedStateSaver); |
| 148 |
|
| 149 |
public: |
| 150 |
ScopedStateSaver() |
| 151 |
{ |
| 152 |
::glGetIntegerv(GL_ACTIVE_TEXTURE, &m_boundTexUnit); |
| 153 |
::glGetIntegerv(GL_CURRENT_PROGRAM, &m_boundProgram); |
| 154 |
::glGetIntegerv(GL_VIEWPORT, &m_currentViewport[0]); |
| 155 |
|
| 156 |
if (m_glGenVertexArrays) |
| 157 |
#if USE(OPENGL_ES_2) |
| 158 |
::glGetIntegerv(GL_VERTEX_ARRAY_BINDING_OES, &m_currentVertexArrayBinding); |
| 159 |
#else |
| 160 |
::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &m_currentVertexArrayBinding); |
| 161 |
#endif |
| 162 |
else { |
| 163 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &m_attribEnabled); |
| 164 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_SIZE, &m_attribSize); |
| 165 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &m_attribStride); |
| 166 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_TYPE, &m_attribType); |
| 167 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &m_attribNormalized); |
| 168 |
::glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &m_attribBufferBinding); |
| 169 |
::glGetVertexAttribPointerv(0, GL_VERTEX_ATTRIB_ARRAY_POINTER, &m_attribPointer); |
| 170 |
::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &m_currentArrayBufferBinding); |
| 171 |
} |
| 172 |
|
| 173 |
::glActiveTexture(GL_TEXTURE0); |
| 174 |
} |
| 175 |
|
| 176 |
~ScopedStateSaver() |
| 177 |
{ |
| 178 |
if (m_boundProgram && !glIsProgram(m_boundProgram)) |
| 179 |
m_boundProgram = 0; |
| 180 |
|
| 181 |
if (m_glGenVertexArrays) |
| 182 |
m_glBindVertexArray(m_currentVertexArrayBinding); |
| 183 |
else { |
| 184 |
if (m_attribEnabled) |
| 185 |
::glEnableVertexAttribArray(0); |
| 186 |
|
| 187 |
::glBindBuffer(GL_ARRAY_BUFFER, m_attribBufferBinding); |
| 188 |
::glVertexAttribPointer(0, m_attribSize, m_attribType, m_attribNormalized, m_attribStride, m_attribPointer); |
| 189 |
::glBindBuffer(GL_ARRAY_BUFFER, m_currentArrayBufferBinding); |
| 190 |
} |
| 191 |
|
| 192 |
::glUseProgram(m_boundProgram); |
| 193 |
::glViewport(m_currentViewport[0], m_currentViewport[1], m_currentViewport[2], m_currentViewport[3]); |
| 194 |
::glActiveTexture(m_boundTexUnit); |
| 195 |
} |
| 196 |
|
| 197 |
private: |
| 198 |
GLint m_boundTexUnit; |
| 199 |
GLint m_boundProgram; |
| 200 |
GLint m_currentArrayBufferBinding; |
| 201 |
GLint m_attribEnabled; |
| 202 |
GLint m_attribSize; |
| 203 |
GLint m_attribStride; |
| 204 |
GLint m_attribType; |
| 205 |
GLint m_attribNormalized; |
| 206 |
GLint m_attribBufferBinding; |
| 207 |
GLint m_currentViewport[4]; |
| 208 |
GLint m_currentVertexArrayBinding; |
| 209 |
ScopedToggleGLState m_scopedToggleState; |
| 210 |
void* m_attribPointer; |
| 211 |
}; |
| 212 |
|
| 213 |
#define STRINGIFY(...) #__VA_ARGS__ |
| 214 |
|
| 215 |
const char* GetShaderSource(GLenum type) { |
| 216 |
switch (type) { |
| 217 |
case GL_VERTEX_SHADER: |
| 218 |
return STRINGIFY( |
| 219 |
attribute vec4 m_vPosition; |
| 220 |
attribute vec2 m_texCoord; |
| 221 |
varying vec2 m_vTexCoord; |
| 222 |
void main(void) { |
| 223 |
gl_Position = m_vPosition; |
| 224 |
m_vTexCoord = m_texCoord; |
| 225 |
}); |
| 226 |
case GL_FRAGMENT_SHADER: |
| 227 |
return STRINGIFY( |
| 228 |
uniform sampler2D u_texSampler; |
| 229 |
varying vec2 m_vTexCoord; |
| 230 |
void main(void) { |
| 231 |
gl_FragColor = texture2D(u_texSampler, m_vTexCoord.st); |
| 232 |
}); |
| 233 |
default: |
| 234 |
return 0; |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
TextureBlitter::TextureBlitter() |
| 239 |
: m_vertexHandle(0) |
| 240 |
, m_currentVertexHandle(0) |
| 241 |
, m_shaderProgram(0) |
| 242 |
, m_vertexBuffer(0) |
| 243 |
, m_fboId(0) |
| 244 |
{ |
| 245 |
} |
| 246 |
|
| 247 |
TextureBlitter::~TextureBlitter() |
| 248 |
{ |
| 249 |
clear(); |
| 250 |
} |
| 251 |
|
| 252 |
void TextureBlitter::clear() |
| 253 |
{ |
| 254 |
if (m_shaderProgram) { |
| 255 |
::glDeleteProgram(m_shaderProgram); |
| 256 |
m_shaderProgram = 0; |
| 257 |
} |
| 258 |
|
| 259 |
if (m_fboId) { |
| 260 |
::glDeleteFramebuffers(1, &m_fboId); |
| 261 |
m_fboId = 0; |
| 262 |
} |
| 263 |
|
| 264 |
if (m_vertexHandle && m_glDeleteVertexArrays) { |
| 265 |
m_glDeleteVertexArrays(1, &m_vertexHandle); |
| 266 |
m_vertexHandle = 0; |
| 267 |
} |
| 268 |
|
| 269 |
if (m_vertexBuffer) { |
| 270 |
::glDeleteBuffers(1, &m_vertexBuffer); |
| 271 |
m_vertexBuffer = 0; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
GLuint TextureBlitter::loadShader(GLenum type, const GLchar *shaderSrc) |
| 276 |
{ |
| 277 |
GLuint shader; |
| 278 |
GLint compiled; |
| 279 |
|
| 280 |
shader = ::glCreateShader(type); |
| 281 |
|
| 282 |
if (!shader) { |
| 283 |
LOG_ERROR("Failed to create shader."); |
| 284 |
return 0; |
| 285 |
} |
| 286 |
|
| 287 |
::glShaderSource(shader, 1, &shaderSrc, 0); |
| 288 |
::glCompileShader(shader); |
| 289 |
::glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); |
| 290 |
|
| 291 |
if (!compiled) { |
| 292 |
::glDeleteShader(shader); |
| 293 |
LOG_ERROR("Failed to compile shader."); |
| 294 |
return 0; |
| 295 |
} |
| 296 |
|
| 297 |
return shader; |
| 298 |
} |
| 299 |
|
| 300 |
void TextureBlitter::bindArrayBuffer() |
| 301 |
{ |
| 302 |
::glEnableVertexAttribArray(m_vertexAttr); |
| 303 |
::glEnableVertexAttribArray(m_textureCoordinatesAttr); |
| 304 |
::glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); |
| 305 |
::glVertexAttribPointer(m_vertexAttr, 4, GL_FLOAT, GL_FALSE, 0, (void*)NULL); |
| 306 |
::glVertexAttribPointer(m_textureCoordinatesAttr, 2, GL_FLOAT, GL_FALSE, 0, (void*)TEXCOORDOFFSET); |
| 307 |
} |
| 308 |
|
| 309 |
void TextureBlitter::enableVertexArray() |
| 310 |
{ |
| 311 |
if (m_currentVertexHandle) |
| 312 |
m_glBindVertexArray(m_currentVertexHandle); |
| 313 |
else |
| 314 |
bindArrayBuffer(); |
| 315 |
} |
| 316 |
|
| 317 |
void TextureBlitter::disableVertexArray() |
| 318 |
{ |
| 319 |
if (m_currentVertexHandle) |
| 320 |
return; |
| 321 |
|
| 322 |
::glDisableVertexAttribArray(m_vertexAttr); |
| 323 |
::glDisableVertexAttribArray(m_textureCoordinatesAttr); |
| 324 |
} |
| 325 |
|
| 326 |
bool TextureBlitter::linkProgram(const GLuint programId) |
| 327 |
{ |
| 328 |
::glLinkProgram(programId); |
| 329 |
GLint linkStatus = 0; |
| 330 |
::glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus); |
| 331 |
|
| 332 |
if (!linkStatus) |
| 333 |
return false; |
| 334 |
|
| 335 |
return true; |
| 336 |
} |
| 337 |
|
| 338 |
void TextureBlitter::initializeVBO() |
| 339 |
{ |
| 340 |
if (m_glGenVertexArrays) { |
| 341 |
m_currentVertexHandle = m_vertexHandle; |
| 342 |
|
| 343 |
if (m_currentVertexHandle) |
| 344 |
return; |
| 345 |
} else if (m_vertexBuffer) |
| 346 |
return; |
| 347 |
|
| 348 |
// bind buffers. |
| 349 |
::glGenBuffers(1, &m_vertexBuffer); |
| 350 |
::glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); |
| 351 |
::glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
| 352 |
|
| 353 |
// Create and set-up the vertex array object |
| 354 |
if (m_glGenVertexArrays && m_glBindVertexArray) { |
| 355 |
GLuint vertexHandle; |
| 356 |
m_glGenVertexArrays(1, &vertexHandle); |
| 357 |
m_glBindVertexArray(vertexHandle); |
| 358 |
bindArrayBuffer(); |
| 359 |
m_vertexHandle = vertexHandle; |
| 360 |
m_currentVertexHandle = vertexHandle; |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
bool TextureBlitter::initializeProgram() |
| 365 |
{ |
| 366 |
if (m_shaderProgram) |
| 367 |
return true; |
| 368 |
|
| 369 |
// create shader. |
| 370 |
GLuint vertexShader = loadShader(GL_VERTEX_SHADER, GetShaderSource(GL_VERTEX_SHADER)); |
| 371 |
if (!vertexShader) |
| 372 |
return false; |
| 373 |
|
| 374 |
GLuint fragmentShader = loadShader(GL_FRAGMENT_SHADER, GetShaderSource(GL_FRAGMENT_SHADER)); |
| 375 |
|
| 376 |
if (!fragmentShader) { |
| 377 |
::glDeleteShader(vertexShader); |
| 378 |
return false; |
| 379 |
} |
| 380 |
|
| 381 |
m_shaderProgram = glCreateProgram(); |
| 382 |
|
| 383 |
if (!m_shaderProgram || (m_shaderProgram && !glIsProgram(m_shaderProgram))) { |
| 384 |
LOG_ERROR("Failed to create program."); |
| 385 |
::glDeleteShader(vertexShader); |
| 386 |
::glDeleteShader(fragmentShader); |
| 387 |
return false; |
| 388 |
} |
| 389 |
|
| 390 |
::glAttachShader(m_shaderProgram, vertexShader); |
| 391 |
::glAttachShader(m_shaderProgram, fragmentShader); |
| 392 |
bool linked = linkProgram(m_shaderProgram); |
| 393 |
::glDeleteShader(vertexShader); |
| 394 |
::glDeleteShader(fragmentShader); |
| 395 |
|
| 396 |
if (!linked) { |
| 397 |
clear(); |
| 398 |
return false; |
| 399 |
} |
| 400 |
|
| 401 |
GLint currentProgram; |
| 402 |
::glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); |
| 403 |
unsigned samplerLocation = glGetUniformLocation(m_shaderProgram, "u_texSampler"); |
| 404 |
m_vertexAttr = ::glGetAttribLocation(m_shaderProgram, "m_vPosition"); |
| 405 |
m_textureCoordinatesAttr = ::glGetAttribLocation(m_shaderProgram, "m_texCoord"); |
| 406 |
::glUseProgram(m_shaderProgram); |
| 407 |
::glUniform1i(samplerLocation, 0); |
| 408 |
|
| 409 |
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 410 |
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 411 |
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 412 |
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 413 |
|
| 414 |
::glUseProgram(currentProgram); |
| 415 |
|
| 416 |
return true; |
| 417 |
} |
| 418 |
|
| 419 |
#if USE(OPENGL_ES_2) |
| 420 |
bool TextureBlitter::drawTexture(const GLuint sourceTexture, const GLuint targetFboId, const IntRect&, const IntRect& destRect, GLenum) |
| 421 |
{ |
| 422 |
initializeGLBindings(); |
| 423 |
|
| 424 |
if (!initializeProgram()) |
| 425 |
return false; |
| 426 |
|
| 427 |
ScopedStateSaver stateSaver; |
| 428 |
|
| 429 |
::glViewport (destRect.x(), destRect.y(), destRect.width(), destRect.height()); |
| 430 |
::glBindFramebuffer(GL_FRAMEBUFFER, targetFboId); |
| 431 |
::glClear(GL_COLOR_BUFFER_BIT); |
| 432 |
::glUseProgram(m_shaderProgram); |
| 433 |
::glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 434 |
::glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 435 |
::glColorMask(true, true, true, true); |
| 436 |
initializeVBO(); |
| 437 |
enableVertexArray(); |
| 438 |
::glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 439 |
::glFlush(); |
| 440 |
disableVertexArray(); |
| 441 |
|
| 442 |
return true; |
| 443 |
} |
| 444 |
#else |
| 445 |
bool TextureBlitter::drawTexture(const GLuint sourceTexture, const GLuint targetFboId, const IntRect& srcRect, const IntRect& destRect, GLenum filter) |
| 446 |
{ |
| 447 |
if (!m_fboId) |
| 448 |
glGenFramebuffers(1, &m_fboId); |
| 449 |
|
| 450 |
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId); |
| 451 |
glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 452 |
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0); |
| 453 |
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFboId); |
| 454 |
glBlitFramebuffer(srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), destRect.x(), destRect.y(), destRect.width(), destRect.height(), GL_COLOR_BUFFER_BIT, filter); |
| 455 |
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
| 456 |
|
| 457 |
return true; |
| 458 |
} |
| 459 |
#endif |
| 460 |
|
| 461 |
} |
| 462 |
|
| 463 |
#endif |
| 464 |
|