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

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

Issue 1746983002: Make Android StreamTexture implement GLStreamTextureImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call UpdateTexImage before fetching the surface texture matrix Created 4 years, 9 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_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 13791 matching lines...) Expand 10 before | Expand all | Expand 10 after
13802 bool unpack_premultiply_alpha_change = 13802 bool unpack_premultiply_alpha_change =
13803 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 13803 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
13804 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 13804 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
13805 glBindTexture(dest_target, dest_texture->service_id()); 13805 glBindTexture(dest_target, dest_texture->service_id());
13806 if (image->CopyTexImage(dest_target)) 13806 if (image->CopyTexImage(dest_target))
13807 return; 13807 return;
13808 } 13808 }
13809 13809
13810 DoCopyTexImageIfNeeded(source_texture, source_target); 13810 DoCopyTexImageIfNeeded(source_texture, source_target);
13811 13811
13812 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13812 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix
13813 // before presenting. 13813 // before presenting.
13814 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 13814 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
13815 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13816 // instead of using kIdentityMatrix crbug.com/226218. AVDACodecImage does
13817 // this correctly, but others (e.g., stream_texture_android.cc) don't.
13818 // (crbug.com/371500, crbug.com/588837)
13819 GLfloat transform_matrix[16];
13820 memcpy(transform_matrix, kIdentityMatrix, sizeof(transform_matrix));
13821 if (GLStreamTextureImage* image = 13815 if (GLStreamTextureImage* image =
no sievers 2016/03/18 01:34:11 nit: merge ifs
13822 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 13816 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
13823 0)) { 13817 0)) {
13824 image->GetTextureMatrix(transform_matrix); 13818 // The coordinate system of this matrix is y-up, not y-down, so a flip is
13819 // needed.
13820 GLfloat transform_matrix[16];
13821 image->GetFlippedTextureMatrix(transform_matrix);
13822 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13823 this, source_target, source_texture->service_id(), dest_target,
13824 dest_texture->service_id(), source_width, source_height,
13825 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
13826 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
13827 return;
13825 } 13828 }
13826 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13827 this, source_target, source_texture->service_id(), dest_target,
13828 dest_texture->service_id(), source_width, source_height,
13829 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
13830 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
13831 } else {
13832 copy_texture_CHROMIUM_->DoCopyTexture(
13833 this, source_target, source_texture->service_id(),
13834 source_internal_format, dest_target, dest_texture->service_id(),
13835 internal_format, source_width, source_height,
13836 unpack_flip_y == GL_TRUE,
13837 unpack_premultiply_alpha == GL_TRUE,
13838 unpack_unmultiply_alpha == GL_TRUE);
13839 } 13829 }
13830 copy_texture_CHROMIUM_->DoCopyTexture(
13831 this, source_target, source_texture->service_id(), source_internal_format,
13832 dest_target, dest_texture->service_id(), internal_format, source_width,
13833 source_height, unpack_flip_y == GL_TRUE,
13834 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE);
13840 } 13835 }
13841 13836
13842 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 13837 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
13843 GLuint source_id, 13838 GLuint source_id,
13844 GLuint dest_id, 13839 GLuint dest_id,
13845 GLint xoffset, 13840 GLint xoffset,
13846 GLint yoffset, 13841 GLint yoffset,
13847 GLint x, 13842 GLint x,
13848 GLint y, 13843 GLint y,
13849 GLsizei width, 13844 GLsizei width,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
14000 ScopedTextureBinder binder( 13995 ScopedTextureBinder binder(
14001 &state_, dest_texture->service_id(), dest_target); 13996 &state_, dest_texture->service_id(), dest_target);
14002 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), 13997 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset),
14003 gfx::Rect(x, y, width, height))) { 13998 gfx::Rect(x, y, width, height))) {
14004 return; 13999 return;
14005 } 14000 }
14006 } 14001 }
14007 14002
14008 DoCopyTexImageIfNeeded(source_texture, source_target); 14003 DoCopyTexImageIfNeeded(source_texture, source_target);
14009 14004
14010 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 14005
14011 // crbug.com/226218. 14006 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
14007 // before presenting.
14008 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
14009 if (GLStreamTextureImage* image =
no sievers 2016/03/18 01:34:11 nit: merge ifs
Tobias Sargeant 2016/03/18 10:30:13 The inner if declares and assigns |image|, so it c
14010 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
14011 0)) {
14012 // The coordinate system of this matrix is y-up, not y-down, so a flip is
14013 // needed.
14014 GLfloat transform_matrix[16];
14015 image->GetFlippedTextureMatrix(transform_matrix);
14016 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
14017 this, source_target, source_texture->service_id(),
14018 source_internal_format, dest_target, dest_texture->service_id(),
14019 dest_internal_format, xoffset, yoffset, x, y, width, height,
14020 dest_width, dest_height, source_width, source_height,
14021 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
14022 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
14023 return;
14024 }
14025 }
14012 copy_texture_CHROMIUM_->DoCopySubTexture( 14026 copy_texture_CHROMIUM_->DoCopySubTexture(
14013 this, source_target, source_texture->service_id(), source_internal_format, 14027 this, source_target, source_texture->service_id(), source_internal_format,
14014 dest_target, dest_texture->service_id(), dest_internal_format, 14028 dest_target, dest_texture->service_id(), dest_internal_format, xoffset,
14015 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 14029 yoffset, x, y, width, height, dest_width, dest_height, source_width,
14016 source_width, source_height, 14030 source_height, unpack_flip_y == GL_TRUE,
14017 unpack_flip_y == GL_TRUE, 14031 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE);
14018 unpack_premultiply_alpha == GL_TRUE,
14019 unpack_unmultiply_alpha == GL_TRUE);
14020 } 14032 }
14021 14033
14022 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLuint source_id, 14034 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLuint source_id,
14023 GLuint dest_id) { 14035 GLuint dest_id) {
14024 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM"); 14036 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM");
14025 14037
14026 TextureRef* source_texture_ref = GetTexture(source_id); 14038 TextureRef* source_texture_ref = GetTexture(source_id);
14027 TextureRef* dest_texture_ref = GetTexture(dest_id); 14039 TextureRef* dest_texture_ref = GetTexture(dest_id);
14028 14040
14029 if (!source_texture_ref || !dest_texture_ref) { 14041 if (!source_texture_ref || !dest_texture_ref) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
14170 if (error != GL_NO_ERROR) { 14182 if (error != GL_NO_ERROR) {
14171 RestoreCurrentTextureBindings(&state_, dest_texture->target()); 14183 RestoreCurrentTextureBindings(&state_, dest_texture->target());
14172 return; 14184 return;
14173 } 14185 }
14174 14186
14175 texture_manager()->SetLevelInfo( 14187 texture_manager()->SetLevelInfo(
14176 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, 14188 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width,
14177 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 14189 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
14178 gfx::Rect(source_width, source_height)); 14190 gfx::Rect(source_width, source_height));
14179 14191
14180 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 14192 copy_texture_CHROMIUM_->DoCopyTexture(
14181 // before presenting. 14193 this, source_texture->target(), source_texture->service_id(),
14182 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 14194 source_internal_format, dest_texture->target(),
14183 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 14195 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
14184 // instead of using kIdentityMatrix crbug.com/226218. 14196 false, false);
14185 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
14186 this, source_texture->target(), source_texture->service_id(),
14187 dest_texture->target(), dest_texture->service_id(), source_width,
14188 source_height, false, false, false, kIdentityMatrix);
14189 } else {
14190 copy_texture_CHROMIUM_->DoCopyTexture(
14191 this, source_texture->target(), source_texture->service_id(),
14192 source_internal_format, dest_texture->target(),
14193 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
14194 false, false);
14195 }
14196 } 14197 }
14197 14198
14198 void GLES2DecoderImpl::DoTexStorage2DEXT( 14199 void GLES2DecoderImpl::DoTexStorage2DEXT(
14199 GLenum target, 14200 GLenum target,
14200 GLint levels, 14201 GLint levels,
14201 GLenum internal_format, 14202 GLenum internal_format,
14202 GLsizei width, 14203 GLsizei width,
14203 GLsizei height) { 14204 GLsizei height) {
14204 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT", 14205 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT",
14205 "width", width, "height", height); 14206 "width", width, "height", height);
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
16251 } 16252 }
16252 16253
16253 // Include the auto-generated part of this file. We split this because it means 16254 // Include the auto-generated part of this file. We split this because it means
16254 // we can easily edit the non-auto generated parts right here in this file 16255 // we can easily edit the non-auto generated parts right here in this file
16255 // instead of having to edit some template or the code generator. 16256 // instead of having to edit some template or the code generator.
16256 #include "base/macros.h" 16257 #include "base/macros.h"
16257 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16258 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16258 16259
16259 } // namespace gles2 16260 } // namespace gles2
16260 } // namespace gpu 16261 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698