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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 FRAGMENT_SHADERS( | 96 FRAGMENT_SHADERS( |
| 97 uniform SamplerType u_sampler; | 97 uniform SamplerType u_sampler; |
| 98 varying TexCoordPrecision vec2 v_uv; | 98 varying TexCoordPrecision vec2 v_uv; |
| 99 void main(void) { | 99 void main(void) { |
| 100 gl_FragColor = TextureLookup(u_sampler, v_uv.st); | 100 gl_FragColor = TextureLookup(u_sampler, v_uv.st); |
| 101 if (gl_FragColor.a > 0.0) | 101 if (gl_FragColor.a > 0.0) |
| 102 gl_FragColor.rgb /= gl_FragColor.a; | 102 gl_FragColor.rgb /= gl_FragColor.a; |
| 103 }), | 103 }), |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 const GLfloat kDefaultMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, | |
| 107 0.0f, 1.0f, 0.0f, 0.0f, | |
| 108 0.0f, 0.0f, 1.0f, 0.0f, | |
| 109 0.0f, 0.0f, 0.0f, 1.0f}; | |
| 110 | |
| 106 // Returns the correct vertex shader id to evaluate the copy operation for | 111 // Returns the correct vertex shader id to evaluate the copy operation for |
| 107 // the CHROMIUM_flipy setting. | 112 // the CHROMIUM_flipy setting. |
| 108 VertexShaderId GetVertexShaderId(bool flip_y) { | 113 VertexShaderId GetVertexShaderId(bool flip_y) { |
| 109 // bit 0: flip y | 114 // bit 0: flip y |
| 110 static VertexShaderId shader_ids[] = { | 115 static VertexShaderId shader_ids[] = { |
| 111 VERTEX_SHADER_COPY_TEXTURE, | 116 VERTEX_SHADER_COPY_TEXTURE, |
| 112 VERTEX_SHADER_COPY_TEXTURE_FLIP_Y, | 117 VERTEX_SHADER_COPY_TEXTURE_FLIP_Y, |
| 113 }; | 118 }; |
| 114 | 119 |
| 115 unsigned index = flip_y ? 1 : 0; | 120 unsigned index = flip_y ? 1 : 0; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 return shader_ids[index][SAMPLER_2D]; | 165 return shader_ids[index][SAMPLER_2D]; |
| 161 case GL_TEXTURE_RECTANGLE_ARB: | 166 case GL_TEXTURE_RECTANGLE_ARB: |
| 162 return shader_ids[index][SAMPLER_RECTANGLE_ARB]; | 167 return shader_ids[index][SAMPLER_RECTANGLE_ARB]; |
| 163 case GL_TEXTURE_EXTERNAL_OES: | 168 case GL_TEXTURE_EXTERNAL_OES: |
| 164 return shader_ids[index][SAMPLER_EXTERNAL_OES]; | 169 return shader_ids[index][SAMPLER_EXTERNAL_OES]; |
| 165 default: | 170 default: |
| 166 break; | 171 break; |
| 167 } | 172 } |
| 168 | 173 |
| 169 NOTREACHED(); | 174 NOTREACHED(); |
| 170 return shader_ids[index][SAMPLER_2D]; | 175 return shader_ids[0][SAMPLER_2D]; |
| 171 } | 176 } |
| 172 | 177 |
| 173 void CompileShader(GLuint shader, const char* shader_source) { | 178 void CompileShader(GLuint shader, const char* shader_source) { |
| 174 glShaderSource(shader, 1, &shader_source, 0); | 179 glShaderSource(shader, 1, &shader_source, 0); |
| 175 glCompileShader(shader); | 180 glCompileShader(shader); |
| 176 #ifndef NDEBUG | 181 #ifndef NDEBUG |
| 177 GLint compile_status; | 182 GLint compile_status; |
| 178 glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); | 183 glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status); |
| 179 if (GL_TRUE != compile_status) | 184 if (GL_TRUE != compile_status) |
| 180 DLOG(ERROR) << "CopyTextureCHROMIUM: shader compilation failure."; | 185 DLOG(ERROR) << "CopyTextureCHROMIUM: shader compilation failure."; |
| 181 #endif | 186 #endif |
| 182 } | 187 } |
| 183 | 188 |
| 184 void DeleteShader(GLuint shader) { | 189 void DeleteShader(GLuint shader) { |
| 185 if (shader) | 190 if (shader) |
| 186 glDeleteShader(shader); | 191 glDeleteShader(shader); |
| 187 } | 192 } |
| 188 | 193 |
| 189 } // namespace | 194 } // namespace |
| 190 | 195 |
| 191 namespace gpu { | 196 namespace gpu { |
| 192 | 197 |
| 193 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() | 198 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() |
| 194 : initialized_(false), | 199 : initialized_(false), |
| 195 vertex_shaders_(NUM_VERTEX_SHADERS, 0u), | 200 vertex_shaders_(NUM_VERTEX_SHADERS, 0u), |
| 196 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u), | 201 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u), |
| 197 buffer_id_(0u), | 202 buffer_id_(0u), |
| 198 framebuffer_(0u) {} | 203 framebuffer_(0u) {} |
| 199 | 204 |
| 200 CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() {} | 205 CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() { |
| 206 DCHECK(!buffer_id_ && !framebuffer_); | |
| 207 } | |
| 201 | 208 |
| 202 void CopyTextureCHROMIUMResourceManager::Initialize( | 209 void CopyTextureCHROMIUMResourceManager::Initialize( |
| 203 const gles2::GLES2Decoder* decoder) { | 210 const gles2::GLES2Decoder* decoder) { |
| 204 COMPILE_ASSERT( | 211 COMPILE_ASSERT( |
| 205 kVertexPositionAttrib == 0u, | 212 kVertexPositionAttrib == 0u, |
| 206 Position_attribs_must_be_0); | 213 Position_attribs_must_be_0); |
| 214 DCHECK(!buffer_id_ && !framebuffer_ && programs_.empty()); | |
| 207 | 215 |
| 208 // Initialize all of the GPU resources required to perform the copy. | 216 // Initialize all of the GPU resources required to perform the copy. |
| 209 glGenBuffersARB(1, &buffer_id_); | 217 glGenBuffersARB(1, &buffer_id_); |
| 210 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); | 218 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); |
| 211 const GLfloat kQuadVertices[] = {-1.0f, -1.0f, | 219 const GLfloat kQuadVertices[] = {-1.0f, -1.0f, |
| 212 1.0f, -1.0f, | 220 1.0f, -1.0f, |
| 213 1.0f, 1.0f, | 221 1.0f, 1.0f, |
| 214 -1.0f, 1.0f}; | 222 -1.0f, 1.0f}; |
| 215 glBufferData( | 223 glBufferData( |
| 216 GL_ARRAY_BUFFER, sizeof(kQuadVertices), kQuadVertices, GL_STATIC_DRAW); | 224 GL_ARRAY_BUFFER, sizeof(kQuadVertices), kQuadVertices, GL_STATIC_DRAW); |
| 217 | 225 |
| 218 glGenFramebuffersEXT(1, &framebuffer_); | 226 glGenFramebuffersEXT(1, &framebuffer_); |
| 219 | 227 |
| 220 decoder->RestoreBufferBindings(); | 228 decoder->RestoreBufferBindings(); |
| 221 | 229 |
| 222 initialized_ = true; | 230 initialized_ = true; |
| 223 } | 231 } |
| 224 | 232 |
| 225 void CopyTextureCHROMIUMResourceManager::Destroy() { | 233 void CopyTextureCHROMIUMResourceManager::Destroy() { |
| 226 if (!initialized_) | 234 if (!initialized_) |
| 227 return; | 235 return; |
| 228 | 236 |
| 229 glDeleteFramebuffersEXT(1, &framebuffer_); | 237 glDeleteFramebuffersEXT(1, &framebuffer_); |
| 238 framebuffer_ = 0; | |
| 230 | 239 |
| 231 std::for_each(vertex_shaders_.begin(), vertex_shaders_.end(), DeleteShader); | 240 std::for_each(vertex_shaders_.begin(), vertex_shaders_.end(), DeleteShader); |
| 232 std::for_each( | 241 std::for_each( |
| 233 fragment_shaders_.begin(), fragment_shaders_.end(), DeleteShader); | 242 fragment_shaders_.begin(), fragment_shaders_.end(), DeleteShader); |
| 234 | 243 |
| 235 for (ProgramMap::const_iterator it = programs_.begin(); it != programs_.end(); | 244 for (ProgramMap::const_iterator it = programs_.begin(); it != programs_.end(); |
| 236 ++it) { | 245 ++it) { |
| 237 const ProgramInfo& info = it->second; | 246 const ProgramInfo& info = it->second; |
| 238 glDeleteProgram(info.program); | 247 glDeleteProgram(info.program); |
| 239 } | 248 } |
| 240 | 249 |
| 241 glDeleteBuffersARB(1, &buffer_id_); | 250 glDeleteBuffersARB(1, &buffer_id_); |
| 251 buffer_id_ = 0; | |
| 242 } | 252 } |
| 243 | 253 |
| 244 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( | 254 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
| 245 const gles2::GLES2Decoder* decoder, | 255 const gles2::GLES2Decoder* decoder, |
| 246 GLenum source_target, | 256 GLenum source_target, |
| 247 GLenum dest_target, | |
| 248 GLuint source_id, | 257 GLuint source_id, |
| 249 GLuint dest_id, | 258 GLuint dest_id, |
| 250 GLint level, | 259 GLint level, |
| 260 GLenum internal_format, | |
| 251 GLsizei width, | 261 GLsizei width, |
| 252 GLsizei height, | 262 GLsizei height, |
| 253 bool flip_y, | 263 bool flip_y, |
| 254 bool premultiply_alpha, | 264 bool premultiply_alpha, |
| 255 bool unpremultiply_alpha) { | 265 bool unpremultiply_alpha) { |
| 256 // Use default transform matrix if no transform passed in. | 266 DoCopyTextureWithTransform(decoder, source_target, source_id, dest_id, |
| 257 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, | 267 level, internal_format, width, height, flip_y, premultiply_alpha, |
| 258 0.0f, 1.0f, 0.0f, 0.0f, | 268 unpremultiply_alpha, kDefaultMatrix); |
| 259 0.0f, 0.0f, 1.0f, 0.0f, | 269 } |
| 260 0.0f, 0.0f, 0.0f, 1.0f}; | 270 |
| 261 DoCopyTextureWithTransform(decoder, source_target, dest_target, source_id, | 271 void CopyTextureCHROMIUMResourceManager::DoFastCopyTexture( |
| 262 dest_id, level, width, height, flip_y, premultiply_alpha, | 272 const gles2::GLES2Decoder* decoder, |
| 263 unpremultiply_alpha, default_matrix); | 273 GLuint source_id, |
| 274 GLuint dest_id, | |
| 275 GLint level, | |
| 276 GLenum internal_format, | |
| 277 GLsizei width, | |
| 278 GLsizei height) { | |
|
reveman
2014/07/09 18:33:28
Does this need to be limited to source_target=TEXT
dshwang
2014/07/09 18:53:12
Do you mean TEXTURE_REXTANGLE_ARB texture can be b
reveman
2014/07/09 19:45:07
Hm, maybe this is only supported by standard GL. T
dshwang
2014/07/10 15:19:45
Yep, I restrict this to TEXTURE_2D, but make ::Bin
| |
| 279 if (BindFramebufferTexture2D(source_id, 0 /* level */)) { | |
| 280 glBindTexture(GL_TEXTURE_2D, dest_id); | |
| 281 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 282 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 283 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 284 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 285 glCopyTexImage2D(GL_TEXTURE_2D, | |
| 286 level, | |
| 287 internal_format, | |
| 288 0 /* x */, | |
| 289 0 /* y */, | |
| 290 width, | |
| 291 height, | |
| 292 0 /* border */); | |
| 293 } | |
| 294 | |
| 295 decoder->RestoreTextureState(source_id); | |
| 296 decoder->RestoreTextureState(dest_id); | |
| 297 decoder->RestoreTextureUnitBindings(0); | |
| 298 decoder->RestoreActiveTexture(); | |
| 299 decoder->RestoreFramebufferBindings(); | |
| 300 } | |
| 301 | |
| 302 bool CopyTextureCHROMIUMResourceManager::BindFramebufferTexture2D( | |
| 303 GLuint texture_id, | |
| 304 GLint level) { | |
| 305 glActiveTexture(GL_TEXTURE0); | |
| 306 glBindTexture(GL_TEXTURE_2D, texture_id); | |
| 307 // NVidia drivers require texture settings to be a certain way | |
| 308 // or they won't report FRAMEBUFFER_COMPLETE. | |
| 309 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 310 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 311 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | |
| 312 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | |
| 313 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_); | |
| 314 glFramebufferTexture2DEXT( | |
| 315 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, level); | |
| 316 | |
| 317 #ifndef NDEBUG | |
| 318 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
| 319 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { | |
| 320 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; | |
| 321 return false; | |
| 322 } | |
| 323 #endif | |
| 324 return true; | |
| 264 } | 325 } |
| 265 | 326 |
| 266 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( | 327 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( |
| 267 const gles2::GLES2Decoder* decoder, | 328 const gles2::GLES2Decoder* decoder, |
| 268 GLenum source_target, | 329 GLenum source_target, |
| 269 GLenum dest_target, | |
| 270 GLuint source_id, | 330 GLuint source_id, |
| 271 GLuint dest_id, | 331 GLuint dest_id, |
| 272 GLint level, | 332 GLint level, |
| 333 GLenum internal_format, | |
| 273 GLsizei width, | 334 GLsizei width, |
| 274 GLsizei height, | 335 GLsizei height, |
| 275 bool flip_y, | 336 bool flip_y, |
| 276 bool premultiply_alpha, | 337 bool premultiply_alpha, |
| 277 bool unpremultiply_alpha, | 338 bool unpremultiply_alpha, |
| 278 const GLfloat transform_matrix[16]) { | 339 const GLfloat transform_matrix[16]) { |
| 279 DCHECK(source_target == GL_TEXTURE_2D || | 340 DCHECK(source_target == GL_TEXTURE_2D || |
| 280 source_target == GL_TEXTURE_RECTANGLE_ARB || | 341 source_target == GL_TEXTURE_RECTANGLE_ARB || |
| 281 source_target == GL_TEXTURE_EXTERNAL_OES); | 342 source_target == GL_TEXTURE_EXTERNAL_OES); |
| 282 if (!initialized_) { | 343 if (!initialized_) { |
| 283 DLOG(ERROR) << "CopyTextureCHROMIUM: Uninitialized manager."; | 344 DLOG(ERROR) << "CopyTextureCHROMIUM: Uninitialized manager."; |
| 284 return; | 345 return; |
| 285 } | 346 } |
| 286 | 347 |
| 287 VertexShaderId vertex_shader_id = GetVertexShaderId(flip_y); | 348 VertexShaderId vertex_shader_id = GetVertexShaderId(flip_y); |
| 288 DCHECK_LT(static_cast<size_t>(vertex_shader_id), vertex_shaders_.size()); | 349 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( | 350 FragmentShaderId fragment_shader_id = GetFragmentShaderId( |
| 296 premultiply_alpha, unpremultiply_alpha, source_target); | 351 premultiply_alpha, unpremultiply_alpha, source_target); |
| 297 DCHECK_LT(static_cast<size_t>(fragment_shader_id), fragment_shaders_.size()); | 352 DCHECK_LT(static_cast<size_t>(fragment_shader_id), fragment_shaders_.size()); |
| 298 GLuint* fragment_shader = &fragment_shaders_[fragment_shader_id]; | 353 |
| 299 if (!*fragment_shader) { | 354 if (vertex_shader_id == VERTEX_SHADER_COPY_TEXTURE && |
| 300 *fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); | 355 fragment_shader_id == FRAGMENT_SHADER_COPY_TEXTURE_2D && |
|
reveman
2014/07/09 18:33:28
I think it's more appropriate to check the paramet
dshwang
2014/07/09 18:53:12
Alright. I'll update.
| |
| 301 CompileShader(*fragment_shader, fragment_shader_source[fragment_shader_id]); | 356 transform_matrix == kDefaultMatrix) { |
| 357 DoFastCopyTexture(decoder, | |
| 358 source_id, | |
| 359 dest_id, | |
| 360 level, | |
| 361 internal_format, | |
| 362 width, | |
| 363 height); | |
| 302 } | 364 } |
| 303 | 365 |
| 304 ProgramMapKey key(vertex_shader_id, fragment_shader_id); | 366 ProgramMapKey key(vertex_shader_id, fragment_shader_id); |
| 305 ProgramInfo* info = &programs_[key]; | 367 ProgramInfo* info = &programs_[key]; |
| 306 // Create program if necessary. | 368 // Create program if necessary. |
| 307 if (!info->program) { | 369 if (!info->program) { |
| 308 info->program = glCreateProgram(); | 370 info->program = glCreateProgram(); |
| 371 GLuint* vertex_shader = &vertex_shaders_[vertex_shader_id]; | |
| 372 if (!*vertex_shader) { | |
| 373 *vertex_shader = glCreateShader(GL_VERTEX_SHADER); | |
| 374 CompileShader(*vertex_shader, vertex_shader_source[vertex_shader_id]); | |
| 375 } | |
| 309 glAttachShader(info->program, *vertex_shader); | 376 glAttachShader(info->program, *vertex_shader); |
| 377 GLuint* fragment_shader = &fragment_shaders_[fragment_shader_id]; | |
| 378 if (!*fragment_shader) { | |
| 379 *fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); | |
| 380 CompileShader(*fragment_shader, | |
| 381 fragment_shader_source[fragment_shader_id]); | |
| 382 } | |
| 310 glAttachShader(info->program, *fragment_shader); | 383 glAttachShader(info->program, *fragment_shader); |
| 311 glBindAttribLocation(info->program, kVertexPositionAttrib, "a_position"); | 384 glBindAttribLocation(info->program, kVertexPositionAttrib, "a_position"); |
| 312 glLinkProgram(info->program); | 385 glLinkProgram(info->program); |
| 313 #ifndef NDEBUG | 386 #ifndef NDEBUG |
| 314 GLint linked; | 387 GLint linked; |
| 315 glGetProgramiv(info->program, GL_LINK_STATUS, &linked); | 388 glGetProgramiv(info->program, GL_LINK_STATUS, &linked); |
| 316 if (!linked) | 389 if (!linked) |
| 317 DLOG(ERROR) << "CopyTextureCHROMIUM: program link failure."; | 390 DLOG(ERROR) << "CopyTextureCHROMIUM: program link failure."; |
| 318 #endif | 391 #endif |
| 319 info->matrix_handle = glGetUniformLocation(info->program, "u_matrix"); | 392 info->matrix_handle = glGetUniformLocation(info->program, "u_matrix"); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 330 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; | 403 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; |
| 331 return; | 404 return; |
| 332 } | 405 } |
| 333 #endif | 406 #endif |
| 334 | 407 |
| 335 glUniformMatrix4fv(info->matrix_handle, 1, GL_FALSE, transform_matrix); | 408 glUniformMatrix4fv(info->matrix_handle, 1, GL_FALSE, transform_matrix); |
| 336 if (source_target == GL_TEXTURE_RECTANGLE_ARB) | 409 if (source_target == GL_TEXTURE_RECTANGLE_ARB) |
| 337 glUniform2f(info->half_size_handle, width / 2.0f, height / 2.0f); | 410 glUniform2f(info->half_size_handle, width / 2.0f, height / 2.0f); |
| 338 else | 411 else |
| 339 glUniform2f(info->half_size_handle, 0.5f, 0.5f); | 412 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 | 413 |
| 352 #ifndef NDEBUG | 414 if (BindFramebufferTexture2D(dest_id, level)) { |
| 353 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
| 354 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { | |
| 355 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; | |
| 356 } else | |
| 357 #endif | |
| 358 { | |
| 359 decoder->ClearAllAttributes(); | 415 decoder->ClearAllAttributes(); |
| 360 glEnableVertexAttribArray(kVertexPositionAttrib); | 416 glEnableVertexAttribArray(kVertexPositionAttrib); |
| 361 | 417 |
| 362 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); | 418 glBindBuffer(GL_ARRAY_BUFFER, buffer_id_); |
| 363 glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0); | 419 glVertexAttribPointer(kVertexPositionAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 364 | 420 |
| 365 glUniform1i(info->sampler_handle, 0); | 421 glUniform1i(info->sampler_handle, 0); |
| 366 | 422 |
| 367 glBindTexture(source_target, source_id); | 423 glBindTexture(source_target, source_id); |
| 368 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 424 glTexParameterf(source_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 387 decoder->RestoreTextureState(dest_id); | 443 decoder->RestoreTextureState(dest_id); |
| 388 decoder->RestoreTextureUnitBindings(0); | 444 decoder->RestoreTextureUnitBindings(0); |
| 389 decoder->RestoreActiveTexture(); | 445 decoder->RestoreActiveTexture(); |
| 390 decoder->RestoreProgramBindings(); | 446 decoder->RestoreProgramBindings(); |
| 391 decoder->RestoreBufferBindings(); | 447 decoder->RestoreBufferBindings(); |
| 392 decoder->RestoreFramebufferBindings(); | 448 decoder->RestoreFramebufferBindings(); |
| 393 decoder->RestoreGlobalState(); | 449 decoder->RestoreGlobalState(); |
| 394 } | 450 } |
| 395 | 451 |
| 396 } // namespace gpu | 452 } // namespace gpu |
| OLD | NEW |