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

Side by Side Diff: media/renderers/skcanvas_video_renderer.cc

Issue 2639973002: Add target argument to Copy{Sub}TextureCHROMIUM entry point (Closed)
Patch Set: use dest_target instead of target Created 3 years, 11 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 "media/renderers/skcanvas_video_renderer.h" 5 #include "media/renderers/skcanvas_video_renderer.h"
6 6
7 #include <GLES3/gl3.h> 7 #include <GLES3/gl3.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 source_textures[i].fTarget = mailbox_holder.texture_target; 113 source_textures[i].fTarget = mailbox_holder.texture_target;
114 114
115 // TODO(dcastagna): avoid this copy once Skia supports native textures 115 // TODO(dcastagna): avoid this copy once Skia supports native textures
116 // with a GL_TEXTURE_RECTANGLE_ARB texture target. 116 // with a GL_TEXTURE_RECTANGLE_ARB texture target.
117 // crbug.com/505026 117 // crbug.com/505026
118 if (mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB) { 118 if (mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB) {
119 unsigned texture_copy = 0; 119 unsigned texture_copy = 0;
120 gl->GenTextures(1, &texture_copy); 120 gl->GenTextures(1, &texture_copy);
121 DCHECK(texture_copy); 121 DCHECK(texture_copy);
122 gl->BindTexture(GL_TEXTURE_2D, texture_copy); 122 gl->BindTexture(GL_TEXTURE_2D, texture_copy);
123 gl->CopyTextureCHROMIUM(source_textures[i].fID, 0, texture_copy, 0, 123 gl->CopyTextureCHROMIUM(source_textures[i].fID, 0, GL_TEXTURE_2D,
124 GL_RGB, GL_UNSIGNED_BYTE, false, true, false); 124 texture_copy, 0, GL_RGB, GL_UNSIGNED_BYTE, false,
125 true, false);
125 126
126 gl->DeleteTextures(1, &source_textures[i].fID); 127 gl->DeleteTextures(1, &source_textures[i].fID);
127 source_textures[i].fID = texture_copy; 128 source_textures[i].fID = texture_copy;
128 source_textures[i].fTarget = GL_TEXTURE_2D; 129 source_textures[i].fTarget = GL_TEXTURE_2D;
129 } 130 }
130 } 131 }
131 GrBackendObject handles[3] = { 132 GrBackendObject handles[3] = {
132 skia::GrGLTextureInfoToGrBackendObject(source_textures[0]), 133 skia::GrGLTextureInfoToGrBackendObject(source_textures[0]),
133 skia::GrGLTextureInfoToGrBackendObject(source_textures[1]), 134 skia::GrGLTextureInfoToGrBackendObject(source_textures[1]),
134 skia::GrGLTextureInfoToGrBackendObject(source_textures[2])}; 135 skia::GrGLTextureInfoToGrBackendObject(source_textures[2])};
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 // Application itself needs to take care of setting the right |flip_y| 777 // Application itself needs to take care of setting the right |flip_y|
777 // value down to get the expected result. 778 // value down to get the expected result.
778 // "flip_y == true" means to reverse the video orientation while 779 // "flip_y == true" means to reverse the video orientation while
779 // "flip_y == false" means to keep the intrinsic orientation. 780 // "flip_y == false" means to keep the intrinsic orientation.
780 781
781 // The video's texture might be larger than the natural size because 782 // The video's texture might be larger than the natural size because
782 // the encoder might have had to round up to the size of a macroblock. 783 // the encoder might have had to round up to the size of a macroblock.
783 // Make sure to only copy the natural size to avoid putting garbage 784 // Make sure to only copy the natural size to avoid putting garbage
784 // into the bottom of the destination texture. 785 // into the bottom of the destination texture.
785 const gfx::Size& natural_size = video_frame->natural_size(); 786 const gfx::Size& natural_size = video_frame->natural_size();
786 gl->CopySubTextureCHROMIUM(source_texture, 0, texture, 0, 0, 0, 0, 0, 787 gl->CopySubTextureCHROMIUM(source_texture, 0, GL_TEXTURE_2D, texture, 0, 0, 0,
787 natural_size.width(), natural_size.height(), 788 0, 0, natural_size.width(), natural_size.height(),
788 flip_y, premultiply_alpha, false); 789 flip_y, premultiply_alpha, false);
789 gl->DeleteTextures(1, &source_texture); 790 gl->DeleteTextures(1, &source_texture);
790 gl->Flush(); 791 gl->Flush();
791 792
792 SyncTokenClientImpl client(gl); 793 SyncTokenClientImpl client(gl);
793 video_frame->UpdateReleaseSyncToken(&client); 794 video_frame->UpdateReleaseSyncToken(&client);
794 } 795 }
795 796
796 bool SkCanvasVideoRenderer::CopyVideoFrameTexturesToGLTexture( 797 bool SkCanvasVideoRenderer::CopyVideoFrameTexturesToGLTexture(
797 const Context3D& context_3d, 798 const Context3D& context_3d,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 uint32_t intermediate_texture = 834 uint32_t intermediate_texture =
834 destination_gl->CreateAndConsumeTextureCHROMIUM( 835 destination_gl->CreateAndConsumeTextureCHROMIUM(
835 mailbox_holder.texture_target, mailbox_holder.mailbox.name); 836 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
836 837
837 // The video's texture might be larger than the natural size because 838 // The video's texture might be larger than the natural size because
838 // the encoder might have had to round up to the size of a macroblock. 839 // the encoder might have had to round up to the size of a macroblock.
839 // Make sure to only copy the natural size to avoid putting garbage 840 // Make sure to only copy the natural size to avoid putting garbage
840 // into the bottom of the destination texture. 841 // into the bottom of the destination texture.
841 const gfx::Size& natural_size = video_frame->natural_size(); 842 const gfx::Size& natural_size = video_frame->natural_size();
842 destination_gl->CopySubTextureCHROMIUM( 843 destination_gl->CopySubTextureCHROMIUM(
843 intermediate_texture, 0, texture, 0, 0, 0, 0, 0, natural_size.width(), 844 intermediate_texture, 0, GL_TEXTURE_2D, texture, 0, 0, 0, 0, 0,
844 natural_size.height(), flip_y, premultiply_alpha, false); 845 natural_size.width(), natural_size.height(), flip_y, premultiply_alpha,
846 false);
845 destination_gl->DeleteTextures(1, &intermediate_texture); 847 destination_gl->DeleteTextures(1, &intermediate_texture);
846 848
847 // Wait for destination context to consume mailbox before deleting it in 849 // Wait for destination context to consume mailbox before deleting it in
848 // canvas context. 850 // canvas context.
849 const GLuint64 dest_fence_sync = destination_gl->InsertFenceSyncCHROMIUM(); 851 const GLuint64 dest_fence_sync = destination_gl->InsertFenceSyncCHROMIUM();
850 destination_gl->ShallowFlushCHROMIUM(); 852 destination_gl->ShallowFlushCHROMIUM();
851 gpu::SyncToken dest_sync_token; 853 gpu::SyncToken dest_sync_token;
852 destination_gl->GenSyncTokenCHROMIUM(dest_fence_sync, 854 destination_gl->GenSyncTokenCHROMIUM(dest_fence_sync,
853 dest_sync_token.GetData()); 855 dest_sync_token.GetData());
854 canvas_gl->WaitSyncTokenCHROMIUM(dest_sync_token.GetConstData()); 856 canvas_gl->WaitSyncTokenCHROMIUM(dest_sync_token.GetConstData());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 last_image_->bounds().contains(visible_rect)) { 960 last_image_->bounds().contains(visible_rect)) {
959 last_image_ = last_image_->makeSubset(visible_rect); 961 last_image_ = last_image_->makeSubset(visible_rect);
960 } 962 }
961 } 963 }
962 964
963 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() { 965 SkISize SkCanvasVideoRenderer::LastImageDimensionsForTesting() {
964 return last_image_dimensions_for_testing_; 966 return last_image_dimensions_for_testing_;
965 } 967 }
966 968
967 } // namespace media 969 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698