| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 686 if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 687 // It's possible that the drawing buffer allocation provokes a context loss, | 687 // It's possible that the drawing buffer allocation provokes a context loss, |
| 688 // so check again just in case. http://crbug.com/512302 | 688 // so check again just in case. http://crbug.com/512302 |
| 689 return false; | 689 return false; |
| 690 } | 690 } |
| 691 | 691 |
| 692 return true; | 692 return true; |
| 693 } | 693 } |
| 694 | 694 |
| 695 bool DrawingBuffer::CopyToPlatformTexture(gpu::gles2::GLES2Interface* gl, | 695 bool DrawingBuffer::CopyToPlatformTexture(gpu::gles2::GLES2Interface* gl, |
| 696 GLenum texture_target, |
| 696 GLuint texture, | 697 GLuint texture, |
| 697 GLenum internal_format, | |
| 698 GLenum dest_type, | |
| 699 GLint level, | |
| 700 bool premultiply_alpha, | 698 bool premultiply_alpha, |
| 701 bool flip_y, | 699 bool flip_y, |
| 702 const IntPoint& dest_texture_offset, | 700 const IntPoint& dest_texture_offset, |
| 703 const IntRect& source_sub_rectangle, | 701 const IntRect& source_sub_rectangle, |
| 704 SourceDrawingBuffer source_buffer) { | 702 SourceDrawingBuffer source_buffer) { |
| 705 ScopedStateRestorer scoped_state_restorer(this); | 703 ScopedStateRestorer scoped_state_restorer(this); |
| 706 | 704 |
| 707 if (contents_changed_) { | 705 if (contents_changed_) { |
| 708 ResolveIfNeeded(); | 706 ResolveIfNeeded(); |
| 709 gl_->Flush(); | 707 gl_->Flush(); |
| 710 } | 708 } |
| 711 | 709 |
| 712 // Assume that the destination target is GL_TEXTURE_2D. | 710 if (!Extensions3DUtil::CanUseCopyTextureCHROMIUM(texture_target)) |
| 713 if (!Extensions3DUtil::CanUseCopyTextureCHROMIUM( | |
| 714 GL_TEXTURE_2D, internal_format, dest_type, level)) | |
| 715 return false; | 711 return false; |
| 716 | 712 |
| 717 // Contexts may be in a different share group. We must transfer the texture | 713 // Contexts may be in a different share group. We must transfer the texture |
| 718 // through a mailbox first. | 714 // through a mailbox first. |
| 719 GLenum target = 0; | 715 GLenum target = 0; |
| 720 gpu::Mailbox mailbox; | 716 gpu::Mailbox mailbox; |
| 721 gpu::SyncToken produce_sync_token; | 717 gpu::SyncToken produce_sync_token; |
| 722 if (source_buffer == kFrontBuffer && front_color_buffer_) { | 718 if (source_buffer == kFrontBuffer && front_color_buffer_) { |
| 723 target = front_color_buffer_->parameters.target; | 719 target = front_color_buffer_->parameters.target; |
| 724 mailbox = front_color_buffer_->mailbox; | 720 mailbox = front_color_buffer_->mailbox; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 743 gl->CreateAndConsumeTextureCHROMIUM(target, mailbox.name); | 739 gl->CreateAndConsumeTextureCHROMIUM(target, mailbox.name); |
| 744 | 740 |
| 745 GLboolean unpack_premultiply_alpha_needed = GL_FALSE; | 741 GLboolean unpack_premultiply_alpha_needed = GL_FALSE; |
| 746 GLboolean unpack_unpremultiply_alpha_needed = GL_FALSE; | 742 GLboolean unpack_unpremultiply_alpha_needed = GL_FALSE; |
| 747 if (want_alpha_channel_ && premultiplied_alpha_ && !premultiply_alpha) | 743 if (want_alpha_channel_ && premultiplied_alpha_ && !premultiply_alpha) |
| 748 unpack_unpremultiply_alpha_needed = GL_TRUE; | 744 unpack_unpremultiply_alpha_needed = GL_TRUE; |
| 749 else if (want_alpha_channel_ && !premultiplied_alpha_ && premultiply_alpha) | 745 else if (want_alpha_channel_ && !premultiplied_alpha_ && premultiply_alpha) |
| 750 unpack_premultiply_alpha_needed = GL_TRUE; | 746 unpack_premultiply_alpha_needed = GL_TRUE; |
| 751 | 747 |
| 752 gl->CopySubTextureCHROMIUM( | 748 gl->CopySubTextureCHROMIUM( |
| 753 source_texture, 0, GL_TEXTURE_2D, texture, 0, dest_texture_offset.X(), | 749 source_texture, 0, texture_target, texture, 0, dest_texture_offset.X(), |
| 754 dest_texture_offset.Y(), source_sub_rectangle.X(), | 750 dest_texture_offset.Y(), source_sub_rectangle.X(), |
| 755 source_sub_rectangle.Y(), source_sub_rectangle.Width(), | 751 source_sub_rectangle.Y(), source_sub_rectangle.Width(), |
| 756 source_sub_rectangle.Height(), flip_y, unpack_premultiply_alpha_needed, | 752 source_sub_rectangle.Height(), flip_y, unpack_premultiply_alpha_needed, |
| 757 unpack_unpremultiply_alpha_needed); | 753 unpack_unpremultiply_alpha_needed); |
| 758 | 754 |
| 759 gl->DeleteTextures(1, &source_texture); | 755 gl->DeleteTextures(1, &source_texture); |
| 760 | 756 |
| 761 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 757 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 762 | 758 |
| 763 gl->Flush(); | 759 gl->Flush(); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 if (pixel_unpack_buffer_binding_dirty_) | 1301 if (pixel_unpack_buffer_binding_dirty_) |
| 1306 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); | 1302 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); |
| 1307 } | 1303 } |
| 1308 | 1304 |
| 1309 bool DrawingBuffer::ShouldUseChromiumImage() { | 1305 bool DrawingBuffer::ShouldUseChromiumImage() { |
| 1310 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1306 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
| 1311 chromium_image_usage_ == kAllowChromiumImage; | 1307 chromium_image_usage_ == kAllowChromiumImage; |
| 1312 } | 1308 } |
| 1313 | 1309 |
| 1314 } // namespace blink | 1310 } // namespace blink |
| OLD | NEW |