Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
index 4f63037c5382b9329fedffcec783b71159ddc1f3..0d4c7560a4b1d7386c51c0ce61d53f8934e2189c 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -53,8 +53,6 @@ |
#include "gpu/command_buffer/service/shader_manager.h" |
#include "gpu/command_buffer/service/shader_translator.h" |
#include "gpu/command_buffer/service/shader_translator_cache.h" |
-#include "gpu/command_buffer/service/stream_texture.h" |
-#include "gpu/command_buffer/service/stream_texture_manager.h" |
#include "gpu/command_buffer/service/texture_manager.h" |
#include "gpu/command_buffer/service/vertex_array_manager.h" |
#include "gpu/command_buffer/service/vertex_attrib_manager.h" |
@@ -724,10 +722,6 @@ class GLES2DecoderImpl : public GLES2Decoder { |
return group_->memory_tracker(); |
} |
- StreamTextureManager* stream_texture_manager() const { |
- return group_->stream_texture_manager(); |
- } |
- |
bool EnsureGPUMemoryAvailable(size_t estimated_size) { |
MemoryTracker* tracker = memory_tracker(); |
if (tracker) { |
@@ -1402,9 +1396,9 @@ class GLES2DecoderImpl : public GLES2Decoder { |
const char* function_name, GLuint max_vertex_accessed, bool* simulated); |
void RestoreStateForAttrib(GLuint attrib); |
- // If texture is a stream texture, this will update the stream to the newest |
- // buffer. |
- void UpdateStreamTextureIfNeeded(Texture* texture); |
+ // Notifies a potentially attached GLImage that we are about to draw with |
+ // the texture. |
+ void PrepareTexImageForDraw(Texture* texture); |
reveman
2013/08/14 15:22:44
PrepareTextureForRender? and maybe not be specific
no sievers
2013/08/14 18:16:48
Done.
|
// Returns false if unrenderable textures were replaced. |
bool PrepareTexturesForRender(); |
@@ -3882,12 +3876,6 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { |
"glBindTexture", "texture bound to more than 1 target."); |
return; |
} |
- if (texture->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_OPERATION, |
- "glBindTexture", "illegal target for stream texture."); |
- return; |
- } |
LogClientServiceForInfo(texture, client_id, "glBindTexture"); |
if (texture->target() == 0) { |
texture_manager()->SetTarget(texture_ref, target); |
@@ -5669,13 +5657,12 @@ void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) { |
} |
} |
-void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture) { |
- if (texture && texture->IsStreamTexture()) { |
- DCHECK(stream_texture_manager()); |
- StreamTexture* stream_tex = |
- stream_texture_manager()->LookupStreamTexture(texture->service_id()); |
- if (stream_tex) |
- stream_tex->Update(); |
+void GLES2DecoderImpl::PrepareTexImageForDraw(Texture* texture) { |
+ if (texture) { |
+ scoped_refptr<gfx::GLImage> image = |
+ texture->GetLevelImage(texture->target(), 0); |
no sievers
2013/08/14 04:01:24
need to worry about multiple leves/images here?
|
+ if (image.get()) |
+ image->WillUseTexImage(); |
} |
} |
@@ -5701,7 +5688,7 @@ bool GLES2DecoderImpl::PrepareTexturesForRender() { |
TextureRef* texture = |
texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
if (texture) |
- UpdateStreamTextureIfNeeded(texture->texture()); |
+ PrepareTexImageForDraw(texture->texture()); |
if (have_unrenderable_textures && |
(!texture || !texture_manager()->CanRender(texture))) { |
textures_set = true; |
@@ -9486,50 +9473,53 @@ error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( |
} |
Texture* texture = texture_ref->texture(); |
- if (texture->IsStreamTexture()) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_OPERATION, |
- "glCreateStreamTextureCHROMIUM", "is already a stream texture."); |
- return error::kNoError; |
- } |
- |
if (texture->target() && texture->target() != GL_TEXTURE_EXTERNAL_OES) { |
LOCAL_SET_GL_ERROR( |
GL_INVALID_OPERATION, |
"glCreateStreamTextureCHROMIUM", |
"is already bound to incompatible target."); |
return error::kNoError; |
- } |
- |
- if (!stream_texture_manager()) |
- return error::kInvalidArguments; |
- |
- GLuint object_id = stream_texture_manager()->CreateStreamTexture( |
- texture->service_id(), client_id); |
- |
- if (object_id) { |
- texture_manager()->SetStreamTexture(texture_ref, true); |
+ } else if (!texture->target()) { |
+ texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); |
+ } |
+ |
+ scoped_refptr<gfx::GLImage> image = |
+ gfx::GLImage::CreateGLImageForStreamTexture(texture->service_id()); |
+ |
+ uint32 image_id = 0; |
+ if (image) { |
+ image_id = group_->GetIdAllocator(id_namespaces::kImages)->AllocateID(); |
+ image_manager()->AddImage(image, image_id); |
reveman
2013/08/14 15:22:44
I thought we decided to track these separably from
no sievers
2013/08/14 18:16:48
See change above. Now that the pattern matches bet
|
+ texture_manager()->SetLevelInfo(texture_ref, |
+ GL_TEXTURE_EXTERNAL_OES, |
+ 0, |
+ GL_RGBA, |
+ 0, |
+ 0, |
+ 1, |
+ 0, |
+ GL_RGBA, |
+ GL_UNSIGNED_BYTE, |
+ true); |
+ texture_manager()->SetLevelImage( |
+ texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image); |
} else { |
LOCAL_SET_GL_ERROR( |
GL_OUT_OF_MEMORY, |
"glCreateStreamTextureCHROMIUM", "failed to create platform texture."); |
} |
- *result = object_id; |
+ *result = image_id; |
return error::kNoError; |
} |
error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM( |
uint32 immediate_data_size, |
const cmds::DestroyStreamTextureCHROMIUM& c) { |
- GLuint client_id = c.texture; |
- TextureRef* texture_ref = texture_manager()->GetTexture(client_id); |
- if (texture_ref && texture_manager()->IsStreamTextureOwner(texture_ref)) { |
- if (!stream_texture_manager()) |
- return error::kInvalidArguments; |
- |
- stream_texture_manager()->DestroyStreamTexture(texture_ref->service_id()); |
- texture_manager()->SetStreamTexture(texture_ref, false); |
+ GLuint image_id = c.texture; |
+ if (image_id && image_manager()->LookupImage(image_id)) { |
+ image_manager()->RemoveImage(image_id); |
+ group_->GetIdAllocator(id_namespaces::kImages)->FreeID(image_id); |
} else { |
LOCAL_SET_GL_ERROR( |
GL_INVALID_VALUE, |
@@ -9740,11 +9730,9 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
} |
if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
- UpdateStreamTextureIfNeeded(source_texture); |
- DCHECK(stream_texture_manager()); |
- StreamTexture* stream_tex = |
- stream_texture_manager()->LookupStreamTexture( |
- source_texture->service_id()); |
+ PrepareTexImageForDraw(source_texture); |
+ scoped_refptr<gfx::GLImage> stream_tex = |
+ source_texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0); |
if (!stream_tex) { |
LOCAL_SET_GL_ERROR( |
GL_INVALID_VALUE, |