Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "gpu/command_buffer/service/gl_utils.h" | 10 #include "gpu/command_buffer/service/gl_utils.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 return shader_ids[index][SAMPLER_2D]; | 160 return shader_ids[index][SAMPLER_2D]; |
| 161 case GL_TEXTURE_RECTANGLE_ARB: | 161 case GL_TEXTURE_RECTANGLE_ARB: |
| 162 return shader_ids[index][SAMPLER_RECTANGLE_ARB]; | 162 return shader_ids[index][SAMPLER_RECTANGLE_ARB]; |
| 163 case GL_TEXTURE_EXTERNAL_OES: | 163 case GL_TEXTURE_EXTERNAL_OES: |
| 164 return shader_ids[index][SAMPLER_EXTERNAL_OES]; | 164 return shader_ids[index][SAMPLER_EXTERNAL_OES]; |
| 165 default: | 165 default: |
| 166 break; | 166 break; |
| 167 } | 167 } |
| 168 | 168 |
| 169 NOTREACHED(); | 169 NOTREACHED(); |
| 170 return shader_ids[index][SAMPLER_2D]; | 170 return shader_ids[0][SAMPLER_2D]; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void CompileShader(GLuint shader, const char* shader_source) { | 173 void CompileShader(GLuint shader, const char* shader_source) { |
| 174 glShaderSource(shader, 1, &shader_source, 0); | 174 glShaderSource(shader, 1, &shader_source, 0); |
| 175 glCompileShader(shader); | 175 glCompileShader(shader); |
| 176 #ifndef NDEBUG | 176 #ifndef NDEBUG |
| 177 GLint compile_status; | 177 GLint compile_status; |
| 178 glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); | 178 glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); |
| 179 if (GL_TRUE != compile_status) | 179 if (GL_TRUE != compile_status) |
| 180 DLOG(ERROR) << "CopyTextureCHROMIUM: shader compilation failure."; | 180 DLOG(ERROR) << "CopyTextureCHROMIUM: shader compilation failure."; |
| 181 #endif | 181 #endif |
| 182 } | 182 } |
| 183 | 183 |
| 184 void DeleteShader(GLuint shader) { | 184 void DeleteShader(GLuint shader) { |
| 185 if (shader) | 185 if (shader) |
| 186 glDeleteShader(shader); | 186 glDeleteShader(shader); |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool BindFramebufferTexture2D(GLenum target, | |
| 190 GLuint texture_id, | |
| 191 GLint level, | |
| 192 GLuint framebuffer) { | |
| 193 DCHECK(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE_ARB); | |
| 194 glActiveTexture(GL_TEXTURE0); | |
| 195 glBindTexture(target, texture_id); | |
| 196 // NVidia drivers require texture settings to be a certain way | |
| 197 // or they won't report FRAMEBUFFER_COMPLETE. | |
| 198 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 199 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 200 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 201 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 202 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer); | |
| 203 glFramebufferTexture2DEXT( | |
| 204 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, texture_id, level); | |
| 205 | |
| 206 #ifndef NDEBUG | |
| 207 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
| 208 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { | |
| 209 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; | |
| 210 return false; | |
| 211 } | |
| 212 #endif | |
| 213 return true; | |
| 214 } | |
| 215 | |
| 216 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder, | |
| 217 GLenum source_target, | |
| 218 GLuint source_id, | |
| 219 GLuint dest_id, | |
| 220 GLint dest_level, | |
| 221 GLenum dest_internal_format, | |
| 222 GLsizei width, | |
| 223 GLsizei height, | |
| 224 GLuint framebuffer) { | |
| 225 DCHECK(source_target == GL_TEXTURE_2D || | |
| 226 source_target == GL_TEXTURE_RECTANGLE_ARB); | |
| 227 if (BindFramebufferTexture2D( | |
| 228 source_target, source_id, 0 /* level */, framebuffer)) { | |
| 229 glBindTexture(GL_TEXTURE_2D, dest_id); | |
| 230 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 231 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 232 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 233 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 234 glCopyTexImage2D(GL_TEXTURE_2D, | |
| 235 dest_level, | |
| 236 dest_internal_format, | |
| 237 0 /* x */, | |
| 238 0 /* y */, | |
| 239 width, | |
| 240 height, | |
| 241 0 /* border */); | |
| 242 } | |
| 243 | |
| 244 decoder->RestoreTextureState(source_id); | |
| 245 decoder->RestoreTextureState(dest_id); | |
| 246 decoder->RestoreTextureUnitBindings(0); | |
| 247 decoder->RestoreActiveTexture(); | |
| 248 decoder->RestoreFramebufferBindings(); | |
| 249 } | |
| 250 | |
| 189 } // namespace | 251 } // namespace |
| 190 | 252 |
| 191 namespace gpu { | 253 namespace gpu { |
| 192 | 254 |
| 193 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() | 255 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() |
| 194 : initialized_(false), | 256 : initialized_(false), |
| 195 vertex_shaders_(NUM_VERTEX_SHADERS, 0u), | 257 vertex_shaders_(NUM_VERTEX_SHADERS, 0u), |
| 196 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u), | 258 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u), |
| 197 buffer_id_(0u), | 259 buffer_id_(0u), |
| 198 framebuffer_(0u) {} | 260 framebuffer_(0u) {} |
| 199 | 261 |
| 200 CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() {} | 262 CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() { |
| 263 DCHECK(!buffer_id_); | |
| 264 DCHECK(!framebuffer_); | |
| 265 } | |
| 201 | 266 |
| 202 void CopyTextureCHROMIUMResourceManager::Initialize( | 267 void CopyTextureCHROMIUMResourceManager::Initialize( |
| 203 const gles2::GLES2Decoder* decoder) { | 268 const gles2::GLES2Decoder* decoder) { |
| 204 COMPILE_ASSERT( | 269 COMPILE_ASSERT( |
| 205 kVertexPositionAttrib == 0u, | 270 kVertexPositionAttrib == 0u, |
| 206 Position_attribs_must_be_0); | 271 Position_attribs_must_be_0); |
| 272 DCHECK(!buffer_id_); | |
| 273 DCHECK(!framebuffer_); | |
| 274 DCHECK(programs_.empty()); | |
| 207 | 275 |
| 208 // Initialize all of the GPU resources required to perform the copy. | 276 // Initialize all of the GPU resources required to perform the copy. |
| 209 glGenBuffersARB(1, &buffer_id_); | 277 glGenBuffersARB(1, &buffer_id_); |
| 210 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); | 278 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); |
| 211 const GLfloat kQuadVertices[] = {-1.0f, -1.0f, | 279 const GLfloat kQuadVertices[] = {-1.0f, -1.0f, |
| 212 1.0f, -1.0f, | 280 1.0f, -1.0f, |
| 213 1.0f, 1.0f, | 281 1.0f, 1.0f, |
| 214 -1.0f, 1.0f}; | 282 -1.0f, 1.0f}; |
| 215 glBufferData( | 283 glBufferData( |
| 216 GL_ARRAY_BUFFER, sizeof(kQuadVertices), kQuadVertices, GL_STATIC_DRAW); | 284 GL_ARRAY_BUFFER, sizeof(kQuadVertices), kQuadVertices, GL_STATIC_DRAW); |
| 217 | 285 |
| 218 glGenFramebuffersEXT(1, &framebuffer_); | 286 glGenFramebuffersEXT(1, &framebuffer_); |
| 219 | 287 |
| 220 decoder->RestoreBufferBindings(); | 288 decoder->RestoreBufferBindings(); |
| 221 | 289 |
| 222 initialized_ = true; | 290 initialized_ = true; |
| 223 } | 291 } |
| 224 | 292 |
| 225 void CopyTextureCHROMIUMResourceManager::Destroy() { | 293 void CopyTextureCHROMIUMResourceManager::Destroy() { |
| 226 if (!initialized_) | 294 if (!initialized_) |
| 227 return; | 295 return; |
| 228 | 296 |
| 229 glDeleteFramebuffersEXT(1, &framebuffer_); | 297 glDeleteFramebuffersEXT(1, &framebuffer_); |
| 298 framebuffer_ = 0; | |
| 230 | 299 |
| 231 std::for_each(vertex_shaders_.begin(), vertex_shaders_.end(), DeleteShader); | 300 std::for_each(vertex_shaders_.begin(), vertex_shaders_.end(), DeleteShader); |
| 232 std::for_each( | 301 std::for_each( |
| 233 fragment_shaders_.begin(), fragment_shaders_.end(), DeleteShader); | 302 fragment_shaders_.begin(), fragment_shaders_.end(), DeleteShader); |
| 234 | 303 |
| 235 for (ProgramMap::const_iterator it = programs_.begin(); it != programs_.end(); | 304 for (ProgramMap::const_iterator it = programs_.begin(); it != programs_.end(); |
| 236 ++it) { | 305 ++it) { |
| 237 const ProgramInfo& info = it->second; | 306 const ProgramInfo& info = it->second; |
| 238 glDeleteProgram(info.program); | 307 glDeleteProgram(info.program); |
| 239 } | 308 } |
| 240 | 309 |
| 241 glDeleteBuffersARB(1, &buffer_id_); | 310 glDeleteBuffersARB(1, &buffer_id_); |
| 311 buffer_id_ = 0; | |
| 312 } | |
| 313 | |
| 314 bool DoesSourceContainSupersetOfDestination(GLenum source_format, | |
| 315 GLenum dest_format) { | |
|
reveman
2014/08/11 18:37:21
is this worth it or should we just keep it simple
dshwang
2014/08/11 19:48:08
Simplified as follows;
return source_format == d
| |
| 316 // The format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or | |
| 317 // GL_LUMINANCE_ALPHA. | |
| 318 DCHECK(source_format >= GL_ALPHA && source_format <= GL_LUMINANCE_ALPHA); | |
| 319 DCHECK(dest_format >= GL_ALPHA && dest_format <= GL_LUMINANCE_ALPHA); | |
| 320 switch (source_format) { | |
| 321 case GL_ALPHA: | |
| 322 case GL_LUMINANCE: | |
| 323 return dest_format == source_format; | |
| 324 case GL_RGBA: | |
| 325 return true; | |
| 326 case GL_RGB: | |
| 327 return dest_format == source_format || dest_format == GL_LUMINANCE; | |
| 328 case GL_LUMINANCE_ALPHA: | |
| 329 return dest_format == source_format || dest_format == GL_LUMINANCE || | |
| 330 dest_format == GL_ALPHA; | |
| 331 } | |
| 332 NOTREACHED(); | |
| 333 return false; | |
| 242 } | 334 } |
| 243 | 335 |
| 244 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( | 336 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
| 245 const gles2::GLES2Decoder* decoder, | 337 const gles2::GLES2Decoder* decoder, |
| 246 GLenum source_target, | 338 GLenum source_target, |
| 247 GLenum dest_target, | |
| 248 GLuint source_id, | 339 GLuint source_id, |
| 340 GLenum source_internal_format, | |
| 249 GLuint dest_id, | 341 GLuint dest_id, |
| 250 GLint level, | 342 GLint dest_level, |
| 343 GLenum dest_internal_format, | |
| 251 GLsizei width, | 344 GLsizei width, |
| 252 GLsizei height, | 345 GLsizei height, |
| 253 bool flip_y, | 346 bool flip_y, |
| 254 bool premultiply_alpha, | 347 bool premultiply_alpha, |
| 255 bool unpremultiply_alpha) { | 348 bool unpremultiply_alpha) { |
| 349 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | |
| 350 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's | |
| 351 // format does not contain a superset of the components required by the base | |
| 352 // format of internalformat. | |
| 353 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml | |
| 354 bool source_contain_superset_of_dest = DoesSourceContainSupersetOfDestination( | |
| 355 source_internal_format, dest_internal_format); | |
| 356 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, | |
| 357 // so restrict this to GL_TEXTURE_2D. | |
|
dshwang
2014/08/11 14:08:12
This code resolves win gpu bot failure in context/
| |
| 358 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && | |
| 359 source_contain_superset_of_dest) { | |
| 360 DoCopyTexImage2D(decoder, | |
| 361 source_target, | |
| 362 source_id, | |
| 363 dest_id, | |
| 364 dest_level, | |
| 365 dest_internal_format, | |
| 366 width, | |
| 367 height, | |
| 368 framebuffer_); | |
| 369 return; | |
| 370 } | |
| 371 | |
| 256 // Use default transform matrix if no transform passed in. | 372 // Use default transform matrix if no transform passed in. |
| 257 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, | 373 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, |
| 258 0.0f, 1.0f, 0.0f, 0.0f, | 374 0.0f, 1.0f, 0.0f, 0.0f, |
| 259 0.0f, 0.0f, 1.0f, 0.0f, | 375 0.0f, 0.0f, 1.0f, 0.0f, |
| 260 0.0f, 0.0f, 0.0f, 1.0f}; | 376 0.0f, 0.0f, 0.0f, 1.0f}; |
| 261 DoCopyTextureWithTransform(decoder, source_target, dest_target, source_id, | 377 DoCopyTextureWithTransform(decoder, |
| 262 dest_id, level, width, height, flip_y, premultiply_alpha, | 378 source_target, |
| 263 unpremultiply_alpha, default_matrix); | 379 source_id, |
| 380 dest_id, | |
| 381 dest_level, | |
| 382 width, | |
| 383 height, | |
| 384 flip_y, | |
| 385 premultiply_alpha, | |
| 386 unpremultiply_alpha, | |
| 387 default_matrix); | |
| 264 } | 388 } |
| 265 | 389 |
| 266 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( | 390 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( |
| 267 const gles2::GLES2Decoder* decoder, | 391 const gles2::GLES2Decoder* decoder, |
| 268 GLenum source_target, | 392 GLenum source_target, |
| 269 GLenum dest_target, | |
| 270 GLuint source_id, | 393 GLuint source_id, |
| 271 GLuint dest_id, | 394 GLuint dest_id, |
| 272 GLint level, | 395 GLint dest_level, |
| 273 GLsizei width, | 396 GLsizei width, |
| 274 GLsizei height, | 397 GLsizei height, |
| 275 bool flip_y, | 398 bool flip_y, |
| 276 bool premultiply_alpha, | 399 bool premultiply_alpha, |
| 277 bool unpremultiply_alpha, | 400 bool unpremultiply_alpha, |
| 278 const GLfloat transform_matrix[16]) { | 401 const GLfloat transform_matrix[16]) { |
| 279 DCHECK(source_target == GL_TEXTURE_2D || | 402 DCHECK(source_target == GL_TEXTURE_2D || |
| 280 source_target == GL_TEXTURE_RECTANGLE_ARB || | 403 source_target == GL_TEXTURE_RECTANGLE_ARB || |
| 281 source_target == GL_TEXTURE_EXTERNAL_OES); | 404 source_target == GL_TEXTURE_EXTERNAL_OES); |
| 282 if (!initialized_) { | 405 if (!initialized_) { |
| 283 DLOG(ERROR) << "CopyTextureCHROMIUM: Uninitialized manager."; | 406 DLOG(ERROR) << "CopyTextureCHROMIUM: Uninitialized manager."; |
| 284 return; | 407 return; |
| 285 } | 408 } |
| 286 | 409 |
| 287 VertexShaderId vertex_shader_id = GetVertexShaderId(flip_y); | 410 VertexShaderId vertex_shader_id = GetVertexShaderId(flip_y); |
| 288 DCHECK_LT(static_cast<size_t>(vertex_shader_id), vertex_shaders_.size()); | 411 DCHECK_LT(static_cast<size_t>(vertex_shader_id), vertex_shaders_.size()); |
| 289 GLuint* vertex_shader = &vertex_shaders_[vertex_shader_id]; | |
| 290 if (!*vertex_shader) { | |
| 291 *vertex_shader = glCreateShader(GL_VERTEX_SHADER); | |
| 292 CompileShader(*vertex_shader, vertex_shader_source[vertex_shader_id]); | |
| 293 } | |
| 294 | |
| 295 FragmentShaderId fragment_shader_id = GetFragmentShaderId( | 412 FragmentShaderId fragment_shader_id = GetFragmentShaderId( |
| 296 premultiply_alpha, unpremultiply_alpha, source_target); | 413 premultiply_alpha, unpremultiply_alpha, source_target); |
| 297 DCHECK_LT(static_cast<size_t>(fragment_shader_id), fragment_shaders_.size()); | 414 DCHECK_LT(static_cast<size_t>(fragment_shader_id), fragment_shaders_.size()); |
| 298 GLuint* fragment_shader = &fragment_shaders_[fragment_shader_id]; | |
| 299 if (!*fragment_shader) { | |
| 300 *fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); | |
| 301 CompileShader(*fragment_shader, fragment_shader_source[fragment_shader_id]); | |
| 302 } | |
| 303 | 415 |
| 304 ProgramMapKey key(vertex_shader_id, fragment_shader_id); | 416 ProgramMapKey key(vertex_shader_id, fragment_shader_id); |
| 305 ProgramInfo* info = &programs_[key]; | 417 ProgramInfo* info = &programs_[key]; |
| 306 // Create program if necessary. | 418 // Create program if necessary. |
| 307 if (!info->program) { | 419 if (!info->program) { |
| 308 info->program = glCreateProgram(); | 420 info->program = glCreateProgram(); |
| 421 GLuint* vertex_shader = &vertex_shaders_[vertex_shader_id]; | |
| 422 if (!*vertex_shader) { | |
| 423 *vertex_shader = glCreateShader(GL_VERTEX_SHADER); | |
| 424 CompileShader(*vertex_shader, vertex_shader_source[vertex_shader_id]); | |
| 425 } | |
| 309 glAttachShader(info->program, *vertex_shader); | 426 glAttachShader(info->program, *vertex_shader); |
| 427 GLuint* fragment_shader = &fragment_shaders_[fragment_shader_id]; | |
| 428 if (!*fragment_shader) { | |
| 429 *fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); | |
| 430 CompileShader(*fragment_shader, | |
| 431 fragment_shader_source[fragment_shader_id]); | |
| 432 } | |
| 310 glAttachShader(info->program, *fragment_shader); | 433 glAttachShader(info->program, *fragment_shader); |
| 311 glBindAttribLocation(info->program, kVertexPositionAttrib, "a_position"); | 434 glBindAttribLocation(info->program, kVertexPositionAttrib, "a_position"); |
| 312 glLinkProgram(info->program); | 435 glLinkProgram(info->program); |
| 313 #ifndef NDEBUG | 436 #ifndef NDEBUG |
| 314 GLint linked; | 437 GLint linked; |
| 315 glGetProgramiv(info->program, GL_LINK_STATUS, &linked); | 438 glGetProgramiv(info->program, GL_LINK_STATUS, &linked); |
| 316 if (!linked) | 439 if (!linked) |
| 317 DLOG(ERROR) << "CopyTextureCHROMIUM: program link failure."; | 440 DLOG(ERROR) << "CopyTextureCHROMIUM: program link failure."; |
| 318 #endif | 441 #endif |
| 319 info->matrix_handle = glGetUniformLocation(info->program, "u_matrix"); | 442 info->matrix_handle = glGetUniformLocation(info->program, "u_matrix"); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 330 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; | 453 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; |
| 331 return; | 454 return; |
| 332 } | 455 } |
| 333 #endif | 456 #endif |
| 334 | 457 |
| 335 glUniformMatrix4fv(info->matrix_handle, 1, GL_FALSE, transform_matrix); | 458 glUniformMatrix4fv(info->matrix_handle, 1, GL_FALSE, transform_matrix); |
| 336 if (source_target == GL_TEXTURE_RECTANGLE_ARB) | 459 if (source_target == GL_TEXTURE_RECTANGLE_ARB) |
| 337 glUniform2f(info->half_size_handle, width / 2.0f, height / 2.0f); | 460 glUniform2f(info->half_size_handle, width / 2.0f, height / 2.0f); |
| 338 else | 461 else |
| 339 glUniform2f(info->half_size_handle, 0.5f, 0.5f); | 462 glUniform2f(info->half_size_handle, 0.5f, 0.5f); |
| 340 glActiveTexture(GL_TEXTURE0); | |
| 341 glBindTexture(GL_TEXTURE_2D, dest_id); | |
| 342 // NVidia drivers require texture settings to be a certain way | |
| 343 // or they won't report FRAMEBUFFER_COMPLETE. | |
| 344 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 345 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 346 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 347 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 348 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_); | |
| 349 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, | |
| 350 dest_id, level); | |
| 351 | 463 |
| 352 #ifndef NDEBUG | 464 if (BindFramebufferTexture2D( |
| 353 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 465 GL_TEXTURE_2D, dest_id, dest_level, framebuffer_)) { |
| 354 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { | |
| 355 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; | |
| 356 } else | |
| 357 #endif | |
| 358 { | |
| 359 decoder->ClearAllAttributes(); | 466 decoder->ClearAllAttributes(); |
| 360 glEnableVertexAttribArray(kVertexPositionAttrib); | 467 glEnableVertexAttribArray(kVertexPositionAttrib); |
| 361 | 468 |
| 362 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); | 469 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); |
| 363 glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0); | 470 glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 364 | 471 |
| 365 glUniform1i(info->sampler_handle, 0); | 472 glUniform1i(info->sampler_handle, 0); |
| 366 | 473 |
| 367 glBindTexture(source_target, source_id); | 474 glBindTexture(source_target, source_id); |
| 368 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 475 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 387 decoder->RestoreTextureState(dest_id); | 494 decoder->RestoreTextureState(dest_id); |
| 388 decoder->RestoreTextureUnitBindings(0); | 495 decoder->RestoreTextureUnitBindings(0); |
| 389 decoder->RestoreActiveTexture(); | 496 decoder->RestoreActiveTexture(); |
| 390 decoder->RestoreProgramBindings(); | 497 decoder->RestoreProgramBindings(); |
| 391 decoder->RestoreBufferBindings(); | 498 decoder->RestoreBufferBindings(); |
| 392 decoder->RestoreFramebufferBindings(); | 499 decoder->RestoreFramebufferBindings(); |
| 393 decoder->RestoreGlobalState(); | 500 decoder->RestoreGlobalState(); |
| 394 } | 501 } |
| 395 | 502 |
| 396 } // namespace gpu | 503 } // namespace gpu |
| OLD | NEW |