Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc

Issue 1304103005: Revert of gpu: support GL_TEXTURE_CUBE_MAP destination target to Copy(Sub)TextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/service/gl_utils.h" 10 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
13 #include "gpu/command_buffer/service/texture_manager.h"
14 12
15 #define SHADER(src) \ 13 #define SHADER(src) \
16 "#ifdef GL_ES\n" \ 14 "#ifdef GL_ES\n" \
17 "precision mediump float;\n" \ 15 "precision mediump float;\n" \
18 "#define TexCoordPrecision mediump\n" \ 16 "#define TexCoordPrecision mediump\n" \
19 "#else\n" \ 17 "#else\n" \
20 "#define TexCoordPrecision\n" \ 18 "#define TexCoordPrecision\n" \
21 "#endif\n" #src 19 "#endif\n" #src
22 #define SHADER_2D(src) \ 20 #define SHADER_2D(src) \
23 "#define SamplerType sampler2D\n" \ 21 "#define SamplerType sampler2D\n" \
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 193 }
196 194
197 void DeleteShader(GLuint shader) { 195 void DeleteShader(GLuint shader) {
198 if (shader) 196 if (shader)
199 glDeleteShader(shader); 197 glDeleteShader(shader);
200 } 198 }
201 199
202 bool BindFramebufferTexture2D(GLenum target, 200 bool BindFramebufferTexture2D(GLenum target,
203 GLuint texture_id, 201 GLuint texture_id,
204 GLuint framebuffer) { 202 GLuint framebuffer) {
205 GLenum binding_target = 203 DCHECK(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE_ARB);
206 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(target);
207 DCHECK(binding_target == GL_TEXTURE_2D ||
208 binding_target == GL_TEXTURE_RECTANGLE_ARB ||
209 binding_target == GL_TEXTURE_CUBE_MAP);
210 glActiveTexture(GL_TEXTURE0); 204 glActiveTexture(GL_TEXTURE0);
211 glBindTexture(binding_target, texture_id); 205 glBindTexture(target, texture_id);
212 // NVidia drivers require texture settings to be a certain way 206 // NVidia drivers require texture settings to be a certain way
213 // or they won't report FRAMEBUFFER_COMPLETE. 207 // or they won't report FRAMEBUFFER_COMPLETE.
214 glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 208 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
215 glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 209 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
216 glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 210 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
217 glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 211 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
218 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer); 212 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
219 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, 213 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
220 texture_id, 0); 214 texture_id, 0);
221 215
222 #ifndef NDEBUG 216 #ifndef NDEBUG
223 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 217 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
224 if (GL_FRAMEBUFFER_COMPLETE != fb_status) { 218 if (GL_FRAMEBUFFER_COMPLETE != fb_status) {
225 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer."; 219 DLOG(ERROR) << "CopyTextureCHROMIUM: Incomplete framebuffer.";
226 return false; 220 return false;
227 } 221 }
228 #endif 222 #endif
229 return true; 223 return true;
230 } 224 }
231 225
232 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder, 226 void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder,
233 GLenum source_target, 227 GLenum source_target,
234 GLuint source_id, 228 GLuint source_id,
235 GLenum dest_target,
236 GLuint dest_id, 229 GLuint dest_id,
237 GLenum dest_internal_format, 230 GLenum dest_internal_format,
238 GLsizei width, 231 GLsizei width,
239 GLsizei height, 232 GLsizei height,
240 GLuint framebuffer) { 233 GLuint framebuffer) {
241 DCHECK(source_target == GL_TEXTURE_2D || 234 DCHECK(source_target == GL_TEXTURE_2D ||
242 source_target == GL_TEXTURE_RECTANGLE_ARB); 235 source_target == GL_TEXTURE_RECTANGLE_ARB);
243 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) { 236 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) {
244 GLenum binding_target = 237 glBindTexture(GL_TEXTURE_2D, dest_id);
245 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target); 238 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
246 glBindTexture(binding_target, dest_id); 239 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
247 glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 240 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
248 glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 241 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
249 glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 242 glCopyTexImage2D(GL_TEXTURE_2D, 0 /* level */, dest_internal_format,
250 glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
251 glCopyTexImage2D(dest_target, 0 /* level */, dest_internal_format,
252 0 /* x */, 0 /* y */, width, height, 0 /* border */); 243 0 /* x */, 0 /* y */, width, height, 0 /* border */);
253 } 244 }
254 245
255 decoder->RestoreTextureState(source_id); 246 decoder->RestoreTextureState(source_id);
256 decoder->RestoreTextureState(dest_id); 247 decoder->RestoreTextureState(dest_id);
257 decoder->RestoreTextureUnitBindings(0); 248 decoder->RestoreTextureUnitBindings(0);
258 decoder->RestoreActiveTexture(); 249 decoder->RestoreActiveTexture();
259 decoder->RestoreFramebufferBindings(); 250 decoder->RestoreFramebufferBindings();
260 } 251 }
261 252
262 void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder, 253 void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder,
263 GLenum source_target, 254 GLenum source_target,
264 GLuint source_id, 255 GLuint source_id,
265 GLenum dest_target,
266 GLuint dest_id, 256 GLuint dest_id,
267 GLint xoffset, 257 GLint xoffset,
268 GLint yoffset, 258 GLint yoffset,
269 GLint source_x, 259 GLint source_x,
270 GLint source_y, 260 GLint source_y,
271 GLsizei source_width, 261 GLsizei source_width,
272 GLsizei source_height, 262 GLsizei source_height,
273 GLuint framebuffer) { 263 GLuint framebuffer) {
274 DCHECK(source_target == GL_TEXTURE_2D || 264 DCHECK(source_target == GL_TEXTURE_2D ||
275 source_target == GL_TEXTURE_RECTANGLE_ARB); 265 source_target == GL_TEXTURE_RECTANGLE_ARB);
276 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) { 266 if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) {
277 GLenum binding_target = 267 glBindTexture(GL_TEXTURE_2D, dest_id);
278 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(dest_target); 268 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
279 glBindTexture(binding_target, dest_id); 269 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
280 glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 270 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
281 glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 271 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
282 glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 272 glCopyTexSubImage2D(GL_TEXTURE_2D, 0 /* level */, xoffset, yoffset,
283 glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 273 source_x, source_y, source_width, source_height);
284 glCopyTexSubImage2D(dest_target, 0 /* level */, xoffset, yoffset, source_x,
285 source_y, source_width, source_height);
286 } 274 }
287 275
288 decoder->RestoreTextureState(source_id); 276 decoder->RestoreTextureState(source_id);
289 decoder->RestoreTextureState(dest_id); 277 decoder->RestoreTextureState(dest_id);
290 decoder->RestoreTextureUnitBindings(0); 278 decoder->RestoreTextureUnitBindings(0);
291 decoder->RestoreActiveTexture(); 279 decoder->RestoreActiveTexture();
292 decoder->RestoreFramebufferBindings(); 280 decoder->RestoreFramebufferBindings();
293 } 281 }
294 282
295 class ScopedStagingTexture {
296 public:
297 ScopedStagingTexture() {
298 glGenTextures(1, &staging_texture_);
299 glBindTexture(GL_TEXTURE_2D, staging_texture_);
300 }
301 ~ScopedStagingTexture() {
302 glDeleteTextures(1, &staging_texture_);
303 staging_texture_ = 0;
304 }
305
306 GLuint texture() const { return staging_texture_; }
307
308 private:
309 GLuint staging_texture_;
310 };
311
312 bool NeedOneCopy(GLenum target,
313 const gpu::gles2::DecoderTextureState* texture_state) {
314 GLenum binding_target =
315 gpu::gles2::GLES2Util::GLTextureTargetToBindingTarget(target);
316
317 if (binding_target != GL_TEXTURE_CUBE_MAP)
318 return false;
319 DCHECK(texture_state);
320
321 // The drivers with |force_cube_complete| or
322 // |force_cube_map_positive_x_allocation| don't guarantee that the FBO binding
323 // cube map texture works.
324 return texture_state->force_cube_complete ||
325 texture_state->force_cube_map_positive_x_allocation;
326 }
327
328 } // namespace 283 } // namespace
329 284
330 namespace gpu { 285 namespace gpu {
331 286
332 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager() 287 CopyTextureCHROMIUMResourceManager::CopyTextureCHROMIUMResourceManager()
333 : initialized_(false), 288 : initialized_(false),
334 vertex_shaders_(NUM_VERTEX_SHADERS, 0u), 289 vertex_shaders_(NUM_VERTEX_SHADERS, 0u),
335 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u), 290 fragment_shaders_(NUM_FRAGMENT_SHADERS, 0u),
336 buffer_id_(0u), 291 buffer_id_(0u),
337 framebuffer_(0u) {} 292 framebuffer_(0u) {}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 342
388 glDeleteBuffersARB(1, &buffer_id_); 343 glDeleteBuffersARB(1, &buffer_id_);
389 buffer_id_ = 0; 344 buffer_id_ = 0;
390 } 345 }
391 346
392 void CopyTextureCHROMIUMResourceManager::DoCopyTexture( 347 void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
393 const gles2::GLES2Decoder* decoder, 348 const gles2::GLES2Decoder* decoder,
394 GLenum source_target, 349 GLenum source_target,
395 GLuint source_id, 350 GLuint source_id,
396 GLenum source_internal_format, 351 GLenum source_internal_format,
397 GLenum dest_target,
398 GLuint dest_id, 352 GLuint dest_id,
399 GLenum dest_internal_format, 353 GLenum dest_internal_format,
400 GLenum dest_type,
401 GLsizei width, 354 GLsizei width,
402 GLsizei height, 355 GLsizei height,
403 bool flip_y, 356 bool flip_y,
404 bool premultiply_alpha, 357 bool premultiply_alpha,
405 bool unpremultiply_alpha, 358 bool unpremultiply_alpha) {
406 const gles2::DecoderTextureState* texture_state) {
407 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 359 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
408 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's 360 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's
409 // format does not contain a superset of the components required by the base 361 // format does not contain a superset of the components required by the base
410 // format of internalformat. 362 // format of internalformat.
411 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml 363 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
412 bool source_format_contain_superset_of_dest_format = 364 bool source_format_contain_superset_of_dest_format =
413 (source_internal_format == dest_internal_format && 365 (source_internal_format == dest_internal_format &&
414 source_internal_format != GL_BGRA_EXT) || 366 source_internal_format != GL_BGRA_EXT) ||
415 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); 367 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB);
416 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, 368 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
417 // so restrict this to GL_TEXTURE_2D. 369 // so restrict this to GL_TEXTURE_2D.
418 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && 370 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
419 source_format_contain_superset_of_dest_format) { 371 source_format_contain_superset_of_dest_format) {
420 DoCopyTexImage2D(decoder, source_target, source_id, dest_target, dest_id, 372 DoCopyTexImage2D(decoder,
421 dest_internal_format, width, height, framebuffer_); 373 source_target,
374 source_id,
375 dest_id,
376 dest_internal_format,
377 width,
378 height,
379 framebuffer_);
422 return; 380 return;
423 } 381 }
424 382
425 // Use kIdentityMatrix if no transform passed in. 383 // Use kIdentityMatrix if no transform passed in.
426 DoCopyTextureWithTransform( 384 DoCopyTextureWithTransform(decoder, source_target, source_id, dest_id, width,
427 decoder, source_target, source_id, dest_target, dest_id, 385 height, flip_y, premultiply_alpha,
428 dest_internal_format, dest_type, width, height, flip_y, premultiply_alpha, 386 unpremultiply_alpha, kIdentityMatrix);
429 unpremultiply_alpha, texture_state, kIdentityMatrix);
430 } 387 }
431 388
432 void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( 389 void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
433 const gles2::GLES2Decoder* decoder, 390 const gles2::GLES2Decoder* decoder,
434 GLenum source_target, 391 GLenum source_target,
435 GLuint source_id, 392 GLuint source_id,
436 GLenum source_internal_format, 393 GLenum source_internal_format,
437 GLenum dest_target,
438 GLuint dest_id, 394 GLuint dest_id,
439 GLenum dest_internal_format, 395 GLenum dest_internal_format,
440 GLenum dest_type,
441 GLint xoffset, 396 GLint xoffset,
442 GLint yoffset, 397 GLint yoffset,
443 GLint x, 398 GLint x,
444 GLint y, 399 GLint y,
445 GLsizei width, 400 GLsizei width,
446 GLsizei height, 401 GLsizei height,
447 GLsizei dest_width, 402 GLsizei dest_width,
448 GLsizei dest_height, 403 GLsizei dest_height,
449 GLsizei source_width, 404 GLsizei source_width,
450 GLsizei source_height, 405 GLsizei source_height,
451 bool flip_y, 406 bool flip_y,
452 bool premultiply_alpha, 407 bool premultiply_alpha,
453 bool unpremultiply_alpha, 408 bool unpremultiply_alpha) {
454 const gles2::DecoderTextureState* texture_state) {
455 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 409 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
456 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's 410 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's
457 // format does not contain a superset of the components required by the base 411 // format does not contain a superset of the components required by the base
458 // format of internalformat. 412 // format of internalformat.
459 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml 413 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
460 bool source_format_contain_superset_of_dest_format = 414 bool source_format_contain_superset_of_dest_format =
461 (source_internal_format == dest_internal_format && 415 (source_internal_format == dest_internal_format &&
462 source_internal_format != GL_BGRA_EXT) || 416 source_internal_format != GL_BGRA_EXT) ||
463 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); 417 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB);
464 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, 418 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
465 // so restrict this to GL_TEXTURE_2D. 419 // so restrict this to GL_TEXTURE_2D.
466 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && 420 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
467 source_format_contain_superset_of_dest_format) { 421 source_format_contain_superset_of_dest_format) {
468 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_target, dest_id, 422 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset,
469 xoffset, yoffset, x, y, width, height, framebuffer_); 423 yoffset, x, y, width, height, framebuffer_);
470 return; 424 return;
471 } 425 }
472 426
473 if (NeedOneCopy(dest_target, texture_state)) { 427 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset,
474 ScopedStagingTexture staging_texture; 428 yoffset, x, y, width, height, dest_width, dest_height,
475 glTexImage2D(GL_TEXTURE_2D, 0, dest_internal_format, width, height, 0, 429 source_width, source_height, flip_y, premultiply_alpha,
476 dest_internal_format, dest_type, nullptr); 430 unpremultiply_alpha, kIdentityMatrix);
477 DoCopyTextureInternal(decoder, source_target, source_id, GL_TEXTURE_2D,
478 staging_texture.texture(), 0, 0, x, y, width, height,
479 width, height, source_width, source_height, flip_y,
480 premultiply_alpha, unpremultiply_alpha,
481 kIdentityMatrix);
482 DoCopyTexSubImage2D(decoder, GL_TEXTURE_2D, staging_texture.texture(),
483 dest_target, dest_id, xoffset, yoffset, 0, 0, width,
484 height, framebuffer_);
485 return;
486 }
487
488 DoCopyTextureInternal(
489 decoder, source_target, source_id, dest_target, dest_id, xoffset, yoffset,
490 x, y, width, height, dest_width, dest_height, source_width, source_height,
491 flip_y, premultiply_alpha, unpremultiply_alpha, kIdentityMatrix);
492 } 431 }
493 432
494 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( 433 void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
495 const gles2::GLES2Decoder* decoder, 434 const gles2::GLES2Decoder* decoder,
496 GLenum source_target, 435 GLenum source_target,
497 GLuint source_id, 436 GLuint source_id,
498 GLenum dest_target,
499 GLuint dest_id, 437 GLuint dest_id,
500 GLenum dest_internal_format,
501 GLenum dest_type,
502 GLsizei width, 438 GLsizei width,
503 GLsizei height, 439 GLsizei height,
504 bool flip_y, 440 bool flip_y,
505 bool premultiply_alpha, 441 bool premultiply_alpha,
506 bool unpremultiply_alpha, 442 bool unpremultiply_alpha,
507 const gles2::DecoderTextureState* texture_state,
508 const GLfloat transform_matrix[16]) { 443 const GLfloat transform_matrix[16]) {
509 GLsizei dest_width = width; 444 GLsizei dest_width = width;
510 GLsizei dest_height = height; 445 GLsizei dest_height = height;
511 446 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, 0, 0, 0, 0,
512 if (NeedOneCopy(dest_target, texture_state)) { 447 width, height, dest_width, dest_height, width, height,
513 // The |dest_id| texture cannot be bound to FBO. Create a staging 448 flip_y, premultiply_alpha, unpremultiply_alpha,
514 // GL_TEXTURE_2D texture, and copy the source texture to the staging 449 transform_matrix);
515 // texture, and copy the staging texture to the dest texture.
516 ScopedStagingTexture staging_texture;
517 glTexImage2D(GL_TEXTURE_2D, 0, dest_internal_format, width, height, 0,
518 dest_internal_format, dest_type, nullptr);
519 DoCopyTextureInternal(decoder, source_target, source_id, GL_TEXTURE_2D,
520 staging_texture.texture(), 0, 0, 0, 0, width, height,
521 width, height, width, height, flip_y,
522 premultiply_alpha, unpremultiply_alpha,
523 transform_matrix);
524 DoCopyTexImage2D(decoder, GL_TEXTURE_2D, staging_texture.texture(),
525 dest_target, dest_id, dest_internal_format, width, height,
526 framebuffer_);
527 return;
528 }
529
530 DoCopyTextureInternal(decoder, source_target, source_id, dest_target, dest_id,
531 0, 0, 0, 0, width, height, dest_width, dest_height,
532 width, height, flip_y, premultiply_alpha,
533 unpremultiply_alpha, transform_matrix);
534 } 450 }
535 451
536 void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal( 452 void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal(
537 const gles2::GLES2Decoder* decoder, 453 const gles2::GLES2Decoder* decoder,
538 GLenum source_target, 454 GLenum source_target,
539 GLuint source_id, 455 GLuint source_id,
540 GLenum dest_target,
541 GLuint dest_id, 456 GLuint dest_id,
542 GLint xoffset, 457 GLint xoffset,
543 GLint yoffset, 458 GLint yoffset,
544 GLint x, 459 GLint x,
545 GLint y, 460 GLint y,
546 GLsizei width, 461 GLsizei width,
547 GLsizei height, 462 GLsizei height,
548 GLsizei dest_width, 463 GLsizei dest_width,
549 GLsizei dest_height, 464 GLsizei dest_height,
550 GLsizei source_width, 465 GLsizei source_width,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 // Pass translation to the shader program. 537 // Pass translation to the shader program.
623 glUniform2f(info->vertex_translate_handle, x_translate_on_vertex, 538 glUniform2f(info->vertex_translate_handle, x_translate_on_vertex,
624 y_translate_on_vertex); 539 y_translate_on_vertex);
625 } 540 }
626 if (source_target == GL_TEXTURE_RECTANGLE_ARB) 541 if (source_target == GL_TEXTURE_RECTANGLE_ARB)
627 glUniform2f(info->half_size_handle, source_width / 2.0f, 542 glUniform2f(info->half_size_handle, source_width / 2.0f,
628 source_height / 2.0f); 543 source_height / 2.0f);
629 else 544 else
630 glUniform2f(info->half_size_handle, 0.5f, 0.5f); 545 glUniform2f(info->half_size_handle, 0.5f, 0.5f);
631 546
632 if (BindFramebufferTexture2D(dest_target, dest_id, framebuffer_)) { 547 if (BindFramebufferTexture2D(GL_TEXTURE_2D, dest_id, framebuffer_)) {
633 #ifndef NDEBUG 548 #ifndef NDEBUG
634 // glValidateProgram of MACOSX validates FBO unlike other platforms, so 549 // glValidateProgram of MACOSX validates FBO unlike other platforms, so
635 // glValidateProgram must be called after FBO binding. crbug.com/463439 550 // glValidateProgram must be called after FBO binding. crbug.com/463439
636 glValidateProgram(info->program); 551 glValidateProgram(info->program);
637 GLint validation_status; 552 GLint validation_status;
638 glGetProgramiv(info->program, GL_VALIDATE_STATUS, &validation_status); 553 glGetProgramiv(info->program, GL_VALIDATE_STATUS, &validation_status);
639 if (GL_TRUE != validation_status) { 554 if (GL_TRUE != validation_status) {
640 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader."; 555 DLOG(ERROR) << "CopyTextureCHROMIUM: Invalid shader.";
641 return; 556 return;
642 } 557 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 decoder->RestoreTextureState(dest_id); 594 decoder->RestoreTextureState(dest_id);
680 decoder->RestoreTextureUnitBindings(0); 595 decoder->RestoreTextureUnitBindings(0);
681 decoder->RestoreActiveTexture(); 596 decoder->RestoreActiveTexture();
682 decoder->RestoreProgramBindings(); 597 decoder->RestoreProgramBindings();
683 decoder->RestoreBufferBindings(); 598 decoder->RestoreBufferBindings();
684 decoder->RestoreFramebufferBindings(); 599 decoder->RestoreFramebufferBindings();
685 decoder->RestoreGlobalState(); 600 decoder->RestoreGlobalState();
686 } 601 }
687 602
688 } // namespace gpu 603 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698