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

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

Issue 24152009: Allow rendering from non-stream GL_TEXTURE_EXTERNAL_OES (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: eead63fe Rebase. Created 7 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_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 9628 matching lines...) Expand 10 before | Expand all | Expand 10 after
9639 LOCAL_SET_GL_ERROR( 9639 LOCAL_SET_GL_ERROR(
9640 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target"); 9640 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target");
9641 return; 9641 return;
9642 } 9642 }
9643 9643
9644 Texture* source_texture = source_texture_ref->texture(); 9644 Texture* source_texture = source_texture_ref->texture();
9645 Texture* dest_texture = dest_texture_ref->texture(); 9645 Texture* dest_texture = dest_texture_ref->texture();
9646 if (dest_texture->target() != GL_TEXTURE_2D || 9646 if (dest_texture->target() != GL_TEXTURE_2D ||
9647 (source_texture->target() != GL_TEXTURE_2D && 9647 (source_texture->target() != GL_TEXTURE_2D &&
9648 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 9648 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
9649 LOCAL_SET_GL_ERROR( 9649 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
9650 GL_INVALID_VALUE, 9650 "glCopyTextureCHROMIUM",
9651 "glCopyTextureCHROMIUM", "invalid texture target binding"); 9651 "invalid texture target binding");
9652 return; 9652 return;
9653 } 9653 }
9654 9654
9655 int source_width, source_height, dest_width, dest_height; 9655 int source_width, source_height, dest_width, dest_height;
9656 9656
9657 if (source_texture->target() == GL_TEXTURE_2D) { 9657 if (source_texture->IsStreamTexture()) {
9658 if (!source_texture->GetLevelSize(GL_TEXTURE_2D, 0, &source_width, 9658 DCHECK_EQ(source_texture->target(),
9659 &source_height)) { 9659 static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES));
9660 LOCAL_SET_GL_ERROR(
9661 GL_INVALID_VALUE,
9662 "glCopyTextureChromium", "source texture has no level 0");
9663 return;
9664 }
9665
9666 // Check that this type of texture is allowed.
9667 if (!texture_manager()->ValidForTarget(GL_TEXTURE_2D, level, source_width,
9668 source_height, 1)) {
9669 LOCAL_SET_GL_ERROR(
9670 GL_INVALID_VALUE,
9671 "glCopyTextureCHROMIUM", "Bad dimensions");
9672 return;
9673 }
9674 }
9675
9676 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
9677 DCHECK(stream_texture_manager()); 9660 DCHECK(stream_texture_manager());
9678 StreamTexture* stream_tex = 9661 StreamTexture* stream_tex =
9679 stream_texture_manager()->LookupStreamTexture( 9662 stream_texture_manager()->LookupStreamTexture(
9680 source_texture->service_id()); 9663 source_texture->service_id());
9681 if (!stream_tex) { 9664 if (!stream_tex) {
9682 LOCAL_SET_GL_ERROR( 9665 LOCAL_SET_GL_ERROR(
9683 GL_INVALID_VALUE, 9666 GL_INVALID_VALUE,
9684 "glCopyTextureChromium", "Stream texture lookup failed"); 9667 "glCopyTextureChromium", "Stream texture lookup failed");
9685 return; 9668 return;
9686 } 9669 }
9687 gfx::Size size = stream_tex->GetSize(); 9670 gfx::Size size = stream_tex->GetSize();
9688 source_width = size.width(); 9671 source_width = size.width();
9689 source_height = size.height(); 9672 source_height = size.height();
9690 if (source_width <= 0 || source_height <= 0) { 9673 if (source_width <= 0 || source_height <= 0) {
9691 LOCAL_SET_GL_ERROR( 9674 LOCAL_SET_GL_ERROR(
9692 GL_INVALID_VALUE, 9675 GL_INVALID_VALUE,
9693 "glCopyTextureChromium", "invalid streamtexture size"); 9676 "glCopyTextureChromium", "invalid streamtexture size");
9694 return; 9677 return;
9695 } 9678 }
9679 } else {
9680 if (!source_texture->GetLevelSize(
9681 source_texture->target(), 0, &source_width, &source_height)) {
9682 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
9683 "glCopyTextureChromium",
9684 "source texture has no level 0");
9685 return;
9686 }
9687
9688 // Check that this type of texture is allowed.
9689 if (!texture_manager()->ValidForTarget(
9690 source_texture->target(), level, source_width, source_height, 1)) {
9691 LOCAL_SET_GL_ERROR(
9692 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
9693 return;
9694 }
9696 } 9695 }
9697 9696
9698 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 9697 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
9699 // needed because it takes 10s of milliseconds to initialize. 9698 // needed because it takes 10s of milliseconds to initialize.
9700 if (!copy_texture_CHROMIUM_.get()) { 9699 if (!copy_texture_CHROMIUM_.get()) {
9701 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 9700 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
9702 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 9701 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
9703 copy_texture_CHROMIUM_->Initialize(this); 9702 copy_texture_CHROMIUM_->Initialize(this);
9704 RestoreCurrentFramebufferBindings(); 9703 RestoreCurrentFramebufferBindings();
9705 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 9704 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
9821 } 9820 }
9822 9821
9823 void GLES2DecoderImpl::DoTexStorage2DEXT( 9822 void GLES2DecoderImpl::DoTexStorage2DEXT(
9824 GLenum target, 9823 GLenum target,
9825 GLint levels, 9824 GLint levels,
9826 GLenum internal_format, 9825 GLenum internal_format,
9827 GLsizei width, 9826 GLsizei width,
9828 GLsizei height) { 9827 GLsizei height) {
9829 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT"); 9828 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT");
9830 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) || 9829 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) ||
9831 TextureManager::ComputeMipMapCount(width, height, 1) < levels) { 9830 TextureManager::ComputeMipMapCount(target, width, height, 1) < levels) {
9832 LOCAL_SET_GL_ERROR( 9831 LOCAL_SET_GL_ERROR(
9833 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range"); 9832 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range");
9834 return; 9833 return;
9835 } 9834 }
9836 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 9835 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
9837 &state_, target); 9836 &state_, target);
9838 if (!texture_ref) { 9837 if (!texture_ref) {
9839 LOCAL_SET_GL_ERROR( 9838 LOCAL_SET_GL_ERROR(
9840 GL_INVALID_OPERATION, 9839 GL_INVALID_OPERATION,
9841 "glTexStorage2DEXT", "unknown texture for target"); 9840 "glTexStorage2DEXT", "unknown texture for target");
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
10446 return error::kNoError; 10445 return error::kNoError;
10447 } 10446 }
10448 10447
10449 // Include the auto-generated part of this file. We split this because it means 10448 // Include the auto-generated part of this file. We split this because it means
10450 // we can easily edit the non-auto generated parts right here in this file 10449 // we can easily edit the non-auto generated parts right here in this file
10451 // instead of having to edit some template or the code generator. 10450 // instead of having to edit some template or the code generator.
10452 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10451 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10453 10452
10454 } // namespace gles2 10453 } // namespace gles2
10455 } // namespace gpu 10454 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698