diff options
32 files changed, 398 insertions, 678 deletions
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index 80bd4d4..1d21dba 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -233,10 +233,6 @@ bool TextureLayer::Update(ResourceUpdateQueue* queue, } } else { texture_id_ = client_->PrepareTexture(); - DCHECK_EQ(!!texture_id_, !!client_->Context3d()); - if (client_->Context3d() && - client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR) - texture_id_ = 0; updated = true; SetNeedsPushProperties(); // The texture id needs to be removed from the active tree before the diff --git a/cc/layers/texture_layer_client.h b/cc/layers/texture_layer_client.h index 187b12f..d191a5b 100644 --- a/cc/layers/texture_layer_client.h +++ b/cc/layers/texture_layer_client.h @@ -19,10 +19,6 @@ class TextureLayerClient { // Returns the texture ID to be used for compositing. virtual unsigned PrepareTexture() = 0; - // Returns the context that is providing the texture. Used for rate limiting - // and detecting lost context. - virtual WebKit::WebGraphicsContext3D* Context3d() = 0; - // Returns true and provides a mailbox if a new frame is available. // Returns false if no new data is available // and the old mailbox is to be reused. diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 9c999fc..d793473 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -245,16 +245,12 @@ TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { class FakeTextureLayerClient : public TextureLayerClient { public: - FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} + FakeTextureLayerClient() {} virtual unsigned PrepareTexture() OVERRIDE { return 0; } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_.get(); - } - virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -265,7 +261,6 @@ class FakeTextureLayerClient : public TextureLayerClient { } private: - scoped_ptr<TestWebGraphicsContext3D> context_; DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); }; @@ -893,7 +888,7 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, TextureLayerNoMailboxIsActivatedDuringCommit() : wait_thread_("WAIT"), wait_event_(false, false), - context_(TestWebGraphicsContext3D::Create()) { + texture_(0u) { wait_thread_.Start(); } @@ -917,13 +912,16 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, PostSetNeedsCommitToMainThread(); } + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) + OVERRIDE { + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); + } + // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE { - context_->makeContextCurrent(); - return context_->createTexture(); - } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_.get(); + return texture_; } virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, @@ -1002,11 +1000,10 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, base::Thread wait_thread_; base::WaitableEvent wait_event_; base::Lock activate_lock_; + unsigned texture_; int activate_count_; - int activate_commit_; scoped_refptr<Layer> root_; scoped_refptr<TextureLayer> layer_; - scoped_ptr<TestWebGraphicsContext3D> context_; }; SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( @@ -1406,28 +1403,19 @@ class TextureLayerClientTest public TextureLayerClient { public: TextureLayerClientTest() - : context_(NULL), - texture_(0), + : texture_(0), commit_count_(0), expected_used_textures_on_draw_(0), expected_used_textures_on_commit_(0) {} virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE { - scoped_ptr<TestWebGraphicsContext3D> context( - TestWebGraphicsContext3D::Create()); - context_ = context.get(); - texture_ = context->createTexture(); - return FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>(); - } - - virtual unsigned PrepareTexture() OVERRIDE { - return texture_; + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_; - } + virtual unsigned PrepareTexture() OVERRIDE { return texture_; } virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, @@ -1470,7 +1458,6 @@ class TextureLayerClientTest base::AutoLock lock(lock_); expected_used_textures_on_commit_ = 0; } - texture_ = 0; break; case 2: EndTest(); @@ -1489,21 +1476,26 @@ class TextureLayerClientTest virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, LayerTreeHostImpl::FrameData* frame_data, bool result) OVERRIDE { - context_->ResetUsedTextures(); + ContextForImplThread(host_impl)->ResetUsedTextures(); return true; } virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) OVERRIDE { ASSERT_TRUE(result); - EXPECT_EQ(expected_used_textures_on_draw_, context_->NumUsedTextures()); + EXPECT_EQ(expected_used_textures_on_draw_, + ContextForImplThread(host_impl)->NumUsedTextures()); } virtual void AfterTest() OVERRIDE {} private: + TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { + return static_cast<TestWebGraphicsContext3D*>( + host_impl->output_surface()->context_provider()->Context3d()); + } + scoped_refptr<TextureLayer> texture_layer_; - TestWebGraphicsContext3D* context_; unsigned texture_; int commit_count_; @@ -1528,25 +1520,23 @@ class TextureLayerChangeInvisibleTest public TextureLayerClient { public: TextureLayerChangeInvisibleTest() - : client_context_(TestWebGraphicsContext3D::Create()), - texture_(client_context_->createTexture()), - texture_to_delete_on_next_commit_(0), + : texture_(0u), prepare_called_(0), commit_count_(0), expected_texture_on_draw_(0) {} + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) + OVERRIDE { + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); + } + // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE { ++prepare_called_; return texture_; } - - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return client_context_.get(); - } - - // TextureLayerClient implementation. virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1597,9 +1587,6 @@ class TextureLayerChangeInvisibleTest case 2: { // Layer shouldn't have been updated. EXPECT_EQ(1, prepare_called_); - // Change the texture. - texture_to_delete_on_next_commit_ = texture_; - texture_ = client_context_->createTexture(); texture_layer_->SetNeedsDisplay(); // Force a change to make sure we draw a frame. solid_layer_->SetBackgroundColor(SK_ColorGRAY); @@ -1607,8 +1594,6 @@ class TextureLayerChangeInvisibleTest } case 3: EXPECT_EQ(1, prepare_called_); - client_context_->deleteTexture(texture_to_delete_on_next_commit_); - texture_to_delete_on_next_commit_ = 0; // Make layer visible again. parent_layer_->SetOpacity(1.f); break; @@ -1616,7 +1601,6 @@ class TextureLayerChangeInvisibleTest // Layer should have been updated. EXPECT_EQ(2, prepare_called_); texture_layer_->ClearClient(); - client_context_->deleteTexture(texture_); texture_ = 0; break; } @@ -1676,14 +1660,12 @@ class TextureLayerChangeInvisibleTest scoped_refptr<SolidColorLayer> solid_layer_; scoped_refptr<Layer> parent_layer_; scoped_refptr<TextureLayer> texture_layer_; - scoped_ptr<TestWebGraphicsContext3D> client_context_; // Used on the main thread, and on the impl thread while the main thread is // blocked. unsigned texture_; // Used on the main thread. - unsigned texture_to_delete_on_next_commit_; int prepare_called_; int commit_count_; @@ -1710,12 +1692,6 @@ class TextureLayerNoExtraCommitForMailboxTest return 0; } - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - NOTREACHED(); - return NULL; - } - virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1819,13 +1795,6 @@ class TextureLayerChangeInvisibleMailboxTest return 0; } - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - NOTREACHED(); - return NULL; - } - - // TextureLayerClient implementation. virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1965,26 +1934,20 @@ class TextureLayerLostContextTest public TextureLayerClient { public: TextureLayerLostContextTest() - : texture_(0), + : context_lost_(false), draw_count_(0) {} virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE { - texture_context_ = TestWebGraphicsContext3D::Create(); - texture_ = texture_context_->createTexture(); return CreateFakeOutputSurface(); } virtual unsigned PrepareTexture() OVERRIDE { - if (draw_count_ == 0) { - texture_context_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, - GL_INNOCENT_CONTEXT_RESET_ARB); - } - return texture_; - } - - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return texture_context_.get(); + if (draw_count_ == 0) + context_lost_ = true; + if (context_lost_) + return 0u; + return 1u; } virtual bool PrepareTextureMailbox( @@ -2021,7 +1984,7 @@ class TextureLayerLostContextTest if (++draw_count_ == 1) EXPECT_EQ(0u, texture_layer->texture_id()); else - EXPECT_EQ(texture_, texture_layer->texture_id()); + EXPECT_EQ(1u, texture_layer->texture_id()); return true; } @@ -2033,8 +1996,7 @@ class TextureLayerLostContextTest private: scoped_refptr<TextureLayer> texture_layer_; - scoped_ptr<TestWebGraphicsContext3D> texture_context_; - unsigned texture_; + bool context_lost_; int draw_count_; }; diff --git a/cc/output/context_provider.cc b/cc/output/context_provider.cc index a823fa2..853a519 100644 --- a/cc/output/context_provider.cc +++ b/cc/output/context_provider.cc @@ -9,8 +9,7 @@ namespace cc { ContextProvider::Capabilities::Capabilities() - : bind_uniform_location(false), - discard_backbuffer(false), + : discard_backbuffer(false), egl_image_external(false), fast_npot_mo8_textures(false), iosurface(false), diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index 0a794d7..d87127c 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -29,7 +29,6 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { virtual class GrContext* GrContext() = 0; struct Capabilities { - bool bind_uniform_location; bool discard_backbuffer; bool egl_image_external; bool fast_npot_mo8_textures; @@ -53,6 +52,9 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { // Returns the capabilities of the currently bound 3d context. virtual Capabilities ContextCapabilities() = 0; + // Checks if the context is currently known to be lost. + virtual bool IsContextLost() = 0; + // Ask the provider to check if the contexts are valid or lost. If they are, // this should invalidate the provider so that it can be replaced with a new // one. diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc index 9195e80..5140532 100644 --- a/cc/output/delegating_renderer.cc +++ b/cc/output/delegating_renderer.cc @@ -149,8 +149,7 @@ bool DelegatingRenderer::IsContextLost() { ContextProvider* context_provider = output_surface_->context_provider(); if (!context_provider) return false; - return context_provider->Context3d()->getGraphicsResetStatusARB() != - GL_NO_ERROR; + return context_provider->IsContextLost(); } void DelegatingRenderer::SetVisible(bool visible) { diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 8c201aa..7a3065a 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -166,7 +166,6 @@ GLRenderer::GLRenderer(RendererClient* client, context_support_(output_surface->context_provider()->ContextSupport()), texture_mailbox_deleter_(texture_mailbox_deleter), is_backbuffer_discarded_(false), - is_using_bind_uniform_(false), visible_(true), is_scissor_enabled_(false), stencil_shadow_(false), @@ -212,8 +211,6 @@ bool GLRenderer::Initialize() { capabilities_.using_discard_framebuffer = context_caps.discard_framebuffer; - is_using_bind_uniform_ = context_caps.bind_uniform_location; - if (!InitializeSharedObjects()) return false; @@ -1705,8 +1702,8 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, struct TextureProgramBinding { template <class Program> - void Set(Program* program, WebKit::WebGraphicsContext3D* context) { - DCHECK(program && (program->initialized() || context->isContextLost())); + void Set(Program* program) { + DCHECK(program); program_id = program->program(); sampler_location = program->fragment_shader().sampler_location(); matrix_location = program->vertex_shader().matrix_location(); @@ -1721,8 +1718,8 @@ struct TextureProgramBinding { struct TexTransformTextureProgramBinding : TextureProgramBinding { template <class Program> - void Set(Program* program, WebKit::WebGraphicsContext3D* context) { - TextureProgramBinding::Set(program, context); + void Set(Program* program) { + TextureProgramBinding::Set(program); tex_transform_location = program->vertex_shader().tex_transform_location(); vertex_opacity_location = program->vertex_shader().vertex_opacity_location(); @@ -1809,18 +1806,16 @@ void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, TexTransformTextureProgramBinding binding; if (quad->premultiplied_alpha) { if (quad->background_color == SK_ColorTRANSPARENT) { - binding.Set(GetTextureProgram(tex_coord_precision), Context()); + binding.Set(GetTextureProgram(tex_coord_precision)); } else { - binding.Set(GetTextureBackgroundProgram(tex_coord_precision), Context()); + binding.Set(GetTextureBackgroundProgram(tex_coord_precision)); } } else { if (quad->background_color == SK_ColorTRANSPARENT) { - binding.Set(GetNonPremultipliedTextureProgram(tex_coord_precision), - Context()); + binding.Set(GetNonPremultipliedTextureProgram(tex_coord_precision)); } else { binding.Set( - GetNonPremultipliedTextureBackgroundProgram(tex_coord_precision), - Context()); + GetNonPremultipliedTextureBackgroundProgram(tex_coord_precision)); } } @@ -1873,7 +1868,7 @@ void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, quad->shared_quad_state->visible_content_rect.bottom_right()); TexTransformTextureProgramBinding binding; - binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision), Context()); + binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); SetUseProgram(binding.program_id); GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); @@ -2516,23 +2511,23 @@ bool GLRenderer::InitializeSharedObjects() { // Create an FBO for doing offscreen rendering. GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); - // We will always need these programs to render, so create the programs - // eagerly so that the shader compilation can start while we do other work. - // Other programs are created lazily on first access. shared_geometry_ = make_scoped_ptr( new GeometryBinding(context_, QuadVertexRect())); - render_pass_program_ = make_scoped_ptr( - new RenderPassProgram(context_, TexCoordPrecisionMedium)); - render_pass_program_highp_ = make_scoped_ptr( - new RenderPassProgram(context_, TexCoordPrecisionHigh)); - tile_program_ = make_scoped_ptr( - new TileProgram(context_, TexCoordPrecisionMedium)); - tile_program_opaque_ = make_scoped_ptr( - new TileProgramOpaque(context_, TexCoordPrecisionMedium)); - tile_program_highp_ = make_scoped_ptr( - new TileProgram(context_, TexCoordPrecisionHigh)); - tile_program_opaque_highp_ = make_scoped_ptr( - new TileProgramOpaque(context_, TexCoordPrecisionHigh)); + // We will always need these programs to render, so initialize the programs + // eagerly so that the shader compilation can start while we do other work. + // Other programs are initialized lazily on first access. + render_pass_program_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionMedium); + render_pass_program_highp_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionHigh); + tile_program_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionMedium); + tile_program_opaque_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionMedium); + tile_program_highp_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionHigh); + tile_program_opaque_highp_.Initialize(output_surface_->context_provider(), + TexCoordPrecisionHigh); GLC(context_, context_->flush()); @@ -2541,382 +2536,318 @@ bool GLRenderer::InitializeSharedObjects() { const GLRenderer::TileCheckerboardProgram* GLRenderer::GetTileCheckerboardProgram() { - if (!tile_checkerboard_program_) - tile_checkerboard_program_ = make_scoped_ptr( - new TileCheckerboardProgram(context_, TexCoordPrecisionNA)); - if (!tile_checkerboard_program_->initialized()) { + if (!tile_checkerboard_program_.initialized()) { TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); - tile_checkerboard_program_->Initialize(context_, is_using_bind_uniform_); + tile_checkerboard_program_.Initialize( + output_surface_->context_provider(), TexCoordPrecisionNA); } - return tile_checkerboard_program_.get(); + return &tile_checkerboard_program_; } const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { - if (!debug_border_program_) - debug_border_program_ = make_scoped_ptr( - new DebugBorderProgram(context_, TexCoordPrecisionNA)); - if (!debug_border_program_->initialized()) { + if (!debug_border_program_.initialized()) { TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); - debug_border_program_->Initialize(context_, is_using_bind_uniform_); + debug_border_program_.Initialize( + output_surface_->context_provider(), TexCoordPrecisionNA); } - return debug_border_program_.get(); + return &debug_border_program_; } const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { - if (!solid_color_program_) - solid_color_program_ = make_scoped_ptr( - new SolidColorProgram(context_, TexCoordPrecisionNA)); - if (!solid_color_program_->initialized()) { + if (!solid_color_program_.initialized()) { TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); - solid_color_program_->Initialize(context_, is_using_bind_uniform_); + solid_color_program_.Initialize( + output_surface_->context_provider(), TexCoordPrecisionNA); } - return solid_color_program_.get(); + return &solid_color_program_; } const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { - if (!solid_color_program_aa_) { - solid_color_program_aa_ = - make_scoped_ptr(new SolidColorProgramAA(context_, TexCoordPrecisionNA)); - } - if (!solid_color_program_aa_->initialized()) { + if (!solid_color_program_aa_.initialized()) { TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); - solid_color_program_aa_->Initialize(context_, is_using_bind_uniform_); + solid_color_program_aa_.Initialize( + output_surface_->context_provider(), TexCoordPrecisionNA); } - return solid_color_program_aa_.get(); + return &solid_color_program_aa_; } const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( TexCoordPrecision precision) { - scoped_ptr<RenderPassProgram>& program = - (precision == TexCoordPrecisionHigh) ? render_pass_program_highp_ - : render_pass_program_; - DCHECK(program); + RenderPassProgram* program = + (precision == TexCoordPrecisionHigh) ? &render_pass_program_highp_ + : &render_pass_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( TexCoordPrecision precision) { - scoped_ptr<RenderPassProgramAA>& program = - (precision == TexCoordPrecisionHigh) ? render_pass_program_aa_highp_ - : render_pass_program_aa_; - if (!program) - program = - make_scoped_ptr(new RenderPassProgramAA(context_, precision)); + RenderPassProgramAA* program = + (precision == TexCoordPrecisionHigh) ? &render_pass_program_aa_highp_ + : &render_pass_program_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { - scoped_ptr<RenderPassMaskProgram>& program = - (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_highp_ - : render_pass_mask_program_; - if (!program) - program = make_scoped_ptr(new RenderPassMaskProgram(context_, precision)); + RenderPassMaskProgram* program = + (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_highp_ + : &render_pass_mask_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassMaskProgramAA* GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { - scoped_ptr<RenderPassMaskProgramAA>& program = - (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_aa_highp_ - : render_pass_mask_program_aa_; - if (!program) - program = - make_scoped_ptr(new RenderPassMaskProgramAA(context_, precision)); + RenderPassMaskProgramAA* program = + (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_aa_highp_ + : &render_pass_mask_program_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassColorMatrixProgram* GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { - scoped_ptr<RenderPassColorMatrixProgram>& program = + RenderPassColorMatrixProgram* program = (precision == TexCoordPrecisionHigh) ? - render_pass_color_matrix_program_highp_ : - render_pass_color_matrix_program_; - if (!program) - program = make_scoped_ptr( - new RenderPassColorMatrixProgram(context_, precision)); + &render_pass_color_matrix_program_highp_ : + &render_pass_color_matrix_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassColorMatrixProgramAA* GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { - scoped_ptr<RenderPassColorMatrixProgramAA>& program = + RenderPassColorMatrixProgramAA* program = (precision == TexCoordPrecisionHigh) ? - render_pass_color_matrix_program_aa_highp_ : - render_pass_color_matrix_program_aa_; - if (!program) - program = make_scoped_ptr( - new RenderPassColorMatrixProgramAA(context_, precision)); + &render_pass_color_matrix_program_aa_highp_ : + &render_pass_color_matrix_program_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgramAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassMaskColorMatrixProgram* GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { - scoped_ptr<RenderPassMaskColorMatrixProgram>& program = + RenderPassMaskColorMatrixProgram* program = (precision == TexCoordPrecisionHigh) ? - render_pass_mask_color_matrix_program_highp_ : - render_pass_mask_color_matrix_program_; - if (!program) - program = make_scoped_ptr( - new RenderPassMaskColorMatrixProgram(context_, precision)); + &render_pass_mask_color_matrix_program_highp_ : + &render_pass_mask_color_matrix_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::RenderPassMaskColorMatrixProgramAA* GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { - scoped_ptr<RenderPassMaskColorMatrixProgramAA>& program = + RenderPassMaskColorMatrixProgramAA* program = (precision == TexCoordPrecisionHigh) ? - render_pass_mask_color_matrix_program_aa_highp_ : - render_pass_mask_color_matrix_program_aa_; - if (!program) - program = make_scoped_ptr( - new RenderPassMaskColorMatrixProgramAA(context_, precision)); + &render_pass_mask_color_matrix_program_aa_highp_ : + &render_pass_mask_color_matrix_program_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgram* GLRenderer::GetTileProgram( TexCoordPrecision precision) { - scoped_ptr<TileProgram>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_highp_ - : tile_program_; - DCHECK(program); + TileProgram* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_highp_ + : &tile_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( TexCoordPrecision precision) { - scoped_ptr<TileProgramOpaque>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_opaque_highp_ - : tile_program_opaque_; + TileProgramOpaque* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_opaque_highp_ + : &tile_program_opaque_; DCHECK(program); if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( TexCoordPrecision precision) { - scoped_ptr<TileProgramAA>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_aa_highp_ - : tile_program_aa_; - if (!program) - program = make_scoped_ptr(new TileProgramAA(context_, precision)); + TileProgramAA* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_aa_highp_ + : &tile_program_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( TexCoordPrecision precision) { - scoped_ptr<TileProgramSwizzle>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_swizzle_highp_ - : tile_program_swizzle_; - if (!program) - program = make_scoped_ptr(new TileProgramSwizzle(context_, precision)); + TileProgramSwizzle* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_highp_ + : &tile_program_swizzle_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgramSwizzleOpaque* GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision) { - scoped_ptr<TileProgramSwizzleOpaque>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_swizzle_opaque_highp_ - : tile_program_swizzle_opaque_; - if (!program) - program = make_scoped_ptr( - new TileProgramSwizzleOpaque(context_, precision)); + TileProgramSwizzleOpaque* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_opaque_highp_ + : &tile_program_swizzle_opaque_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( TexCoordPrecision precision) { - scoped_ptr<TileProgramSwizzleAA>& program = - (precision == TexCoordPrecisionHigh) ? tile_program_swizzle_aa_highp_ - : tile_program_swizzle_aa_; - if (!program) - program = make_scoped_ptr(new TileProgramSwizzleAA(context_, precision)); + TileProgramSwizzleAA* program = + (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_aa_highp_ + : &tile_program_swizzle_aa_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( TexCoordPrecision precision) { - scoped_ptr<TextureProgram>& program = - (precision == TexCoordPrecisionHigh) ? texture_program_highp_ - : texture_program_; - if (!program) - program = make_scoped_ptr(new TextureProgram(context_, precision)); + TextureProgram* program = + (precision == TexCoordPrecisionHigh) ? &texture_program_highp_ + : &texture_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::NonPremultipliedTextureProgram* GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { - scoped_ptr<NonPremultipliedTextureProgram>& program = + NonPremultipliedTextureProgram* program = (precision == TexCoordPrecisionHigh) ? - nonpremultiplied_texture_program_highp_ : - nonpremultiplied_texture_program_; - if (!program) { - program = make_scoped_ptr( - new NonPremultipliedTextureProgram(context_, precision)); - } + &nonpremultiplied_texture_program_highp_ : + &nonpremultiplied_texture_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::NonPremultipliedTextureProgram::Initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TextureBackgroundProgram* GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision) { - scoped_ptr<TextureBackgroundProgram>& program = - (precision == TexCoordPrecisionHigh) ? texture_background_program_highp_ - : texture_background_program_; - if (!program) { - program = make_scoped_ptr( - new TextureBackgroundProgram(context_, precision)); - } + TextureBackgroundProgram* program = + (precision == TexCoordPrecisionHigh) ? &texture_background_program_highp_ + : &texture_background_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::NonPremultipliedTextureBackgroundProgram* GLRenderer::GetNonPremultipliedTextureBackgroundProgram( TexCoordPrecision precision) { - scoped_ptr<NonPremultipliedTextureBackgroundProgram>& program = + NonPremultipliedTextureBackgroundProgram* program = (precision == TexCoordPrecisionHigh) ? - nonpremultiplied_texture_background_program_highp_ : - nonpremultiplied_texture_background_program_; - if (!program) { - program = make_scoped_ptr( - new NonPremultipliedTextureBackgroundProgram(context_, precision)); - } + &nonpremultiplied_texture_background_program_highp_ : + &nonpremultiplied_texture_background_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::NonPremultipliedTextureProgram::Initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::TextureIOSurfaceProgram* GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { - scoped_ptr<TextureIOSurfaceProgram>& program = - (precision == TexCoordPrecisionHigh) ? texture_io_surface_program_highp_ - : texture_io_surface_program_; - if (!program) - program = - make_scoped_ptr(new TextureIOSurfaceProgram(context_, precision)); + TextureIOSurfaceProgram* program = + (precision == TexCoordPrecisionHigh) ? &texture_io_surface_program_highp_ + : &texture_io_surface_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( TexCoordPrecision precision) { - scoped_ptr<VideoYUVProgram>& program = - (precision == TexCoordPrecisionHigh) ? video_yuv_program_highp_ - : video_yuv_program_; - if (!program) - program = make_scoped_ptr(new VideoYUVProgram(context_, precision)); + VideoYUVProgram* program = + (precision == TexCoordPrecisionHigh) ? &video_yuv_program_highp_ + : &video_yuv_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram( TexCoordPrecision precision) { - scoped_ptr<VideoYUVAProgram>& program = - (precision == TexCoordPrecisionHigh) ? video_yuva_program_highp_ - : video_yuva_program_; - if (!program) - program = make_scoped_ptr(new VideoYUVAProgram(context_, precision)); + VideoYUVAProgram* program = + (precision == TexCoordPrecisionHigh) ? &video_yuva_program_highp_ + : &video_yuva_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } const GLRenderer::VideoStreamTextureProgram* GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { if (!Capabilities().using_egl_image) return NULL; - scoped_ptr<VideoStreamTextureProgram>& program = - (precision == TexCoordPrecisionHigh) ? video_stream_texture_program_highp_ - : video_stream_texture_program_; - if (!program) - program = - make_scoped_ptr(new VideoStreamTextureProgram(context_, precision)); + VideoStreamTextureProgram* program = (precision == TexCoordPrecisionHigh) + ? &video_stream_texture_program_highp_ + : &video_stream_texture_program_; if (!program->initialized()) { TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); - program->Initialize(context_, is_using_bind_uniform_); + program->Initialize(output_surface_->context_provider(), precision); } - return program.get(); + return program; } void GLRenderer::CleanupSharedObjects() { @@ -2924,110 +2855,62 @@ void GLRenderer::CleanupSharedObjects() { shared_geometry_.reset(); - if (tile_program_) - tile_program_->Cleanup(context_); - if (tile_program_opaque_) - tile_program_opaque_->Cleanup(context_); - if (tile_program_swizzle_) - tile_program_swizzle_->Cleanup(context_); - if (tile_program_swizzle_opaque_) - tile_program_swizzle_opaque_->Cleanup(context_); - if (tile_program_aa_) - tile_program_aa_->Cleanup(context_); - if (tile_program_swizzle_aa_) - tile_program_swizzle_aa_->Cleanup(context_); - if (tile_checkerboard_program_) - tile_checkerboard_program_->Cleanup(context_); - - if (tile_program_highp_) - tile_program_highp_->Cleanup(context_); - if (tile_program_opaque_highp_) - tile_program_opaque_highp_->Cleanup(context_); - if (tile_program_swizzle_highp_) - tile_program_swizzle_highp_->Cleanup(context_); - if (tile_program_swizzle_opaque_highp_) - tile_program_swizzle_opaque_highp_->Cleanup(context_); - if (tile_program_aa_highp_) - tile_program_aa_highp_->Cleanup(context_); - if (tile_program_swizzle_aa_highp_) - tile_program_swizzle_aa_highp_->Cleanup(context_); - - if (render_pass_mask_program_) - render_pass_mask_program_->Cleanup(context_); - if (render_pass_program_) - render_pass_program_->Cleanup(context_); - if (render_pass_mask_program_aa_) - render_pass_mask_program_aa_->Cleanup(context_); - if (render_pass_program_aa_) - render_pass_program_aa_->Cleanup(context_); - if (render_pass_color_matrix_program_) - render_pass_color_matrix_program_->Cleanup(context_); - if (render_pass_mask_color_matrix_program_aa_) - render_pass_mask_color_matrix_program_aa_->Cleanup(context_); - if (render_pass_color_matrix_program_aa_) - render_pass_color_matrix_program_aa_->Cleanup(context_); - if (render_pass_mask_color_matrix_program_) - render_pass_mask_color_matrix_program_->Cleanup(context_); - - if (render_pass_mask_program_highp_) - render_pass_mask_program_highp_->Cleanup(context_); - if (render_pass_program_highp_) - render_pass_program_highp_->Cleanup(context_); - if (render_pass_mask_program_aa_highp_) - render_pass_mask_program_aa_highp_->Cleanup(context_); - if (render_pass_program_aa_highp_) - render_pass_program_aa_highp_->Cleanup(context_); - if (render_pass_color_matrix_program_highp_) - render_pass_color_matrix_program_highp_->Cleanup(context_); - if (render_pass_mask_color_matrix_program_aa_highp_) - render_pass_mask_color_matrix_program_aa_highp_->Cleanup(context_); - if (render_pass_color_matrix_program_aa_highp_) - render_pass_color_matrix_program_aa_highp_->Cleanup(context_); - if (render_pass_mask_color_matrix_program_highp_) - render_pass_mask_color_matrix_program_highp_->Cleanup(context_); - - if (texture_program_) - texture_program_->Cleanup(context_); - if (nonpremultiplied_texture_program_) - nonpremultiplied_texture_program_->Cleanup(context_); - if (texture_background_program_) - texture_background_program_->Cleanup(context_); - if (nonpremultiplied_texture_background_program_) - nonpremultiplied_texture_background_program_->Cleanup(context_); - if (texture_io_surface_program_) - texture_io_surface_program_->Cleanup(context_); - - if (texture_program_highp_) - texture_program_highp_->Cleanup(context_); - if (nonpremultiplied_texture_program_highp_) - nonpremultiplied_texture_program_highp_->Cleanup(context_); - if (texture_background_program_highp_) - texture_background_program_highp_->Cleanup(context_); - if (nonpremultiplied_texture_background_program_highp_) - nonpremultiplied_texture_background_program_highp_->Cleanup(context_); - if (texture_io_surface_program_highp_) - texture_io_surface_program_highp_->Cleanup(context_); - - if (video_yuv_program_) - video_yuv_program_->Cleanup(context_); - if (video_yuva_program_) - video_yuva_program_->Cleanup(context_); - if (video_stream_texture_program_) - video_stream_texture_program_->Cleanup(context_); - - if (video_yuv_program_highp_) - video_yuv_program_highp_->Cleanup(context_); - if (video_yuva_program_highp_) - video_yuva_program_highp_->Cleanup(context_); - if (video_stream_texture_program_highp_) - video_stream_texture_program_highp_->Cleanup(context_); - - if (debug_border_program_) - debug_border_program_->Cleanup(context_); - if (solid_color_program_) - solid_color_program_->Cleanup(context_); - if (solid_color_program_aa_) - solid_color_program_aa_->Cleanup(context_); + tile_program_.Cleanup(context_); + tile_program_opaque_.Cleanup(context_); + tile_program_swizzle_.Cleanup(context_); + tile_program_swizzle_opaque_.Cleanup(context_); + tile_program_aa_.Cleanup(context_); + tile_program_swizzle_aa_.Cleanup(context_); + tile_checkerboard_program_.Cleanup(context_); + + tile_program_highp_.Cleanup(context_); + tile_program_opaque_highp_.Cleanup(context_); + tile_program_swizzle_highp_.Cleanup(context_); + tile_program_swizzle_opaque_highp_.Cleanup(context_); + tile_program_aa_highp_.Cleanup(context_); + tile_program_swizzle_aa_highp_.Cleanup(context_); + + render_pass_mask_program_.Cleanup(context_); + render_pass_program_.Cleanup(context_); + render_pass_mask_program_aa_.Cleanup(context_); + render_pass_program_aa_.Cleanup(context_); + render_pass_color_matrix_program_.Cleanup(context_); + render_pass_mask_color_matrix_program_aa_.Cleanup(context_); + render_pass_color_matrix_program_aa_.Cleanup(context_); + render_pass_mask_color_matrix_program_.Cleanup(context_); + + render_pass_mask_program_highp_.Cleanup(context_); + render_pass_program_highp_.Cleanup(context_); + render_pass_mask_program_aa_highp_.Cleanup(context_); + render_pass_program_aa_highp_.Cleanup(context_); + render_pass_color_matrix_program_highp_.Cleanup(context_); + render_pass_mask_color_matrix_program_aa_highp_.Cleanup(context_); + render_pass_color_matrix_program_aa_highp_.Cleanup(context_); + render_pass_mask_color_matrix_program_highp_.Cleanup(context_); + + texture_program_.Cleanup(context_); + nonpremultiplied_texture_program_.Cleanup(context_); + texture_background_program_.Cleanup(context_); + nonpremultiplied_texture_background_program_.Cleanup(context_); + texture_io_surface_program_.Cleanup(context_); + + texture_program_highp_.Cleanup(context_); + nonpremultiplied_texture_program_highp_.Cleanup(context_); + texture_background_program_highp_.Cleanup(context_); + nonpremultiplied_texture_background_program_highp_.Cleanup(context_); + texture_io_surface_program_highp_.Cleanup(context_); + + video_yuv_program_.Cleanup(context_); + video_yuva_program_.Cleanup(context_); + video_stream_texture_program_.Cleanup(context_); + + video_yuv_program_highp_.Cleanup(context_); + video_yuva_program_highp_.Cleanup(context_); + video_stream_texture_program_highp_.Cleanup(context_); + + debug_border_program_.Cleanup(context_); + solid_color_program_.Cleanup(context_); + solid_color_program_aa_.Cleanup(context_); if (offscreen_framebuffer_id_) GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); @@ -3085,7 +2968,7 @@ bool GLRenderer::CanUseSkiaGPUBackend() const { } bool GLRenderer::IsContextLost() { - return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); + return output_surface_->context_provider()->IsContextLost(); } } // namespace cc diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h index d65e638..86fc945 100644 --- a/cc/output/gl_renderer.h +++ b/cc/output/gl_renderer.h @@ -357,72 +357,65 @@ class CC_EXPORT GLRenderer : public DirectRenderer { const SolidColorProgram* GetSolidColorProgram(); const SolidColorProgramAA* GetSolidColorProgramAA(); - scoped_ptr<TileProgram> tile_program_; - scoped_ptr<TileProgramOpaque> tile_program_opaque_; - scoped_ptr<TileProgramAA> tile_program_aa_; - scoped_ptr<TileProgramSwizzle> tile_program_swizzle_; - scoped_ptr<TileProgramSwizzleOpaque> tile_program_swizzle_opaque_; - scoped_ptr<TileProgramSwizzleAA> tile_program_swizzle_aa_; - scoped_ptr<TileCheckerboardProgram> tile_checkerboard_program_; - - scoped_ptr<TileProgram> tile_program_highp_; - scoped_ptr<TileProgramOpaque> tile_program_opaque_highp_; - scoped_ptr<TileProgramAA> tile_program_aa_highp_; - scoped_ptr<TileProgramSwizzle> tile_program_swizzle_highp_; - scoped_ptr<TileProgramSwizzleOpaque> tile_program_swizzle_opaque_highp_; - scoped_ptr<TileProgramSwizzleAA> tile_program_swizzle_aa_highp_; - - scoped_ptr<TextureProgram> texture_program_; - scoped_ptr<NonPremultipliedTextureProgram> nonpremultiplied_texture_program_; - scoped_ptr<TextureBackgroundProgram> texture_background_program_; - scoped_ptr<NonPremultipliedTextureBackgroundProgram> + TileProgram tile_program_; + TileProgramOpaque tile_program_opaque_; + TileProgramAA tile_program_aa_; + TileProgramSwizzle tile_program_swizzle_; + TileProgramSwizzleOpaque tile_program_swizzle_opaque_; + TileProgramSwizzleAA tile_program_swizzle_aa_; + TileCheckerboardProgram tile_checkerboard_program_; + + TileProgram tile_program_highp_; + TileProgramOpaque tile_program_opaque_highp_; + TileProgramAA tile_program_aa_highp_; + TileProgramSwizzle tile_program_swizzle_highp_; + TileProgramSwizzleOpaque tile_program_swizzle_opaque_highp_; + TileProgramSwizzleAA tile_program_swizzle_aa_highp_; + + TextureProgram texture_program_; + NonPremultipliedTextureProgram nonpremultiplied_texture_program_; + TextureBackgroundProgram texture_background_program_; + NonPremultipliedTextureBackgroundProgram nonpremultiplied_texture_background_program_; - scoped_ptr<TextureIOSurfaceProgram> texture_io_surface_program_; + TextureIOSurfaceProgram texture_io_surface_program_; - scoped_ptr<TextureProgram> texture_program_highp_; - scoped_ptr<NonPremultipliedTextureProgram> - nonpremultiplied_texture_program_highp_; - scoped_ptr<TextureBackgroundProgram> texture_background_program_highp_; - scoped_ptr<NonPremultipliedTextureBackgroundProgram> + TextureProgram texture_program_highp_; + NonPremultipliedTextureProgram nonpremultiplied_texture_program_highp_; + TextureBackgroundProgram texture_background_program_highp_; + NonPremultipliedTextureBackgroundProgram nonpremultiplied_texture_background_program_highp_; - scoped_ptr<TextureIOSurfaceProgram> texture_io_surface_program_highp_; - - scoped_ptr<RenderPassProgram> render_pass_program_; - scoped_ptr<RenderPassProgramAA> render_pass_program_aa_; - scoped_ptr<RenderPassMaskProgram> render_pass_mask_program_; - scoped_ptr<RenderPassMaskProgramAA> render_pass_mask_program_aa_; - scoped_ptr<RenderPassColorMatrixProgram> render_pass_color_matrix_program_; - scoped_ptr<RenderPassColorMatrixProgramAA> - render_pass_color_matrix_program_aa_; - scoped_ptr<RenderPassMaskColorMatrixProgram> - render_pass_mask_color_matrix_program_; - scoped_ptr<RenderPassMaskColorMatrixProgramAA> - render_pass_mask_color_matrix_program_aa_; - - scoped_ptr<RenderPassProgram> render_pass_program_highp_; - scoped_ptr<RenderPassProgramAA> render_pass_program_aa_highp_; - scoped_ptr<RenderPassMaskProgram> render_pass_mask_program_highp_; - scoped_ptr<RenderPassMaskProgramAA> render_pass_mask_program_aa_highp_; - scoped_ptr<RenderPassColorMatrixProgram> - render_pass_color_matrix_program_highp_; - scoped_ptr<RenderPassColorMatrixProgramAA> - render_pass_color_matrix_program_aa_highp_; - scoped_ptr<RenderPassMaskColorMatrixProgram> - render_pass_mask_color_matrix_program_highp_; - scoped_ptr<RenderPassMaskColorMatrixProgramAA> + TextureIOSurfaceProgram texture_io_surface_program_highp_; + + RenderPassProgram render_pass_program_; + RenderPassProgramAA render_pass_program_aa_; + RenderPassMaskProgram render_pass_mask_program_; + RenderPassMaskProgramAA render_pass_mask_program_aa_; + RenderPassColorMatrixProgram render_pass_color_matrix_program_; + RenderPassColorMatrixProgramAA render_pass_color_matrix_program_aa_; + RenderPassMaskColorMatrixProgram render_pass_mask_color_matrix_program_; + RenderPassMaskColorMatrixProgramAA render_pass_mask_color_matrix_program_aa_; + + RenderPassProgram render_pass_program_highp_; + RenderPassProgramAA render_pass_program_aa_highp_; + RenderPassMaskProgram render_pass_mask_program_highp_; + RenderPassMaskProgramAA render_pass_mask_program_aa_highp_; + RenderPassColorMatrixProgram render_pass_color_matrix_program_highp_; + RenderPassColorMatrixProgramAA render_pass_color_matrix_program_aa_highp_; + RenderPassMaskColorMatrixProgram render_pass_mask_color_matrix_program_highp_; + RenderPassMaskColorMatrixProgramAA render_pass_mask_color_matrix_program_aa_highp_; - scoped_ptr<VideoYUVProgram> video_yuv_program_; - scoped_ptr<VideoYUVAProgram> video_yuva_program_; - scoped_ptr<VideoStreamTextureProgram> video_stream_texture_program_; + VideoYUVProgram video_yuv_program_; + VideoYUVAProgram video_yuva_program_; + VideoStreamTextureProgram video_stream_texture_program_; - scoped_ptr<VideoYUVProgram> video_yuv_program_highp_; - scoped_ptr<VideoYUVAProgram> video_yuva_program_highp_; - scoped_ptr<VideoStreamTextureProgram> video_stream_texture_program_highp_; + VideoYUVProgram video_yuv_program_highp_; + VideoYUVAProgram video_yuva_program_highp_; + VideoStreamTextureProgram video_stream_texture_program_highp_; - scoped_ptr<DebugBorderProgram> debug_border_program_; - scoped_ptr<SolidColorProgram> solid_color_program_; - scoped_ptr<SolidColorProgramAA> solid_color_program_aa_; + DebugBorderProgram debug_border_program_; + SolidColorProgram solid_color_program_; + SolidColorProgramAA solid_color_program_aa_; WebKit::WebGraphicsContext3D* context_; gpu::ContextSupport* context_support_; diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 36daf00..daf7868 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -57,8 +57,8 @@ namespace cc { #define EXPECT_PROGRAM_VALID(program_binding) \ do { \ - EXPECT_TRUE(program_binding->program()); \ - EXPECT_TRUE(program_binding->initialized()); \ + EXPECT_TRUE((program_binding)->program()); \ + EXPECT_TRUE((program_binding)->initialized()); \ } while (false) // Explicitly named to be a friend in GLRenderer for shader access. @@ -262,56 +262,56 @@ class GLRendererShaderTest : public testing::Test { } void TestRenderPassProgram() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_program_); - EXPECT_EQ(renderer_->render_pass_program_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_); + EXPECT_EQ(renderer_->render_pass_program_.program(), renderer_->program_shadow_); } void TestRenderPassColorMatrixProgram() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_); - EXPECT_EQ(renderer_->render_pass_color_matrix_program_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_); + EXPECT_EQ(renderer_->render_pass_color_matrix_program_.program(), renderer_->program_shadow_); } void TestRenderPassMaskProgram() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_); - EXPECT_EQ(renderer_->render_pass_mask_program_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_); + EXPECT_EQ(renderer_->render_pass_mask_program_.program(), renderer_->program_shadow_); } void TestRenderPassMaskColorMatrixProgram() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_); - EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_); + EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_.program(), renderer_->program_shadow_); } void TestRenderPassProgramAA() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_program_aa_); - EXPECT_EQ(renderer_->render_pass_program_aa_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_program_aa_); + EXPECT_EQ(renderer_->render_pass_program_aa_.program(), renderer_->program_shadow_); } void TestRenderPassColorMatrixProgramAA() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_color_matrix_program_aa_); - EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_color_matrix_program_aa_); + EXPECT_EQ(renderer_->render_pass_color_matrix_program_aa_.program(), renderer_->program_shadow_); } void TestRenderPassMaskProgramAA() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_program_aa_); - EXPECT_EQ(renderer_->render_pass_mask_program_aa_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_program_aa_); + EXPECT_EQ(renderer_->render_pass_mask_program_aa_.program(), renderer_->program_shadow_); } void TestRenderPassMaskColorMatrixProgramAA() { - EXPECT_PROGRAM_VALID(renderer_->render_pass_mask_color_matrix_program_aa_); - EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_->program(), + EXPECT_PROGRAM_VALID(&renderer_->render_pass_mask_color_matrix_program_aa_); + EXPECT_EQ(renderer_->render_pass_mask_color_matrix_program_aa_.program(), renderer_->program_shadow_); } void TestSolidColorProgramAA() { - EXPECT_PROGRAM_VALID(renderer_->solid_color_program_aa_); - EXPECT_EQ(renderer_->solid_color_program_aa_->program(), + EXPECT_PROGRAM_VALID(&renderer_->solid_color_program_aa_); + EXPECT_EQ(renderer_->solid_color_program_aa_.program(), renderer_->program_shadow_); } @@ -570,9 +570,7 @@ TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) { class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { public: - LoseContextOnFirstGetContext() : context_lost_(false) {} - - virtual bool makeContextCurrent() OVERRIDE { return !context_lost_; } + LoseContextOnFirstGetContext() {} virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) OVERRIDE { @@ -585,13 +583,6 @@ class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D { context_lost_ = true; *value = 0; } - - virtual WGC3Denum getGraphicsResetStatusARB() OVERRIDE { - return context_lost_ ? 1 : 0; - } - - private: - bool context_lost_; }; TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) { diff --git a/cc/output/program_binding.cc b/cc/output/program_binding.cc index 5b7b13e..d68df80 100644 --- a/cc/output/program_binding.cc +++ b/cc/output/program_binding.cc @@ -28,49 +28,47 @@ ProgramBindingBase::~ProgramBindingBase() { DCHECK(!initialized_); } -void ProgramBindingBase::Init(WebGraphicsContext3D* context, +bool ProgramBindingBase::Init(WebGraphicsContext3D* context, const std::string& vertex_shader, const std::string& fragment_shader) { TRACE_EVENT0("cc", "ProgramBindingBase::init"); vertex_shader_id_ = LoadShader(context, GL_VERTEX_SHADER, vertex_shader); - if (!vertex_shader_id_) { - if (!IsContextLost(context)) - LOG(ERROR) << "Failed to create vertex shader"; - return; - } + if (!vertex_shader_id_) + return false; fragment_shader_id_ = LoadShader(context, GL_FRAGMENT_SHADER, fragment_shader); if (!fragment_shader_id_) { GLC(context, context->deleteShader(vertex_shader_id_)); vertex_shader_id_ = 0; - if (!IsContextLost(context)) - LOG(ERROR) << "Failed to create fragment shader"; - return; + return false; } program_ = CreateShaderProgram(context, vertex_shader_id_, fragment_shader_id_); - DCHECK(program_ || IsContextLost(context)); + return !!program_; } -void ProgramBindingBase::Link(WebGraphicsContext3D* context) { +bool ProgramBindingBase::Link(WebGraphicsContext3D* context) { GLC(context, context->linkProgram(program_)); CleanupShaders(context); if (!program_) - return; + return false; #ifndef NDEBUG int linked = 0; GLC(context, context->getProgramiv(program_, GL_LINK_STATUS, &linked)); if (!linked) { - if (!IsContextLost(context)) - LOG(ERROR) << "Failed to link shader program"; GLC(context, context->deleteProgram(program_)); + return false; } #endif + return true; } void ProgramBindingBase::Cleanup(WebGraphicsContext3D* context) { + if (!initialized_) + return; + initialized_ = false; if (!program_) return; @@ -105,11 +103,8 @@ unsigned ProgramBindingBase::CreateShaderProgram(WebGraphicsContext3D* context, unsigned vertex_shader, unsigned fragment_shader) { unsigned program_object = context->createProgram(); - if (!program_object) { - if (!IsContextLost(context)) - LOG(ERROR) << "Failed to create shader program"; + if (!program_object) return 0; - } GLC(context, context->attachShader(program_object, vertex_shader)); GLC(context, context->attachShader(program_object, fragment_shader)); @@ -143,8 +138,4 @@ void ProgramBindingBase::CleanupShaders(WebGraphicsContext3D* context) { } } -bool ProgramBindingBase::IsContextLost(WebGraphicsContext3D* context) { - return (context->getGraphicsResetStatusARB() != GL_NO_ERROR); -} - } // namespace cc diff --git a/cc/output/program_binding.h b/cc/output/program_binding.h index ee9d284..01efa9c 100644 --- a/cc/output/program_binding.h +++ b/cc/output/program_binding.h @@ -8,6 +8,7 @@ #include <string> #include "base/logging.h" +#include "cc/output/context_provider.h" #include "cc/output/shader.h" namespace WebKit { class WebGraphicsContext3D; } @@ -19,10 +20,10 @@ class ProgramBindingBase { ProgramBindingBase(); ~ProgramBindingBase(); - void Init(WebKit::WebGraphicsContext3D* context, + bool Init(WebKit::WebGraphicsContext3D* context, const std::string& vertex_shader, const std::string& fragment_shader); - void Link(WebKit::WebGraphicsContext3D* context); + bool Link(WebKit::WebGraphicsContext3D* context); void Cleanup(WebKit::WebGraphicsContext3D* context); unsigned program() const { return program_; } @@ -36,7 +37,6 @@ class ProgramBindingBase { unsigned vertex_shader, unsigned fragment_shader); void CleanupShaders(WebKit::WebGraphicsContext3D* context); - bool IsContextLost(WebKit::WebGraphicsContext3D* context); unsigned program_; unsigned vertex_shader_id_; @@ -50,35 +50,35 @@ class ProgramBindingBase { template <class VertexShader, class FragmentShader> class ProgramBinding : public ProgramBindingBase { public: - explicit ProgramBinding(WebKit::WebGraphicsContext3D* context, - TexCoordPrecision precision) { - ProgramBindingBase::Init( - context, - vertex_shader_.GetShaderString(), - fragment_shader_.GetShaderString(precision)); - } + ProgramBinding() {} - void Initialize(WebKit::WebGraphicsContext3D* context, - bool using_bind_uniform) { - DCHECK(context); + void Initialize(ContextProvider* context_provider, + TexCoordPrecision precision) { + DCHECK(context_provider); DCHECK(!initialized_); - if (IsContextLost(context)) + if (context_provider->IsContextLost()) return; - // Need to bind uniforms before linking - if (!using_bind_uniform) - Link(context); + if (!ProgramBindingBase::Init( + context_provider->Context3d(), + vertex_shader_.GetShaderString(), + fragment_shader_.GetShaderString(precision))) { + DCHECK(context_provider->IsContextLost()); + return; + } int base_uniform_index = 0; - vertex_shader_.Init( - context, program_, using_bind_uniform, &base_uniform_index); - fragment_shader_.Init( - context, program_, using_bind_uniform, &base_uniform_index); + vertex_shader_.Init(context_provider->Context3d(), + program_, &base_uniform_index); + fragment_shader_.Init(context_provider->Context3d(), + program_, &base_uniform_index); // Link after binding uniforms - if (using_bind_uniform) - Link(context); + if (!Link(context_provider->Context3d())) { + DCHECK(context_provider->IsContextLost()); + return; + } initialized_ = true; } diff --git a/cc/output/shader.cc b/cc/output/shader.cc index beabf8d..cf4a5ed 100644 --- a/cc/output/shader.cc +++ b/cc/output/shader.cc @@ -27,16 +27,10 @@ static void GetProgramUniformLocations(WebGraphicsContext3D* context, size_t count, const char** uniforms, int* locations, - bool using_bind_uniform, int* base_uniform_index) { for (size_t i = 0; i < count; i++) { - if (using_bind_uniform) { - locations[i] = (*base_uniform_index)++; - context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); - } else { - locations[i] = context->getUniformLocation(program, uniforms[i]); - DCHECK_NE(locations[i], -1); - } + locations[i] = (*base_uniform_index)++; + context->bindUniformLocationCHROMIUM(program, locations[i], uniforms[i]); } } @@ -121,7 +115,6 @@ VertexShaderPosTex::VertexShaderPosTex() void VertexShaderPosTex::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -133,7 +126,6 @@ void VertexShaderPosTex::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; } @@ -157,7 +149,6 @@ VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch() void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -170,7 +161,6 @@ void VertexShaderPosTexYUVStretch::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; tex_scale_location_ = locations[1]; @@ -196,7 +186,6 @@ VertexShaderPos::VertexShaderPos() void VertexShaderPos::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -208,7 +197,6 @@ void VertexShaderPos::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; } @@ -230,7 +218,6 @@ VertexShaderPosTexTransform::VertexShaderPosTexTransform() void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -244,7 +231,6 @@ void VertexShaderPosTexTransform::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; tex_transform_location_ = locations[1]; @@ -288,7 +274,6 @@ VertexShaderQuad::VertexShaderQuad() void VertexShaderQuad::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -301,7 +286,6 @@ void VertexShaderQuad::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; quad_location_ = locations[1]; @@ -347,7 +331,6 @@ VertexShaderQuadAA::VertexShaderQuadAA() void VertexShaderQuadAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -362,7 +345,6 @@ void VertexShaderQuadAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; viewport_location_ = locations[1]; @@ -406,7 +388,6 @@ VertexShaderQuadTexTransformAA::VertexShaderQuadTexTransformAA() void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -422,7 +403,6 @@ void VertexShaderQuadTexTransformAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; viewport_location_ = locations[1]; @@ -468,7 +448,6 @@ VertexShaderTile::VertexShaderTile() void VertexShaderTile::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -482,7 +461,6 @@ void VertexShaderTile::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; quad_location_ = locations[1]; @@ -514,7 +492,6 @@ VertexShaderTileAA::VertexShaderTileAA() void VertexShaderTileAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -530,7 +507,6 @@ void VertexShaderTileAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; viewport_location_ = locations[1]; @@ -575,7 +551,6 @@ VertexShaderVideoTransform::VertexShaderVideoTransform() void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "matrix", @@ -588,7 +563,6 @@ void VertexShaderVideoTransform::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); matrix_location_ = locations[0]; tex_matrix_location_ = locations[1]; @@ -615,7 +589,6 @@ FragmentTexAlphaBinding::FragmentTexAlphaBinding() void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -628,7 +601,6 @@ void FragmentTexAlphaBinding::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; alpha_location_ = locations[1]; @@ -642,7 +614,6 @@ FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding() void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -657,7 +628,6 @@ void FragmentTexColorMatrixAlphaBinding::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; alpha_location_ = locations[1]; @@ -670,7 +640,6 @@ FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -682,7 +651,6 @@ void FragmentTexOpaqueBinding::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; } @@ -692,7 +660,6 @@ FragmentShaderOESImageExternal::FragmentShaderOESImageExternal() void FragmentShaderOESImageExternal::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -704,7 +671,6 @@ void FragmentShaderOESImageExternal::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; } @@ -795,7 +761,6 @@ FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -808,7 +773,6 @@ void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; @@ -925,7 +889,6 @@ FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA() void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -938,7 +901,6 @@ void FragmentShaderRGBATexAlphaAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; alpha_location_ = locations[1]; @@ -970,7 +932,6 @@ FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -984,7 +945,6 @@ void FragmentTexClampAlphaAABinding::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; alpha_location_ = locations[1]; @@ -1046,7 +1006,6 @@ FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask() void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -1062,7 +1021,6 @@ void FragmentShaderRGBATexAlphaMask::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; mask_sampler_location_ = locations[1]; @@ -1101,7 +1059,6 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -1117,7 +1074,6 @@ void FragmentShaderRGBATexAlphaMaskAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; mask_sampler_location_ = locations[1]; @@ -1164,7 +1120,6 @@ FragmentShaderRGBATexAlphaMaskColorMatrixAA:: void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -1182,7 +1137,6 @@ void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init( arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; mask_sampler_location_ = locations[1]; @@ -1236,7 +1190,6 @@ FragmentShaderRGBATexAlphaColorMatrixAA:: void FragmentShaderRGBATexAlphaColorMatrixAA::Init( WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -1251,7 +1204,6 @@ void FragmentShaderRGBATexAlphaColorMatrixAA::Init( arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; alpha_location_ = locations[1]; @@ -1295,7 +1247,6 @@ FragmentShaderRGBATexAlphaMaskColorMatrix:: void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "s_texture", @@ -1313,7 +1264,6 @@ void FragmentShaderRGBATexAlphaMaskColorMatrix::Init( arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); sampler_location_ = locations[0]; mask_sampler_location_ = locations[1]; @@ -1362,7 +1312,6 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo() void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "y_texture", @@ -1379,7 +1328,6 @@ void FragmentShaderYUVVideo::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); y_texture_location_ = locations[0]; u_texture_location_ = locations[1]; @@ -1424,7 +1372,6 @@ FragmentShaderYUVAVideo::FragmentShaderYUVAVideo() void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "y_texture", @@ -1442,7 +1389,6 @@ void FragmentShaderYUVAVideo::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); y_texture_location_ = locations[0]; u_texture_location_ = locations[1]; @@ -1483,7 +1429,6 @@ FragmentShaderColor::FragmentShaderColor() void FragmentShaderColor::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "color", @@ -1495,7 +1440,6 @@ void FragmentShaderColor::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); color_location_ = locations[0]; } @@ -1516,7 +1460,6 @@ FragmentShaderColorAA::FragmentShaderColorAA() void FragmentShaderColorAA::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "color", @@ -1528,7 +1471,6 @@ void FragmentShaderColorAA::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); color_location_ = locations[0]; } @@ -1556,7 +1498,6 @@ FragmentShaderCheckerboard::FragmentShaderCheckerboard() void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) { static const char* uniforms[] = { "alpha", @@ -1571,7 +1512,6 @@ void FragmentShaderCheckerboard::Init(WebGraphicsContext3D* context, arraysize(uniforms), uniforms, locations, - using_bind_uniform, base_uniform_index); alpha_location_ = locations[0]; tex_transform_location_ = locations[1]; diff --git a/cc/output/shader.h b/cc/output/shader.h index 7135bef..615fcb8 100644 --- a/cc/output/shader.h +++ b/cc/output/shader.h @@ -48,7 +48,6 @@ class VertexShaderPosTex { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -66,7 +65,6 @@ class VertexShaderPosTexYUVStretch { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -86,7 +84,6 @@ class VertexShaderPos { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -102,7 +99,6 @@ class VertexShaderPosTexIdentity { public: void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index) {} std::string GetShaderString() const; }; @@ -113,7 +109,6 @@ class VertexShaderPosTexTransform { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -135,7 +130,6 @@ class VertexShaderQuad { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -157,7 +151,6 @@ class VertexShaderQuadAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -182,7 +175,6 @@ class VertexShaderQuadTexTransformAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -208,7 +200,6 @@ class VertexShaderTile { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -234,7 +225,6 @@ class VertexShaderTileAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -262,7 +252,6 @@ class VertexShaderVideoTransform { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString() const; @@ -282,7 +271,6 @@ class FragmentTexAlphaBinding { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int fragment_tex_transform_location() const { return -1; } @@ -301,8 +289,7 @@ class FragmentTexColorMatrixAlphaBinding { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool usingBindUniform, - int* baseUniformIndex); + int* base_uniform_index); int alpha_location() const { return alpha_location_; } int color_matrix_location() const { return color_matrix_location_; } int color_offset_location() const { return color_offset_location_; } @@ -322,7 +309,6 @@ class FragmentTexOpaqueBinding { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return -1; } int fragment_tex_transform_location() const { return -1; } @@ -341,7 +327,6 @@ class FragmentTexBackgroundBinding { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int background_color_location() const { return background_color_location_; } int sampler_location() const { return sampler_location_; } @@ -421,7 +406,6 @@ class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding { std::string GetShaderString(TexCoordPrecision precision) const; void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); private: int sampler_location_; @@ -435,7 +419,6 @@ class FragmentShaderRGBATexAlphaAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); std::string GetShaderString(TexCoordPrecision precision) const; @@ -455,7 +438,6 @@ class FragmentTexClampAlphaAABinding { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -491,7 +473,6 @@ class FragmentShaderRGBATexAlphaMask { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -520,7 +501,6 @@ class FragmentShaderRGBATexAlphaMaskAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -549,7 +529,6 @@ class FragmentShaderRGBATexAlphaMaskColorMatrixAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -580,7 +559,6 @@ class FragmentShaderRGBATexAlphaColorMatrixAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -601,7 +579,6 @@ class FragmentShaderRGBATexAlphaMaskColorMatrix { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int sampler_location() const { return sampler_location_; } @@ -632,7 +609,6 @@ class FragmentShaderYUVVideo { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int y_texture_location() const { return y_texture_location_; } int u_texture_location() const { return u_texture_location_; } @@ -660,7 +636,6 @@ class FragmentShaderYUVAVideo { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int y_texture_location() const { return y_texture_location_; } @@ -690,7 +665,6 @@ class FragmentShaderColor { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int color_location() const { return color_location_; } @@ -707,7 +681,6 @@ class FragmentShaderColorAA { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int color_location() const { return color_location_; } @@ -724,7 +697,6 @@ class FragmentShaderCheckerboard { void Init(WebKit::WebGraphicsContext3D* context, unsigned program, - bool using_bind_uniform, int* base_uniform_index); int alpha_location() const { return alpha_location_; } int tex_transform_location() const { return tex_transform_location_; } diff --git a/cc/test/fake_web_graphics_context_3d.cc b/cc/test/fake_web_graphics_context_3d.cc index d822cfe..6996298 100644 --- a/cc/test/fake_web_graphics_context_3d.cc +++ b/cc/test/fake_web_graphics_context_3d.cc @@ -38,10 +38,6 @@ bool FakeWebGraphicsContext3D::isContextLost() { return false; } -WGC3Denum FakeWebGraphicsContext3D::getGraphicsResetStatusARB() { - return GL_NO_ERROR; -} - void* FakeWebGraphicsContext3D::mapBufferSubDataCHROMIUM( WGC3Denum target, WebKit::WGC3Dintptr offset, diff --git a/cc/test/fake_web_graphics_context_3d.h b/cc/test/fake_web_graphics_context_3d.h index 35f55c6..4bd48a2 100644 --- a/cc/test/fake_web_graphics_context_3d.h +++ b/cc/test/fake_web_graphics_context_3d.h @@ -31,7 +31,6 @@ class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { virtual void synthesizeGLError(WebKit::WGC3Denum) {} virtual bool isContextLost(); - virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); virtual void* mapBufferSubDataCHROMIUM( WebKit::WGC3Denum target, diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc index 61660ea..f1cdbb6 100644 --- a/cc/test/test_context_provider.cc +++ b/cc/test/test_context_provider.cc @@ -71,7 +71,9 @@ scoped_refptr<TestContextProvider> TestContextProvider::Create( TestContextProvider::TestContextProvider( scoped_ptr<TestWebGraphicsContext3D> context) - : context3d_(context.Pass()), bound_(false), destroyed_(false) { + : context3d_(context.Pass()), + bound_(false), + destroyed_(false) { DCHECK(main_thread_checker_.CalledOnValidThread()); DCHECK(context3d_); context_thread_checker_.DetachFromThread(); @@ -139,6 +141,14 @@ class GrContext* TestContextProvider::GrContext() { return NULL; } +bool TestContextProvider::IsContextLost() { + DCHECK(context3d_); + DCHECK(bound_); + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_->isContextLost(); +} + void TestContextProvider::VerifyContexts() { DCHECK(context3d_); DCHECK(bound_); @@ -185,7 +195,6 @@ TestWebGraphicsContext3D* TestContextProvider::TestContext3d() { TestWebGraphicsContext3D* TestContextProvider::UnboundTestContext3d() { DCHECK(context3d_); - DCHECK(context_thread_checker_.CalledOnValidThread()); return context3d_.get(); } diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h index 749cade..8db2edf 100644 --- a/cc/test/test_context_provider.h +++ b/cc/test/test_context_provider.h @@ -31,6 +31,7 @@ class TestContextProvider : public cc::ContextProvider { virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual gpu::ContextSupport* ContextSupport() OVERRIDE; virtual class GrContext* GrContext() OVERRIDE; + virtual bool IsContextLost() OVERRIDE; virtual void VerifyContexts() OVERRIDE; virtual bool DestroyedOnMainThread() OVERRIDE; virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE; diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc index 44ea6af..bb08a65 100644 --- a/cc/test/test_web_graphics_context_3d.cc +++ b/cc/test/test_web_graphics_context_3d.cc @@ -127,10 +127,6 @@ bool TestWebGraphicsContext3D::isContextLost() { return context_lost_; } -WGC3Denum TestWebGraphicsContext3D::getGraphicsResetStatusARB() { - return context_lost_ ? GL_UNKNOWN_CONTEXT_RESET_ARB : GL_NO_ERROR; -} - WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( WGC3Denum target) { if (context_lost_) diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index 23d5fe9..8dfe754 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h @@ -37,7 +37,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { int width, int height, float scale_factor); virtual bool isContextLost(); - virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader); virtual void bindFramebuffer( diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc index 12bfd8c..be5fc24 100644 --- a/content/browser/aura/gpu_process_transport_factory.cc +++ b/content/browser/aura/gpu_process_transport_factory.cc @@ -67,6 +67,8 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver { // ui::Texture overrides: virtual unsigned int PrepareTexture() OVERRIDE { + if (!host_context_ || host_context_->isContextLost()) + return 0u; return texture_id_; } diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 750b103..8441767 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -1251,10 +1251,6 @@ void RenderWidgetHostViewAndroid::DidCommitFrameData() { RunAckCallbacks(); } -WebKit::WebGraphicsContext3D* RenderWidgetHostViewAndroid::Context3d() { - return ImageTransportFactoryAndroid::GetInstance()->GetContext3D(); -} - bool RenderWidgetHostViewAndroid::PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 463701b..f68de7e 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -190,7 +190,6 @@ class RenderWidgetHostViewAndroid // cc::TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE; - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 59034e1..a6a3f4e 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc @@ -165,6 +165,14 @@ ContextProviderCommandBuffer::ContextCapabilities() { return capabilities_; } +bool ContextProviderCommandBuffer::IsContextLost() { + DCHECK(context3d_); + DCHECK(lost_context_callback_proxy_); // Is bound to thread. + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_->isContextLost(); +} + void ContextProviderCommandBuffer::VerifyContexts() { DCHECK(context3d_); DCHECK(lost_context_callback_proxy_); // Is bound to thread. @@ -212,7 +220,6 @@ bool ContextProviderCommandBuffer::InitializeCapabilities() { // TODO(jamesr): This information is duplicated with // gpu::gles2::FeatureInfo::AddFeatures(). Capabilities caps; - caps.bind_uniform_location = true; caps.discard_backbuffer = true; caps.set_visibility = true; diff --git a/content/common/gpu/client/context_provider_command_buffer.h b/content/common/gpu/client/context_provider_command_buffer.h index cec651f..5ee668c 100644 --- a/content/common/gpu/client/context_provider_command_buffer.h +++ b/content/common/gpu/client/context_provider_command_buffer.h @@ -35,6 +35,7 @@ class CONTENT_EXPORT ContextProviderCommandBuffer virtual gpu::ContextSupport* ContextSupport() OVERRIDE; virtual class GrContext* GrContext() OVERRIDE; virtual Capabilities ContextCapabilities() OVERRIDE; + virtual bool IsContextLost() OVERRIDE; virtual void VerifyContexts() OVERRIDE; virtual bool DestroyedOnMainThread() OVERRIDE; virtual void SetLostContextCallback( diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 9282fcb..1f92c99 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -1902,10 +1902,6 @@ unsigned PepperPluginInstanceImpl::PrepareTexture() { return 0; } -WebKit::WebGraphicsContext3D* PepperPluginInstanceImpl::Context3d() { - return NULL; -} - bool PepperPluginInstanceImpl::PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index f28cd44..288ac87 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -499,7 +499,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // cc::TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE; - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index a1184dd..a0858a6 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -20,6 +20,7 @@ #include "cc/output/filter_operation.h" #include "cc/output/filter_operations.h" #include "cc/resources/transferable_resource.h" +#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "ui/compositor/compositor_switches.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer_animator.h" @@ -647,13 +648,6 @@ unsigned Layer::PrepareTexture() { return texture_->PrepareTexture(); } -WebKit::WebGraphicsContext3D* Layer::Context3d() { - DCHECK(texture_layer_.get()); - if (texture_.get()) - return texture_->HostContext3D(); - return NULL; -} - bool Layer::PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 2d21b98..4faab12 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -321,7 +321,6 @@ class COMPOSITOR_EXPORT Layer // TextureLayerClient virtual unsigned PrepareTexture() OVERRIDE; - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index bbadcb9..4be7b2b 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -125,7 +125,6 @@ ContextProviderInProcess::ContextCapabilities() { // We always use a WebGraphicsContext3DInProcessCommandBufferImpl which // provides the following capabilities: Capabilities caps; - caps.bind_uniform_location = true; caps.discard_backbuffer = true; caps.map_image = true; caps.map_sub = true; @@ -174,6 +173,14 @@ class GrContext* ContextProviderInProcess::GrContext() { return gr_context_->get(); } +bool ContextProviderInProcess::IsContextLost() { + DCHECK(context3d_); + DCHECK(lost_context_callback_proxy_); // Is bound to thread. + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_->isContextLost(); +} + void ContextProviderInProcess::VerifyContexts() { DCHECK(context3d_); DCHECK(lost_context_callback_proxy_); // Is bound to thread. diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h index 36c2bcd..406fe96 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -35,6 +35,7 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual ::gpu::ContextSupport* ContextSupport() OVERRIDE; virtual class GrContext* GrContext() OVERRIDE; + virtual bool IsContextLost() OVERRIDE; virtual void VerifyContexts() OVERRIDE; virtual bool DestroyedOnMainThread() OVERRIDE; virtual void SetLostContextCallback( diff --git a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc index 8e4db54..0a48b5c 100644 --- a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc +++ b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc @@ -11,6 +11,7 @@ #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" #include "third_party/WebKit/public/platform/WebFloatRect.h" +#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/WebKit/public/platform/WebSize.h" #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" #include "webkit/renderer/compositor_bindings/web_layer_impl.h" @@ -65,11 +66,6 @@ unsigned WebExternalTextureLayerImpl::PrepareTexture() { return 0; } -WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() { - DCHECK(client_); - return client_->context(); -} - bool WebExternalTextureLayerImpl::PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, diff --git a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h index 5992d1a..92d7e51 100644 --- a/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h +++ b/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h @@ -46,7 +46,6 @@ class WebExternalTextureLayerImpl // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE; - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, |