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

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

Issue 22824009: Remove StreamTextureManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "gpu/command_buffer/service/gpu_tracer.h" 46 #include "gpu/command_buffer/service/gpu_tracer.h"
47 #include "gpu/command_buffer/service/image_manager.h" 47 #include "gpu/command_buffer/service/image_manager.h"
48 #include "gpu/command_buffer/service/mailbox_manager.h" 48 #include "gpu/command_buffer/service/mailbox_manager.h"
49 #include "gpu/command_buffer/service/memory_tracking.h" 49 #include "gpu/command_buffer/service/memory_tracking.h"
50 #include "gpu/command_buffer/service/program_manager.h" 50 #include "gpu/command_buffer/service/program_manager.h"
51 #include "gpu/command_buffer/service/query_manager.h" 51 #include "gpu/command_buffer/service/query_manager.h"
52 #include "gpu/command_buffer/service/renderbuffer_manager.h" 52 #include "gpu/command_buffer/service/renderbuffer_manager.h"
53 #include "gpu/command_buffer/service/shader_manager.h" 53 #include "gpu/command_buffer/service/shader_manager.h"
54 #include "gpu/command_buffer/service/shader_translator.h" 54 #include "gpu/command_buffer/service/shader_translator.h"
55 #include "gpu/command_buffer/service/shader_translator_cache.h" 55 #include "gpu/command_buffer/service/shader_translator_cache.h"
56 #include "gpu/command_buffer/service/stream_texture.h"
57 #include "gpu/command_buffer/service/stream_texture_manager.h"
58 #include "gpu/command_buffer/service/texture_manager.h" 56 #include "gpu/command_buffer/service/texture_manager.h"
59 #include "gpu/command_buffer/service/vertex_array_manager.h" 57 #include "gpu/command_buffer/service/vertex_array_manager.h"
60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 58 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
61 #include "ui/gl/gl_bindings.h" 59 #include "ui/gl/gl_bindings.h"
62 #include "ui/gl/gl_fence.h" 60 #include "ui/gl/gl_fence.h"
63 #include "ui/gl/gl_image.h" 61 #include "ui/gl/gl_image.h"
64 #include "ui/gl/gl_implementation.h" 62 #include "ui/gl/gl_implementation.h"
65 #include "ui/gl/gl_surface.h" 63 #include "ui/gl/gl_surface.h"
66 64
67 #if defined(OS_MACOSX) 65 #if defined(OS_MACOSX)
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 715 }
718 716
719 VertexArrayManager* vertex_array_manager() { 717 VertexArrayManager* vertex_array_manager() {
720 return vertex_array_manager_.get(); 718 return vertex_array_manager_.get();
721 } 719 }
722 720
723 MemoryTracker* memory_tracker() { 721 MemoryTracker* memory_tracker() {
724 return group_->memory_tracker(); 722 return group_->memory_tracker();
725 } 723 }
726 724
727 StreamTextureManager* stream_texture_manager() const {
728 return group_->stream_texture_manager();
729 }
730
731 bool EnsureGPUMemoryAvailable(size_t estimated_size) { 725 bool EnsureGPUMemoryAvailable(size_t estimated_size) {
732 MemoryTracker* tracker = memory_tracker(); 726 MemoryTracker* tracker = memory_tracker();
733 if (tracker) { 727 if (tracker) {
734 return tracker->EnsureGPUMemoryAvailable(estimated_size); 728 return tracker->EnsureGPUMemoryAvailable(estimated_size);
735 } 729 }
736 return true; 730 return true;
737 } 731 }
738 732
739 bool IsOffscreenBufferMultisampled() const { 733 bool IsOffscreenBufferMultisampled() const {
740 return offscreen_target_samples_ > 1; 734 return offscreen_target_samples_ > 1;
(...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 Texture* texture = texture_ref->texture(); 3869 Texture* texture = texture_ref->texture();
3876 3870
3877 // Check the texture exists 3871 // Check the texture exists
3878 // Check that we are not trying to bind it to a different target. 3872 // Check that we are not trying to bind it to a different target.
3879 if (texture->target() != 0 && texture->target() != target) { 3873 if (texture->target() != 0 && texture->target() != target) {
3880 LOCAL_SET_GL_ERROR( 3874 LOCAL_SET_GL_ERROR(
3881 GL_INVALID_OPERATION, 3875 GL_INVALID_OPERATION,
3882 "glBindTexture", "texture bound to more than 1 target."); 3876 "glBindTexture", "texture bound to more than 1 target.");
3883 return; 3877 return;
3884 } 3878 }
3885 if (texture->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) {
3886 LOCAL_SET_GL_ERROR(
3887 GL_INVALID_OPERATION,
3888 "glBindTexture", "illegal target for stream texture.");
3889 return;
3890 }
3891 LogClientServiceForInfo(texture, client_id, "glBindTexture"); 3879 LogClientServiceForInfo(texture, client_id, "glBindTexture");
3892 if (texture->target() == 0) { 3880 if (texture->target() == 0) {
3893 texture_manager()->SetTarget(texture_ref, target); 3881 texture_manager()->SetTarget(texture_ref, target);
3894 } 3882 }
3895 glBindTexture(target, texture->service_id()); 3883 glBindTexture(target, texture->service_id());
3896 3884
3897 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 3885 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
3898 unit.bind_target = target; 3886 unit.bind_target = target;
3899 switch (target) { 3887 switch (target) {
3900 case GL_TEXTURE_2D: 3888 case GL_TEXTURE_2D:
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
5663 // We know there will be no errors, because we only defer compilation on 5651 // We know there will be no errors, because we only defer compilation on
5664 // shaders that were previously compiled successfully. 5652 // shaders that were previously compiled successfully.
5665 program_manager()->ForceCompileShader(shader->deferred_compilation_source(), 5653 program_manager()->ForceCompileShader(shader->deferred_compilation_source(),
5666 shader, 5654 shader,
5667 translator, 5655 translator,
5668 feature_info_.get()); 5656 feature_info_.get());
5669 } 5657 }
5670 } 5658 }
5671 5659
5672 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture) { 5660 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture) {
5673 if (texture && texture->IsStreamTexture()) { 5661 if (features().chromium_stream_texture && texture &&
5674 DCHECK(stream_texture_manager()); 5662 texture->target() == GL_TEXTURE_EXTERNAL_OES) {
5675 StreamTexture* stream_tex = 5663 scoped_refptr<gfx::GLImage> stream_tex =
5676 stream_texture_manager()->LookupStreamTexture(texture->service_id()); 5664 texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0);
5677 if (stream_tex) 5665 if (stream_tex.get())
5678 stream_tex->Update(); 5666 stream_tex->UpdateTexImage();
5679 } 5667 }
5680 } 5668 }
5681 5669
5682 bool GLES2DecoderImpl::PrepareTexturesForRender() { 5670 bool GLES2DecoderImpl::PrepareTexturesForRender() {
5683 DCHECK(state_.current_program.get()); 5671 DCHECK(state_.current_program.get());
5684 bool have_unrenderable_textures = 5672 bool have_unrenderable_textures =
5685 texture_manager()->HaveUnrenderableTextures(); 5673 texture_manager()->HaveUnrenderableTextures();
5686 if (!have_unrenderable_textures && !features().oes_egl_image_external) { 5674 if (!have_unrenderable_textures && !features().oes_egl_image_external) {
5687 return true; 5675 return true;
5688 } 5676 }
(...skipping 3763 matching lines...) Expand 10 before | Expand all | Expand 10 after
9452 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 9440 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
9453 element_array_buffer ? element_array_buffer->service_id() : 0); 9441 element_array_buffer ? element_array_buffer->service_id() : 0);
9454 } 9442 }
9455 9443
9456 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { 9444 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) {
9457 const VertexAttribManager* vao = 9445 const VertexAttribManager* vao =
9458 GetVertexAttribManager(client_id); 9446 GetVertexAttribManager(client_id);
9459 return vao && vao->IsValid() && !vao->IsDeleted(); 9447 return vao && vao->IsValid() && !vao->IsDeleted();
9460 } 9448 }
9461 9449
9462 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( 9450 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
reveman 2013/08/13 00:48:13 Could this become CreateStreamImageCHROMIUM and re
no sievers 2013/08/14 04:01:23 Yes, I think that sounds good. But since it needs
9463 uint32 immediate_data_size, 9451 uint32 immediate_data_size,
9464 const cmds::CreateStreamTextureCHROMIUM& c) { 9452 const cmds::CreateStreamTextureCHROMIUM& c) {
9465 if (!features().chromium_stream_texture) { 9453 if (!features().chromium_stream_texture) {
9466 LOCAL_SET_GL_ERROR( 9454 LOCAL_SET_GL_ERROR(
9467 GL_INVALID_OPERATION, 9455 GL_INVALID_OPERATION,
9468 "glOpenStreamTextureCHROMIUM", "not supported."); 9456 "glOpenStreamTextureCHROMIUM", "not supported.");
9469 return error::kNoError; 9457 return error::kNoError;
9470 } 9458 }
9471 9459
9472 uint32 client_id = c.client_id; 9460 uint32 client_id = c.client_id;
9473 typedef cmds::CreateStreamTextureCHROMIUM::Result Result; 9461 typedef cmds::CreateStreamTextureCHROMIUM::Result Result;
9474 Result* result = GetSharedMemoryAs<Result*>( 9462 Result* result = GetSharedMemoryAs<Result*>(
9475 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 9463 c.result_shm_id, c.result_shm_offset, sizeof(*result));
9476 9464
9477 if (!result) 9465 if (!result)
9478 return error::kOutOfBounds; 9466 return error::kOutOfBounds;
9479 *result = GL_ZERO; 9467 *result = GL_ZERO;
9480 TextureRef* texture_ref = texture_manager()->GetTexture(client_id); 9468 TextureRef* texture_ref = texture_manager()->GetTexture(client_id);
9481 if (!texture_ref) { 9469 if (!texture_ref) {
9482 LOCAL_SET_GL_ERROR( 9470 LOCAL_SET_GL_ERROR(
9483 GL_INVALID_VALUE, 9471 GL_INVALID_VALUE,
9484 "glCreateStreamTextureCHROMIUM", "bad texture id."); 9472 "glCreateStreamTextureCHROMIUM", "bad texture id.");
9485 return error::kNoError; 9473 return error::kNoError;
9486 } 9474 }
9487 9475
9488 Texture* texture = texture_ref->texture(); 9476 Texture* texture = texture_ref->texture();
9489 if (texture->IsStreamTexture()) {
9490 LOCAL_SET_GL_ERROR(
9491 GL_INVALID_OPERATION,
9492 "glCreateStreamTextureCHROMIUM", "is already a stream texture.");
9493 return error::kNoError;
9494 }
9495
9496 if (texture->target() && texture->target() != GL_TEXTURE_EXTERNAL_OES) { 9477 if (texture->target() && texture->target() != GL_TEXTURE_EXTERNAL_OES) {
9497 LOCAL_SET_GL_ERROR( 9478 LOCAL_SET_GL_ERROR(
9498 GL_INVALID_OPERATION, 9479 GL_INVALID_OPERATION,
9499 "glCreateStreamTextureCHROMIUM", 9480 "glCreateStreamTextureCHROMIUM",
9500 "is already bound to incompatible target."); 9481 "is already bound to incompatible target.");
9501 return error::kNoError; 9482 return error::kNoError;
9483 } else if (!texture->target()) {
9484 texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES);
9502 } 9485 }
9503 9486
9504 if (!stream_texture_manager()) 9487 scoped_refptr<gfx::GLImage> image =
9505 return error::kInvalidArguments; 9488 gfx::GLImage::CreateGLImageForStreamTexture(texture->service_id());
9506 9489
9507 GLuint object_id = stream_texture_manager()->CreateStreamTexture( 9490 uint32 image_id = 0;
9508 texture->service_id(), client_id); 9491 if (image) {
9509 9492 image_id = group_->GetIdAllocator(id_namespaces::kImages)->AllocateID();
9510 if (object_id) { 9493 image_manager()->AddImage(image, image_id);
9511 texture_manager()->SetStreamTexture(texture_ref, true); 9494 texture_manager()->SetLevelInfo(texture_ref,
9495 GL_TEXTURE_EXTERNAL_OES,
9496 0,
9497 GL_RGBA,
9498 0,
9499 0,
9500 1,
9501 0,
9502 GL_RGBA,
9503 GL_UNSIGNED_BYTE,
9504 true);
9505 texture_manager()->SetLevelImage(
9506 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image);
9512 } else { 9507 } else {
9513 LOCAL_SET_GL_ERROR( 9508 LOCAL_SET_GL_ERROR(
9514 GL_OUT_OF_MEMORY, 9509 GL_OUT_OF_MEMORY,
9515 "glCreateStreamTextureCHROMIUM", "failed to create platform texture."); 9510 "glCreateStreamTextureCHROMIUM", "failed to create platform texture.");
9516 } 9511 }
9517 9512
9518 *result = object_id; 9513 *result = image_id;
9519 return error::kNoError; 9514 return error::kNoError;
9520 } 9515 }
9521 9516
9522 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM( 9517 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(
9523 uint32 immediate_data_size, 9518 uint32 immediate_data_size,
9524 const cmds::DestroyStreamTextureCHROMIUM& c) { 9519 const cmds::DestroyStreamTextureCHROMIUM& c) {
9525 GLuint client_id = c.texture; 9520 GLuint image_id = c.texture;
9526 TextureRef* texture_ref = texture_manager()->GetTexture(client_id); 9521 if (image_id && image_manager()->LookupImage(image_id)) {
9527 if (texture_ref && texture_manager()->IsStreamTextureOwner(texture_ref)) { 9522 image_manager()->RemoveImage(image_id);
9528 if (!stream_texture_manager()) 9523 group_->GetIdAllocator(id_namespaces::kImages)->FreeID(image_id);
9529 return error::kInvalidArguments;
9530
9531 stream_texture_manager()->DestroyStreamTexture(texture_ref->service_id());
9532 texture_manager()->SetStreamTexture(texture_ref, false);
9533 } else { 9524 } else {
9534 LOCAL_SET_GL_ERROR( 9525 LOCAL_SET_GL_ERROR(
9535 GL_INVALID_VALUE, 9526 GL_INVALID_VALUE,
9536 "glDestroyStreamTextureCHROMIUM", "bad texture id."); 9527 "glDestroyStreamTextureCHROMIUM", "bad texture id.");
9537 } 9528 }
9538 9529
9539 return error::kNoError; 9530 return error::kNoError;
9540 } 9531 }
9541 9532
9542 #if defined(OS_MACOSX) 9533 #if defined(OS_MACOSX)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
9734 source_height, 1)) { 9725 source_height, 1)) {
9735 LOCAL_SET_GL_ERROR( 9726 LOCAL_SET_GL_ERROR(
9736 GL_INVALID_VALUE, 9727 GL_INVALID_VALUE,
9737 "glCopyTextureCHROMIUM", "Bad dimensions"); 9728 "glCopyTextureCHROMIUM", "Bad dimensions");
9738 return; 9729 return;
9739 } 9730 }
9740 } 9731 }
9741 9732
9742 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 9733 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
9743 UpdateStreamTextureIfNeeded(source_texture); 9734 UpdateStreamTextureIfNeeded(source_texture);
9744 DCHECK(stream_texture_manager()); 9735 scoped_refptr<gfx::GLImage> stream_tex =
9745 StreamTexture* stream_tex = 9736 source_texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0);
9746 stream_texture_manager()->LookupStreamTexture(
9747 source_texture->service_id());
9748 if (!stream_tex) { 9737 if (!stream_tex) {
9749 LOCAL_SET_GL_ERROR( 9738 LOCAL_SET_GL_ERROR(
9750 GL_INVALID_VALUE, 9739 GL_INVALID_VALUE,
9751 "glCopyTextureChromium", "Stream texture lookup failed"); 9740 "glCopyTextureChromium", "Stream texture lookup failed");
9752 return; 9741 return;
9753 } 9742 }
9754 gfx::Size size = stream_tex->GetSize(); 9743 gfx::Size size = stream_tex->GetSize();
9755 source_width = size.width(); 9744 source_width = size.width();
9756 source_height = size.height(); 9745 source_height = size.height();
9757 if (source_width <= 0 || source_height <= 0) { 9746 if (source_width <= 0 || source_height <= 0) {
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
10503 return error::kNoError; 10492 return error::kNoError;
10504 } 10493 }
10505 10494
10506 // Include the auto-generated part of this file. We split this because it means 10495 // Include the auto-generated part of this file. We split this because it means
10507 // we can easily edit the non-auto generated parts right here in this file 10496 // we can easily edit the non-auto generated parts right here in this file
10508 // instead of having to edit some template or the code generator. 10497 // instead of having to edit some template or the code generator.
10509 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10498 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10510 10499
10511 } // namespace gles2 10500 } // namespace gles2
10512 } // namespace gpu 10501 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698