Commit 34008d88 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Reuse some texture copying code

Allow RasterDecoderImpl to use some texture copying code by adding
methods to DecoderContext (common interface implemented by RasterDecoder
and GLES2Decoder). Implement some of the NOTIMPLEMENTED() state
restoration code by copying from GLES2DecoderImpl.

BUG=789238

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic23665e8f1d63f20905334dedefdeb77e90c3c40
Reviewed-on: https://chromium-review.googlesource.com/981075
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546191}
parent c5284710
...@@ -33,6 +33,7 @@ struct ContextCreationAttribs; ...@@ -33,6 +33,7 @@ struct ContextCreationAttribs;
namespace gles2 { namespace gles2 {
class ContextGroup; class ContextGroup;
class ErrorState; class ErrorState;
class FeatureInfo;
class GpuFenceManager; class GpuFenceManager;
struct ContextState; struct ContextState;
struct DisallowedFeatures; struct DisallowedFeatures;
...@@ -73,6 +74,8 @@ class GPU_GLES2_EXPORT DecoderContext : public AsyncAPIInterface { ...@@ -73,6 +74,8 @@ class GPU_GLES2_EXPORT DecoderContext : public AsyncAPIInterface {
virtual Capabilities GetCapabilities() = 0; virtual Capabilities GetCapabilities() = 0;
virtual const gles2::FeatureInfo* GetFeatureInfo() const = 0;
// Gets the associated GLContext. // Gets the associated GLContext.
virtual gl::GLContext* GetGLContext() = 0; virtual gl::GLContext* GetGLContext() = 0;
...@@ -130,6 +133,9 @@ class GPU_GLES2_EXPORT DecoderContext : public AsyncAPIInterface { ...@@ -130,6 +133,9 @@ class GPU_GLES2_EXPORT DecoderContext : public AsyncAPIInterface {
virtual void RestoreState(const gles2::ContextState* prev_state) = 0; virtual void RestoreState(const gles2::ContextState* prev_state) = 0;
// Restore States. // Restore States.
virtual void RestoreGlobalState() const = 0;
virtual void ClearAllAttributes() const = 0;
virtual void RestoreAllAttributes() const = 0;
virtual void RestoreActiveTexture() const = 0; virtual void RestoreActiveTexture() const = 0;
virtual void RestoreAllTextureUnitAndSamplerBindings( virtual void RestoreAllTextureUnitAndSamplerBindings(
const gles2::ContextState* prev_state) const = 0; const gles2::ContextState* prev_state) const = 0;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h"
#include "gpu/command_buffer/service/decoder_context.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
...@@ -33,8 +34,7 @@ CopyTexImageResourceManager::CopyTexImageResourceManager( ...@@ -33,8 +34,7 @@ CopyTexImageResourceManager::CopyTexImageResourceManager(
CopyTexImageResourceManager::~CopyTexImageResourceManager() = default; CopyTexImageResourceManager::~CopyTexImageResourceManager() = default;
void CopyTexImageResourceManager::Initialize( void CopyTexImageResourceManager::Initialize(const DecoderContext* decoder) {
const gles2::GLES2Decoder* decoder) {
if (initialized_) { if (initialized_) {
return; return;
} }
...@@ -141,7 +141,7 @@ void CopyTexImageResourceManager::Destroy() { ...@@ -141,7 +141,7 @@ void CopyTexImageResourceManager::Destroy() {
} }
void CopyTexImageResourceManager::DoCopyTexImage2DToLUMACompatibilityTexture( void CopyTexImageResourceManager::DoCopyTexImage2DToLUMACompatibilityTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLuint dest_texture, GLuint dest_texture,
GLenum dest_texture_target, GLenum dest_texture_target,
GLenum dest_target, GLenum dest_target,
...@@ -170,7 +170,7 @@ void CopyTexImageResourceManager::DoCopyTexImage2DToLUMACompatibilityTexture( ...@@ -170,7 +170,7 @@ void CopyTexImageResourceManager::DoCopyTexImage2DToLUMACompatibilityTexture(
} }
void CopyTexImageResourceManager::DoCopyTexSubImageToLUMACompatibilityTexture( void CopyTexImageResourceManager::DoCopyTexSubImageToLUMACompatibilityTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLuint dest_texture, GLuint dest_texture,
GLenum dest_texture_target, GLenum dest_texture_target,
GLenum dest_target, GLenum dest_target,
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "gpu/gpu_gles2_export.h" #include "gpu/gpu_gles2_export.h"
namespace gpu { namespace gpu {
namespace gles2 { class DecoderContext;
class GLES2Decoder; namespace gles2 {
// This class encapsulates the resources required to implement the // This class encapsulates the resources required to implement the
// glCopyTexImage and glCopyTexSubImage commands. These commands somtimes // glCopyTexImage and glCopyTexSubImage commands. These commands somtimes
...@@ -26,11 +26,11 @@ class GPU_GLES2_EXPORT CopyTexImageResourceManager { ...@@ -26,11 +26,11 @@ class GPU_GLES2_EXPORT CopyTexImageResourceManager {
explicit CopyTexImageResourceManager(const gles2::FeatureInfo* feature_info); explicit CopyTexImageResourceManager(const gles2::FeatureInfo* feature_info);
~CopyTexImageResourceManager(); ~CopyTexImageResourceManager();
void Initialize(const gles2::GLES2Decoder* decoder); void Initialize(const DecoderContext* decoder);
void Destroy(); void Destroy();
void DoCopyTexImage2DToLUMACompatibilityTexture( void DoCopyTexImage2DToLUMACompatibilityTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLuint dest_texture, GLuint dest_texture,
GLenum dest_texture_target, GLenum dest_texture_target,
GLenum dest_target, GLenum dest_target,
...@@ -46,7 +46,7 @@ class GPU_GLES2_EXPORT CopyTexImageResourceManager { ...@@ -46,7 +46,7 @@ class GPU_GLES2_EXPORT CopyTexImageResourceManager {
GLenum source_framebuffer_internal_format); GLenum source_framebuffer_internal_format);
void DoCopyTexSubImageToLUMACompatibilityTexture( void DoCopyTexSubImageToLUMACompatibilityTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLuint dest_texture, GLuint dest_texture,
GLenum dest_texture_target, GLenum dest_texture_target,
GLenum dest_target, GLenum dest_target,
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include <algorithm> #include <algorithm>
#include "gpu/command_buffer/service/decoder_context.h"
#include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
...@@ -557,7 +557,7 @@ bool BindFramebufferTexture2D(GLenum target, ...@@ -557,7 +557,7 @@ bool BindFramebufferTexture2D(GLenum target,
} }
void DoCopyTexImage2D( void DoCopyTexImage2D(
const gpu::gles2::GLES2Decoder* decoder, const gpu::DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -610,7 +610,7 @@ void DoCopyTexImage2D( ...@@ -610,7 +610,7 @@ void DoCopyTexImage2D(
} }
void DoCopyTexSubImage2D( void DoCopyTexSubImage2D(
const gpu::gles2::GLES2Decoder* decoder, const gpu::DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -782,7 +782,7 @@ enum TexImageCommandType { ...@@ -782,7 +782,7 @@ enum TexImageCommandType {
}; };
void DoReadbackAndTexImage(TexImageCommandType command_type, void DoReadbackAndTexImage(TexImageCommandType command_type,
const gpu::gles2::GLES2Decoder* decoder, const gpu::DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -878,7 +878,7 @@ CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() { ...@@ -878,7 +878,7 @@ CopyTextureCHROMIUMResourceManager::~CopyTextureCHROMIUMResourceManager() {
} }
void CopyTextureCHROMIUMResourceManager::Initialize( void CopyTextureCHROMIUMResourceManager::Initialize(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
const gles2::FeatureInfo::FeatureFlags& feature_flags) { const gles2::FeatureInfo::FeatureFlags& feature_flags) {
static_assert( static_assert(
kVertexPositionAttrib == 0u, kVertexPositionAttrib == 0u,
...@@ -947,7 +947,7 @@ void CopyTextureCHROMIUMResourceManager::Destroy() { ...@@ -947,7 +947,7 @@ void CopyTextureCHROMIUMResourceManager::Destroy() {
} }
void CopyTextureCHROMIUMResourceManager::DoCopyTexture( void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -1022,7 +1022,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture( ...@@ -1022,7 +1022,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
} }
void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -1114,7 +1114,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture( ...@@ -1114,7 +1114,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
} }
void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform( void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -1148,7 +1148,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform( ...@@ -1148,7 +1148,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTextureWithTransform(
} }
void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -1175,7 +1175,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( ...@@ -1175,7 +1175,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
} }
void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal( void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
#include "gpu/gpu_gles2_export.h" #include "gpu/gpu_gles2_export.h"
namespace gpu { namespace gpu {
class DecoderContext;
namespace gles2 { namespace gles2 {
class GLES2Decoder;
class CopyTexImageResourceManager; class CopyTexImageResourceManager;
enum CopyTextureMethod { enum CopyTextureMethod {
...@@ -49,11 +51,11 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -49,11 +51,11 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
CopyTextureCHROMIUMResourceManager(); CopyTextureCHROMIUMResourceManager();
~CopyTextureCHROMIUMResourceManager(); ~CopyTextureCHROMIUMResourceManager();
void Initialize(const gles2::GLES2Decoder* decoder, void Initialize(const DecoderContext* decoder,
const gles2::FeatureInfo::FeatureFlags& feature_flags); const gles2::FeatureInfo::FeatureFlags& feature_flags);
void Destroy(); void Destroy();
void DoCopyTexture(const gles2::GLES2Decoder* decoder, void DoCopyTexture(const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -71,7 +73,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -71,7 +73,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
CopyTextureMethod method, CopyTextureMethod method,
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter);
void DoCopySubTexture(const gles2::GLES2Decoder* decoder, void DoCopySubTexture(const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -98,7 +100,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -98,7 +100,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter);
void DoCopySubTextureWithTransform( void DoCopySubTextureWithTransform(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -129,7 +131,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -129,7 +131,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
// matrix should be given in column-major form, so it can be passed // matrix should be given in column-major form, so it can be passed
// directly to GL. // directly to GL.
void DoCopyTextureWithTransform( void DoCopyTextureWithTransform(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -178,7 +180,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -178,7 +180,7 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
}; };
void DoCopyTextureInternal( void DoCopyTextureInternal(
const gles2::GLES2Decoder* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
......
...@@ -43,7 +43,6 @@ class ServiceTransferCache; ...@@ -43,7 +43,6 @@ class ServiceTransferCache;
namespace gles2 { namespace gles2 {
class ContextGroup; class ContextGroup;
class FeatureInfo;
class FramebufferManager; class FramebufferManager;
class GLES2Util; class GLES2Util;
class ImageManager; class ImageManager;
...@@ -151,15 +150,9 @@ class GPU_GLES2_EXPORT GLES2Decoder : public CommonDecoder, ...@@ -151,15 +150,9 @@ class GPU_GLES2_EXPORT GLES2Decoder : public CommonDecoder,
// Gets the GLES2 Util which holds info. // Gets the GLES2 Util which holds info.
virtual GLES2Util* GetGLES2Util() = 0; virtual GLES2Util* GetGLES2Util() = 0;
virtual const FeatureInfo* GetFeatureInfo() const = 0;
// Restore States. // Restore States.
virtual void RestoreGlobalState() const = 0;
virtual void RestoreDeviceWindowRectangles() const = 0; virtual void RestoreDeviceWindowRectangles() const = 0;
virtual void ClearAllAttributes() const = 0;
virtual void RestoreAllAttributes() const = 0;
virtual void SetIgnoreCachedStateForTest(bool ignore) = 0; virtual void SetIgnoreCachedStateForTest(bool ignore) = 0;
virtual void SetForceShaderNameHashingForTest(bool force) = 0; virtual void SetForceShaderNameHashingForTest(bool force) = 0;
virtual uint32_t GetAndClearBackbufferClearBitsForTest(); virtual uint32_t GetAndClearBackbufferClearBitsForTest();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "gpu/command_buffer/common/raster_cmd_format.h" #include "gpu/command_buffer/common/raster_cmd_format.h"
#include "gpu/command_buffer/common/raster_cmd_ids.h" #include "gpu/command_buffer/common/raster_cmd_ids.h"
#include "gpu/command_buffer/common/sync_token.h" #include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/context_state.h" #include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/decoder_client.h" #include "gpu/command_buffer/service/decoder_client.h"
...@@ -209,7 +210,13 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient { ...@@ -209,7 +210,13 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient {
void Destroy(bool have_context) override; void Destroy(bool have_context) override;
bool MakeCurrent() override; bool MakeCurrent() override;
gl::GLContext* GetGLContext() override; gl::GLContext* GetGLContext() override;
const FeatureInfo* GetFeatureInfo() const override {
return feature_info_.get();
}
Capabilities GetCapabilities() override; Capabilities GetCapabilities() override;
void RestoreGlobalState() const override;
void ClearAllAttributes() const override;
void RestoreAllAttributes() const override;
void RestoreState(const gles2::ContextState* prev_state) override; void RestoreState(const gles2::ContextState* prev_state) override;
void RestoreActiveTexture() const override; void RestoreActiveTexture() const override;
void RestoreAllTextureUnitAndSamplerBindings( void RestoreAllTextureUnitAndSamplerBindings(
...@@ -293,6 +300,8 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient { ...@@ -293,6 +300,8 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient {
MemoryTracker* memory_tracker() { return group_->memory_tracker(); } MemoryTracker* memory_tracker() { return group_->memory_tracker(); }
BufferManager* buffer_manager() { return group_->buffer_manager(); }
bool EnsureGPUMemoryAvailable(size_t estimated_size) { bool EnsureGPUMemoryAvailable(size_t estimated_size) {
MemoryTracker* tracker = memory_tracker(); MemoryTracker* tracker = memory_tracker();
if (tracker) { if (tracker) {
...@@ -499,6 +508,11 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient { ...@@ -499,6 +508,11 @@ class RasterDecoderImpl : public RasterDecoder, public gles2::ErrorStateClient {
// A table of CommandInfo for all the commands. // A table of CommandInfo for all the commands.
static const CommandInfo command_info[kNumCommands - kFirstRasterCommand]; static const CommandInfo command_info[kNumCommands - kFirstRasterCommand];
// Most recent generation of the TextureManager. If this no longer matches
// the current generation when our context becomes current, then we'll rebind
// all the textures to stay up to date with Texture::service_id() changes.
uint32_t texture_manager_service_id_generation_;
// Number of commands remaining to be processed in DoCommands(). // Number of commands remaining to be processed in DoCommands().
int commands_to_process_; int commands_to_process_;
...@@ -602,6 +616,7 @@ RasterDecoderImpl::RasterDecoderImpl( ...@@ -602,6 +616,7 @@ RasterDecoderImpl::RasterDecoderImpl(
Outputter* outputter, Outputter* outputter,
ContextGroup* group) ContextGroup* group)
: RasterDecoder(command_buffer_service), : RasterDecoder(command_buffer_service),
texture_manager_service_id_generation_(0),
commands_to_process_(0), commands_to_process_(0),
current_decoder_error_(error::kNoError), current_decoder_error_(error::kNoError),
client_(client), client_(client),
...@@ -718,6 +733,11 @@ bool RasterDecoderImpl::MakeCurrent() { ...@@ -718,6 +733,11 @@ bool RasterDecoderImpl::MakeCurrent() {
group_->LoseContexts(error::kUnknown); group_->LoseContexts(error::kUnknown);
return false; return false;
} }
DCHECK_EQ(api(), gl::g_current_gl_context);
// Rebind textures if the service ids may have changed.
RestoreAllExternalTextureBindingsIfNeeded();
return true; return true;
} }
...@@ -739,30 +759,61 @@ Capabilities RasterDecoderImpl::GetCapabilities() { ...@@ -739,30 +759,61 @@ Capabilities RasterDecoderImpl::GetCapabilities() {
return caps; return caps;
} }
void RasterDecoderImpl::RestoreGlobalState() const {
state_.RestoreGlobalState(nullptr);
}
void RasterDecoderImpl::ClearAllAttributes() const {
// Must use native VAO 0, as RestoreAllAttributes can't fully restore
// other VAOs.
if (feature_info_->feature_flags().native_vertex_array_object)
api()->glBindVertexArrayOESFn(0);
for (uint32_t i = 0; i < group_->max_vertex_attribs(); ++i) {
if (i != 0) // Never disable attribute 0
state_.vertex_attrib_manager->SetDriverVertexAttribEnabled(i, false);
if (features().angle_instanced_arrays)
api()->glVertexAttribDivisorANGLEFn(i, 0);
}
}
void RasterDecoderImpl::RestoreAllAttributes() const {
state_.RestoreVertexAttribs();
}
void RasterDecoderImpl::RestoreState(const ContextState* prev_state) { void RasterDecoderImpl::RestoreState(const ContextState* prev_state) {
NOTIMPLEMENTED(); TRACE_EVENT1("gpu", "RasterDecoderImpl::RestoreState", "context",
logger_.GetLogPrefix());
state_.RestoreState(prev_state);
} }
void RasterDecoderImpl::RestoreActiveTexture() const { void RasterDecoderImpl::RestoreActiveTexture() const {
NOTIMPLEMENTED(); state_.RestoreActiveTexture();
} }
void RasterDecoderImpl::RestoreAllTextureUnitAndSamplerBindings( void RasterDecoderImpl::RestoreAllTextureUnitAndSamplerBindings(
const ContextState* prev_state) const { const ContextState* prev_state) const {
NOTIMPLEMENTED(); state_.RestoreAllTextureUnitAndSamplerBindings(prev_state);
} }
void RasterDecoderImpl::RestoreActiveTextureUnitBinding( void RasterDecoderImpl::RestoreActiveTextureUnitBinding(
unsigned int target) const { unsigned int target) const {
NOTIMPLEMENTED(); state_.RestoreActiveTextureUnitBinding(target);
} }
void RasterDecoderImpl::RestoreBufferBinding(unsigned int target) { void RasterDecoderImpl::RestoreBufferBinding(unsigned int target) {
NOTIMPLEMENTED(); if (target == GL_PIXEL_PACK_BUFFER) {
state_.UpdatePackParameters();
} else if (target == GL_PIXEL_UNPACK_BUFFER) {
state_.UpdateUnpackParameters();
}
gles2::Buffer* bound_buffer =
buffer_manager()->GetBufferInfoForTarget(&state_, target);
api()->glBindBufferFn(target, bound_buffer ? bound_buffer->service_id() : 0);
} }
void RasterDecoderImpl::RestoreBufferBindings() const { void RasterDecoderImpl::RestoreBufferBindings() const {
NOTIMPLEMENTED(); state_.RestoreBufferBindings();
} }
void RasterDecoderImpl::RestoreFramebufferBindings() const { void RasterDecoderImpl::RestoreFramebufferBindings() const {
...@@ -770,19 +821,34 @@ void RasterDecoderImpl::RestoreFramebufferBindings() const { ...@@ -770,19 +821,34 @@ void RasterDecoderImpl::RestoreFramebufferBindings() const {
} }
void RasterDecoderImpl::RestoreRenderbufferBindings() { void RasterDecoderImpl::RestoreRenderbufferBindings() {
NOTIMPLEMENTED(); state_.RestoreRenderbufferBindings();
} }
void RasterDecoderImpl::RestoreProgramBindings() const { void RasterDecoderImpl::RestoreProgramBindings() const {
NOTIMPLEMENTED(); state_.RestoreProgramSettings(nullptr, false);
} }
void RasterDecoderImpl::RestoreTextureState(unsigned service_id) const { void RasterDecoderImpl::RestoreTextureState(unsigned service_id) const {
NOTIMPLEMENTED(); Texture* texture = texture_manager()->GetTextureForServiceId(service_id);
if (texture) {
GLenum target = texture->target();
api()->glBindTextureFn(target, service_id);
api()->glTexParameteriFn(target, GL_TEXTURE_WRAP_S, texture->wrap_s());
api()->glTexParameteriFn(target, GL_TEXTURE_WRAP_T, texture->wrap_t());
api()->glTexParameteriFn(target, GL_TEXTURE_MIN_FILTER,
texture->min_filter());
api()->glTexParameteriFn(target, GL_TEXTURE_MAG_FILTER,
texture->mag_filter());
if (feature_info_->IsWebGL2OrES3Context()) {
api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL,
texture->base_level());
}
RestoreTextureUnitBindings(state_.active_texture_unit);
}
} }
void RasterDecoderImpl::RestoreTextureUnitBindings(unsigned unit) const { void RasterDecoderImpl::RestoreTextureUnitBindings(unsigned unit) const {
NOTIMPLEMENTED(); state_.RestoreTextureUnitBindings(unit, nullptr);
} }
void RasterDecoderImpl::RestoreVertexAttribArray(unsigned index) { void RasterDecoderImpl::RestoreVertexAttribArray(unsigned index) {
...@@ -790,7 +856,30 @@ void RasterDecoderImpl::RestoreVertexAttribArray(unsigned index) { ...@@ -790,7 +856,30 @@ void RasterDecoderImpl::RestoreVertexAttribArray(unsigned index) {
} }
void RasterDecoderImpl::RestoreAllExternalTextureBindingsIfNeeded() { void RasterDecoderImpl::RestoreAllExternalTextureBindingsIfNeeded() {
NOTIMPLEMENTED(); if (texture_manager()->GetServiceIdGeneration() ==
texture_manager_service_id_generation_)
return;
// Texture manager's version has changed, so rebind all external textures
// in case their service ids have changed.
for (unsigned texture_unit_index = 0;
texture_unit_index < state_.texture_units.size(); texture_unit_index++) {
const TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
if (texture_unit.bind_target != GL_TEXTURE_EXTERNAL_OES)
continue;
if (TextureRef* texture_ref =
texture_unit.bound_texture_external_oes.get()) {
api()->glActiveTextureFn(GL_TEXTURE0 + texture_unit_index);
api()->glBindTextureFn(GL_TEXTURE_EXTERNAL_OES,
texture_ref->service_id());
}
}
api()->glActiveTextureFn(GL_TEXTURE0 + state_.active_texture_unit);
texture_manager_service_id_generation_ =
texture_manager()->GetServiceIdGeneration();
} }
QueryManager* RasterDecoderImpl::GetQueryManager() { QueryManager* RasterDecoderImpl::GetQueryManager() {
......
...@@ -70,6 +70,9 @@ class MockRasterDecoder : public RasterDecoder { ...@@ -70,6 +70,9 @@ class MockRasterDecoder : public RasterDecoder {
MOCK_METHOD0(PerformIdleWork, void()); MOCK_METHOD0(PerformIdleWork, void());
MOCK_CONST_METHOD0(HasPollingWork, bool()); MOCK_CONST_METHOD0(HasPollingWork, bool());
MOCK_METHOD0(PerformPollingWork, void()); MOCK_METHOD0(PerformPollingWork, void());
MOCK_CONST_METHOD0(RestoreGlobalState, void());
MOCK_CONST_METHOD0(ClearAllAttributes, void());
MOCK_CONST_METHOD0(RestoreAllAttributes, void());
MOCK_METHOD1(RestoreState, void(const gles2::ContextState* prev_state)); MOCK_METHOD1(RestoreState, void(const gles2::ContextState* prev_state));
MOCK_CONST_METHOD0(RestoreActiveTexture, void()); MOCK_CONST_METHOD0(RestoreActiveTexture, void());
MOCK_CONST_METHOD1(RestoreAllTextureUnitAndSamplerBindings, MOCK_CONST_METHOD1(RestoreAllTextureUnitAndSamplerBindings,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment