diff options
author | hkuang@chromium.org <hkuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 23:32:56 +0000 |
---|---|---|
committer | hkuang@chromium.org <hkuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 23:32:56 +0000 |
commit | 377976552d6004d97c0a26fe920df5f13b3d13c5 (patch) | |
tree | a97e1e4dd5b1adf1678f8d449bbd7c248389ec69 /gpu | |
parent | 0602fad8350075b6e7440b7844fc44d652a70352 (diff) | |
download | chromium_src-377976552d6004d97c0a26fe920df5f13b3d13c5.zip chromium_src-377976552d6004d97c0a26fe920df5f13b3d13c5.tar.gz chromium_src-377976552d6004d97c0a26fe920df5f13b3d13c5.tar.bz2 |
Add getSize for StreamTexture.
BUG=225781
TEST=visited the following site:
http://html5doctor.com/demos/video-canvas-magic/demo1.html
Visit http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_drawimage_video.
Canvas painting still works.
Review URL: https://chromiumcodereview.appspot.com/14787012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 46 | ||||
-rw-r--r-- | gpu/command_buffer/service/stream_texture.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/service/stream_texture_mock.h | 1 |
3 files changed, 27 insertions, 24 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index b0823b1..33f10bf 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -9578,15 +9578,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( int source_width, source_height, dest_width, dest_height; - // When the source texture is GL_TEXTURE_EXTERNAL_OES, we assume width - // and height are the same as destination texture. The caller needs to - // make sure they allocate a destination texture which is the same size - // as the source. This is due to the limitation of the StreamTexture. - // There is no way to find out the size of the texture from the GL consumer - // side. But StreamTextures are unique per video stream and should never - // change, so we could find out the size of the video stream and allocate - // a equal size RGBA texture for copy. TODO(hkuang): Add support to get - // width/height of StreamTexture crbug.com/225781. if (source_texture->target() == GL_TEXTURE_2D) { if (!source_texture->GetLevelSize(GL_TEXTURE_2D, 0, &source_width, &source_height)) { @@ -9606,6 +9597,28 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( } } + if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { + DCHECK(stream_texture_manager_); + StreamTexture* stream_tex = + stream_texture_manager_->LookupStreamTexture( + source_texture->service_id()); + if (!stream_tex) { + LOCAL_SET_GL_ERROR( + GL_INVALID_VALUE, + "glCopyTextureChromium", "Stream texture lookup failed"); + return; + } + gfx::Size size = stream_tex->GetSize(); + source_width = size.width(); + source_height = size.height(); + if (source_width <= 0 || source_height <= 0) { + LOCAL_SET_GL_ERROR( + GL_INVALID_VALUE, + "glCopyTextureChromium", "invalid streamtexture size"); + return; + } + } + // Defer initializing the CopyTextureCHROMIUMResourceManager until it is // needed because it takes 10s of milliseconds to initialize. if (!copy_texture_CHROMIUM_.get()) { @@ -9627,21 +9640,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( &dest_internal_format); } - // Set source texture's width and height to be the same as - // destination texture when source is GL_TEXTURE_EXTERNAL_OES. - // TODO(hkuang): Add support to get width/height of StreamTexture - // crbug.com/225781. - if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { - if (!dest_level_defined) { - LOCAL_SET_GL_ERROR( - GL_INVALID_VALUE, - "glCopyTextureCHROMIUM", "destination level not defined"); - return; - } - source_width = dest_width; - source_height = dest_height; - } - // Resize the destination texture to the dimensions of the source texture. if (!dest_level_defined || dest_width != source_width || dest_height != source_height || diff --git a/gpu/command_buffer/service/stream_texture.h b/gpu/command_buffer/service/stream_texture.h index 72d6a08..bcddc82 100644 --- a/gpu/command_buffer/service/stream_texture.h +++ b/gpu/command_buffer/service/stream_texture.h @@ -6,6 +6,7 @@ #define GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_H_ #include "base/basictypes.h" +#include "ui/gfx/size.h" namespace gpu { @@ -19,6 +20,9 @@ class StreamTexture { virtual void Update() = 0; + // Get the size of the StreamTexture. + virtual gfx::Size GetSize() = 0; + private: DISALLOW_COPY_AND_ASSIGN(StreamTexture); }; diff --git a/gpu/command_buffer/service/stream_texture_mock.h b/gpu/command_buffer/service/stream_texture_mock.h index 44e3a98..cd951d2 100644 --- a/gpu/command_buffer/service/stream_texture_mock.h +++ b/gpu/command_buffer/service/stream_texture_mock.h @@ -17,6 +17,7 @@ class MockStreamTexture : public StreamTexture { virtual ~MockStreamTexture(); MOCK_METHOD0(Update, void()); + MOCK_METHOD0(GetSize, gfx::Size(void)); private: DISALLOW_COPY_AND_ASSIGN(MockStreamTexture); |