0

cc: Finish the rename from cc::GraphicsContext to cc::OutputSurface

It is far too confusing to deal with OutputSurface code when half the time it is
called a GraphicsContext incorrectly. Cleaning this up so I can think about the
code properly as I upstream the Ubercomp CL.

R=jamesr,piman
BUG=146080

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=171403

Review URL: https://codereview.chromium.org/11450019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171410 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
danakj@chromium.org
2012-12-06 06:13:20 +00:00
parent 51e5bdcb18
commit 3be2171df1
61 changed files with 459 additions and 430 deletions

@ -1,8 +1,11 @@
include_rules = [ include_rules = [
"+media",
"+skia/ext", "+skia/ext",
"+third_party/skia/include", "+third_party/skia/include",
"+third_party/khronos/GLES2/gl2.h", "+third_party/khronos/GLES2/gl2.h",
"+third_party/khronos/GLES2/gl2ext.h", "+third_party/khronos/GLES2/gl2ext.h",
"+ui/gfx", "+ui/gfx",
"+media", # TODO(danakj): Drop dependencies on WebKit Platform API from cc.
"+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h",
"+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h",
] ]

@ -62,7 +62,6 @@
'gl_renderer.h', 'gl_renderer.h',
'gl_renderer_draw_cache.cc', 'gl_renderer_draw_cache.cc',
'gl_renderer_draw_cache.h', 'gl_renderer_draw_cache.h',
'graphics_context.h',
'hash_pair.h', 'hash_pair.h',
'heads_up_display_layer.cc', 'heads_up_display_layer.cc',
'heads_up_display_layer.h', 'heads_up_display_layer.h',
@ -115,6 +114,7 @@
'nine_patch_layer_impl.h', 'nine_patch_layer_impl.h',
'occlusion_tracker.cc', 'occlusion_tracker.cc',
'occlusion_tracker.h', 'occlusion_tracker.h',
'output_surface.h',
'overdraw_metrics.cc', 'overdraw_metrics.cc',
'overdraw_metrics.h', 'overdraw_metrics.h',
'page_scale_animation.cc', 'page_scale_animation.cc',

@ -57,6 +57,7 @@
'tiled_layer_unittest.cc', 'tiled_layer_unittest.cc',
'tree_synchronizer_unittest.cc', 'tree_synchronizer_unittest.cc',
'timing_function_unittest.cc', 'timing_function_unittest.cc',
'test/fake_web_graphics_context_3d_unittest.cc',
], ],
'cc_tests_support_files': [ 'cc_tests_support_files': [
'test/animation_test_common.cc', 'test/animation_test_common.cc',
@ -64,8 +65,7 @@
'test/compositor_fake_web_graphics_context_3d.h', 'test/compositor_fake_web_graphics_context_3d.h',
'test/fake_content_layer_client.cc', 'test/fake_content_layer_client.cc',
'test/fake_content_layer_client.h', 'test/fake_content_layer_client.h',
'test/fake_graphics_context.h', 'test/fake_output_surface.h',
'test/fake_graphics_context_3d_unittest.cc',
'test/fake_layer_tree_host_client.cc', 'test/fake_layer_tree_host_client.cc',
'test/fake_layer_tree_host_client.h', 'test/fake_layer_tree_host_client.h',
'test/fake_picture_layer_tiling_client.cc', 'test/fake_picture_layer_tiling_client.cc',

@ -65,7 +65,7 @@ void DelegatedRendererLayerImpl::clearRenderPasses()
m_renderPassesInDrawOrder.clear(); m_renderPassesInDrawOrder.clear();
} }
void DelegatedRendererLayerImpl::didLoseContext() void DelegatedRendererLayerImpl::didLoseOutputSurface()
{ {
clearRenderPasses(); clearRenderPasses();
} }

@ -23,7 +23,7 @@ public:
void setRenderPasses(ScopedPtrVector<RenderPass>&); void setRenderPasses(ScopedPtrVector<RenderPass>&);
void clearRenderPasses(); void clearRenderPasses();
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
virtual RenderPass::Id firstContributingRenderPassId() const OVERRIDE; virtual RenderPass::Id firstContributingRenderPassId() const OVERRIDE;
virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const OVERRIDE; virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const OVERRIDE;

@ -12,6 +12,7 @@
#include "cc/single_thread_proxy.h" #include "cc/single_thread_proxy.h"
#include "cc/solid_color_draw_quad.h" #include "cc/solid_color_draw_quad.h"
#include "cc/solid_color_layer_impl.h" #include "cc/solid_color_layer_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h" #include "cc/test/fake_proxy.h"
#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h" #include "cc/test/fake_web_graphics_context_3d.h"
@ -39,12 +40,12 @@ public:
settings.minimumOcclusionTrackingSize = gfx::Size(); settings.minimumOcclusionTrackingSize = gfx::Size();
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
m_hostImpl->initializeRenderer(createContext()); m_hostImpl->initializeRenderer(createFakeOutputSurface());
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
} }
// LayerTreeHostImplClient implementation. // LayerTreeHostImplClient implementation.
virtual void didLoseContextOnImplThread() OVERRIDE { } virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVERRIDE { } virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVERRIDE { }
virtual void onCanDrawStateChanged(bool) OVERRIDE { } virtual void onCanDrawStateChanged(bool) OVERRIDE { }
@ -56,11 +57,6 @@ public:
virtual void sendManagedMemoryStats() OVERRIDE { } virtual void sendManagedMemoryStats() OVERRIDE { }
protected: protected:
scoped_ptr<GraphicsContext> createContext()
{
return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>();
}
FakeProxy m_proxy; FakeProxy m_proxy;
DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThreadBlocked; DebugScopedSetImplThreadAndMainThreadBlocked m_alwaysImplThreadAndMainThreadBlocked;
scoped_ptr<LayerTreeHostImpl> m_hostImpl; scoped_ptr<LayerTreeHostImpl> m_hostImpl;

@ -102,9 +102,6 @@ bool GLRenderer::initialize()
else else
m_capabilities.usingAcceleratedPainting = false; m_capabilities.usingAcceleratedPainting = false;
m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_front_buffer_cached");
m_capabilities.usingPartialSwap = settings().partialSwapEnabled && extensions.count("GL_CHROMIUM_post_sub_buffer"); m_capabilities.usingPartialSwap = settings().partialSwapEnabled && extensions.count("GL_CHROMIUM_post_sub_buffer");
// Use the swapBuffers callback only with the threaded proxy. // Use the swapBuffers callback only with the threaded proxy.
@ -1353,7 +1350,7 @@ void GLRenderer::ensureFramebuffer()
void GLRenderer::onContextLost() void GLRenderer::onContextLost()
{ {
m_client->didLoseContext(); m_client->didLoseOutputSurface();
} }

@ -16,6 +16,8 @@
#include "cc/solid_color_draw_quad.h" #include "cc/solid_color_draw_quad.h"
#include "cc/tile_draw_quad.h" #include "cc/tile_draw_quad.h"
#include "cc/yuv_video_draw_quad.h" #include "cc/yuv_video_draw_quad.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h"
#include "ui/gfx/quad_f.h" #include "ui/gfx/quad_f.h"
namespace WebKit { namespace WebKit {

@ -73,7 +73,7 @@ public:
// RendererClient methods. // RendererClient methods.
virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::Size fakeSize(1, 1); return fakeSize; } virtual const gfx::Size& deviceViewportSize() const OVERRIDE { static gfx::Size fakeSize(1, 1); return fakeSize; }
virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTreeSettings fakeSettings; return fakeSettings; } virtual const LayerTreeSettings& settings() const OVERRIDE { static LayerTreeSettings fakeSettings; return fakeSettings; }
virtual void didLoseContext() OVERRIDE { } virtual void didLoseOutputSurface() OVERRIDE { }
virtual void onSwapBuffersComplete() OVERRIDE { } virtual void onSwapBuffersComplete() OVERRIDE { }
virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCount++; } virtual void setFullRootLayerDamage() OVERRIDE { m_setFullRootLayerDamageCount++; }
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; } virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { m_memoryAllocationLimitBytes = policy.bytesLimitWhenVisible; }
@ -139,7 +139,7 @@ protected:
WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes;
WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_context;
FakeRendererClient m_mockClient; FakeRendererClient m_mockClient;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
FakeRendererGL m_renderer; FakeRendererGL m_renderer;
@ -300,7 +300,7 @@ public:
TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls) TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext))); scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -343,7 +343,7 @@ private:
TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert) TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext))); scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -365,8 +365,8 @@ public:
TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation) TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
renderer.initialize(); renderer.initialize();
@ -392,7 +392,7 @@ private:
TEST(GLRendererTest2, opaqueBackground) TEST(GLRendererTest2, opaqueBackground)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D()); ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -415,7 +415,7 @@ TEST(GLRendererTest2, opaqueBackground)
TEST(GLRendererTest2, transparentBackground) TEST(GLRendererTest2, transparentBackground)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D()); ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -466,7 +466,7 @@ private:
TEST(GLRendererTest2, visibilityChangeIsLastCall) TEST(GLRendererTest2, visibilityChangeIsLastCall)
{ {
FakeRendererClient mockClient; FakeRendererClient mockClient;
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext)));
VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3D()); VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get()); FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -518,7 +518,7 @@ private:
TEST(GLRendererTest2, activeTextureState) TEST(GLRendererTest2, activeTextureState)
{ {
FakeRendererClient fakeClient; FakeRendererClient fakeClient;
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D()); TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&fakeClient, resourceProvider.get()); FakeRendererGL renderer(&fakeClient, resourceProvider.get());

@ -1,18 +0,0 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_GRAPHICS_CONTEXT_H_
#define CC_GRAPHICS_CONTEXT_H_
#include <public/WebCompositorOutputSurface.h>
#include <public/WebGraphicsContext3D.h>
namespace cc {
// FIXME: rename fully to OutputSurface.
typedef WebKit::WebCompositorOutputSurface GraphicsContext;
} // namespace cc
#endif // CC_GRAPHICS_CONTEXT_H_

@ -134,7 +134,7 @@ void HeadsUpDisplayLayerImpl::didDraw(ResourceProvider* resourceProvider)
DCHECK(!resourceProvider->inUseByConsumer(m_hudTexture->id())); DCHECK(!resourceProvider->inUseByConsumer(m_hudTexture->id()));
} }
void HeadsUpDisplayLayerImpl::didLoseContext() void HeadsUpDisplayLayerImpl::didLoseOutputSurface()
{ {
m_hudTexture.reset(); m_hudTexture.reset();
} }

@ -37,7 +37,7 @@ public:
void updateHudTexture(ResourceProvider*); void updateHudTexture(ResourceProvider*);
virtual void didDraw(ResourceProvider*) OVERRIDE; virtual void didDraw(ResourceProvider*) OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
virtual bool layerIsAlwaysDamaged() const OVERRIDE; virtual bool layerIsAlwaysDamaged() const OVERRIDE;

@ -6,13 +6,13 @@
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "cc/gl_renderer.h" // For the GLC() macro. #include "cc/gl_renderer.h" // For the GLC() macro.
#include "cc/graphics_context.h"
#include "cc/io_surface_draw_quad.h" #include "cc/io_surface_draw_quad.h"
#include "cc/layer_tree_host_impl.h" #include "cc/layer_tree_host_impl.h"
#include "cc/output_surface.h"
#include "cc/quad_sink.h" #include "cc/quad_sink.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h" #include "third_party/khronos/GLES2/gl2ext.h"
#include <public/WebGraphicsContext3D.h>
namespace cc { namespace cc {
@ -29,9 +29,9 @@ IOSurfaceLayerImpl::~IOSurfaceLayerImpl()
if (!m_ioSurfaceTextureId) if (!m_ioSurfaceTextureId)
return; return;
GraphicsContext* context = layerTreeHostImpl()->context(); OutputSurface* outputSurface = layerTreeHostImpl()->outputSurface();
// FIXME: Implement this path for software compositing. // FIXME: Implement this path for software compositing.
WebKit::WebGraphicsContext3D* context3d = context->context3D(); WebKit::WebGraphicsContext3D* context3d = outputSurface->context3D();
if (context3d) if (context3d)
context3d->deleteTexture(m_ioSurfaceTextureId); context3d->deleteTexture(m_ioSurfaceTextureId);
} }
@ -91,7 +91,7 @@ void IOSurfaceLayerImpl::dumpLayerProperties(std::string* str, int indent) const
LayerImpl::dumpLayerProperties(str, indent); LayerImpl::dumpLayerProperties(str, indent);
} }
void IOSurfaceLayerImpl::didLoseContext() void IOSurfaceLayerImpl::didLoseOutputSurface()
{ {
// We don't have a valid texture ID in the new context; however, // We don't have a valid texture ID in the new context; however,
// the IOSurface is still valid. // the IOSurface is still valid.

@ -24,7 +24,7 @@ public:
virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
virtual void willDraw(ResourceProvider*) OVERRIDE; virtual void willDraw(ResourceProvider*) OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE;

@ -680,7 +680,7 @@ Region LayerImpl::visibleContentOpaqueRegion() const
return Region(); return Region();
} }
void LayerImpl::didLoseContext() void LayerImpl::didLoseOutputSurface()
{ {
} }

@ -262,10 +262,10 @@ public:
virtual void didUpdateTransforms() { } virtual void didUpdateTransforms() { }
// Indicates that the context previously used to render this layer // Indicates that the surface previously used to render this layer
// was lost and that a new one has been created. Won't be called // was lost and that a new one has been created. Won't be called
// until the new context has been created successfully. // until the new surface has been created successfully.
virtual void didLoseContext(); virtual void didLoseOutputSurface();
ScrollbarAnimationController* scrollbarAnimationController() const { return m_scrollbarAnimationController.get(); } ScrollbarAnimationController* scrollbarAnimationController() const { return m_scrollbarAnimationController.get(); }

@ -9,7 +9,6 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "cc/font_atlas.h" #include "cc/font_atlas.h"
#include "cc/graphics_context.h"
#include "cc/heads_up_display_layer.h" #include "cc/heads_up_display_layer.h"
#include "cc/heads_up_display_layer_impl.h" #include "cc/heads_up_display_layer_impl.h"
#include "cc/layer.h" #include "cc/layer.h"
@ -147,8 +146,7 @@ LayerTreeSettings::~LayerTreeSettings()
RendererCapabilities::RendererCapabilities() RendererCapabilities::RendererCapabilities()
: bestTextureFormat(0) : bestTextureFormat(0)
, contextHasCachedFrontBuffer(false) , usingPartialSwap(0)
, usingPartialSwap(false)
, usingAcceleratedPainting(false) , usingAcceleratedPainting(false)
, usingSetVisibility(false) , usingSetVisibility(false)
, usingSwapCompleteCallback(false) , usingSwapCompleteCallback(false)
@ -185,7 +183,7 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSetting
, m_commitNumber(0) , m_commitNumber(0)
, m_renderingStats() , m_renderingStats()
, m_rendererInitialized(false) , m_rendererInitialized(false)
, m_contextLost(false) , m_outputSurfaceLost(false)
, m_numTimesRecreateShouldFail(0) , m_numTimesRecreateShouldFail(0)
, m_numFailedRecreateAttempts(0) , m_numFailedRecreateAttempts(0)
, m_settings(settings) , m_settings(settings)
@ -222,7 +220,7 @@ bool LayerTreeHost::initializeProxy(scoped_ptr<Proxy> proxy)
m_proxy = proxy.Pass(); m_proxy = proxy.Pass();
m_proxy->start(); m_proxy->start();
return m_proxy->initializeContext(); return m_proxy->initializeOutputSurface();
} }
LayerTreeHost::~LayerTreeHost() LayerTreeHost::~LayerTreeHost()
@ -248,7 +246,7 @@ void LayerTreeHost::initializeRenderer()
{ {
TRACE_EVENT0("cc", "LayerTreeHost::initializeRenderer"); TRACE_EVENT0("cc", "LayerTreeHost::initializeRenderer");
if (!m_proxy->initializeRenderer()) { if (!m_proxy->initializeRenderer()) {
// Uh oh, better tell the client that we can't do anything with this context. // Uh oh, better tell the client that we can't do anything with this output surface.
m_client->didRecreateOutputSurface(false); m_client->didRecreateOutputSurface(false);
return; return;
} }
@ -273,28 +271,28 @@ void LayerTreeHost::initializeRenderer()
min(m_settings.maxUntiledLayerSize.height(), m_proxy->rendererCapabilities().maxTextureSize)); min(m_settings.maxUntiledLayerSize.height(), m_proxy->rendererCapabilities().maxTextureSize));
} }
LayerTreeHost::RecreateResult LayerTreeHost::recreateContext() LayerTreeHost::RecreateResult LayerTreeHost::recreateOutputSurface()
{ {
TRACE_EVENT0("cc", "LayerTreeHost::recreateContext"); TRACE_EVENT0("cc", "LayerTreeHost::recreateOutputSurface");
DCHECK(m_contextLost); DCHECK(m_outputSurfaceLost);
bool recreated = false; bool recreated = false;
if (!m_numTimesRecreateShouldFail) if (!m_numTimesRecreateShouldFail)
recreated = m_proxy->recreateContext(); recreated = m_proxy->recreateOutputSurface();
else else
m_numTimesRecreateShouldFail--; m_numTimesRecreateShouldFail--;
if (recreated) { if (recreated) {
m_client->didRecreateOutputSurface(true); m_client->didRecreateOutputSurface(true);
m_contextLost = false; m_outputSurfaceLost = false;
return RecreateSucceeded; return RecreateSucceeded;
} }
// Tolerate a certain number of recreation failures to work around races // Tolerate a certain number of recreation failures to work around races
// in the context-lost machinery. // in the output-surface-lost machinery.
m_numFailedRecreateAttempts++; m_numFailedRecreateAttempts++;
if (m_numFailedRecreateAttempts < 5) { if (m_numFailedRecreateAttempts < 5) {
// FIXME: The single thread does not self-schedule context // FIXME: The single thread does not self-schedule output surface
// recreation. So force another recreation attempt to happen by requesting // recreation. So force another recreation attempt to happen by requesting
// another commit. // another commit.
if (!m_proxy->hasImplThread()) if (!m_proxy->hasImplThread())
@ -302,8 +300,8 @@ LayerTreeHost::RecreateResult LayerTreeHost::recreateContext()
return RecreateFailedButTryAgain; return RecreateFailedButTryAgain;
} }
// We have tried too many times to recreate the context. Tell the host to fall // We have tried too many times to recreate the output surface. Tell the
// back to software rendering. // host to fall back to software rendering.
m_client->didRecreateOutputSurface(false); m_client->didRecreateOutputSurface(false);
return RecreateFailedAndGaveUp; return RecreateFailedAndGaveUp;
} }
@ -429,7 +427,7 @@ void LayerTreeHost::commitComplete()
m_client->didCommit(); m_client->didCommit();
} }
scoped_ptr<GraphicsContext> LayerTreeHost::createContext() scoped_ptr<OutputSurface> LayerTreeHost::createOutputSurface()
{ {
return m_client->createOutputSurface(); return m_client->createOutputSurface();
} }
@ -444,11 +442,11 @@ scoped_ptr<LayerTreeHostImpl> LayerTreeHost::createLayerTreeHostImpl(LayerTreeHo
return LayerTreeHostImpl::create(m_settings, client, m_proxy.get()); return LayerTreeHostImpl::create(m_settings, client, m_proxy.get());
} }
void LayerTreeHost::didLoseContext() void LayerTreeHost::didLoseOutputSurface()
{ {
TRACE_EVENT0("cc", "LayerTreeHost::didLoseContext"); TRACE_EVENT0("cc", "LayerTreeHost::didLoseOutputSurface");
DCHECK(m_proxy->isMainThread()); DCHECK(m_proxy->isMainThread());
m_contextLost = true; m_outputSurfaceLost = true;
m_numFailedRecreateAttempts = 0; m_numFailedRecreateAttempts = 0;
setNeedsCommit(); setNeedsCommit();
} }
@ -596,11 +594,11 @@ void LayerTreeHost::startPageScaleAnimation(gfx::Vector2d targetOffset, bool use
m_proxy->startPageScaleAnimation(targetOffset, useAnchor, scale, duration); m_proxy->startPageScaleAnimation(targetOffset, useAnchor, scale, duration);
} }
void LayerTreeHost::loseContext(int numTimes) void LayerTreeHost::loseOutputSurface(int numTimes)
{ {
TRACE_EVENT1("cc", "LayerTreeHost::loseCompositorContext", "numTimes", numTimes); TRACE_EVENT1("cc", "LayerTreeHost::loseCompositorOutputSurface", "numTimes", numTimes);
m_numTimesRecreateShouldFail = numTimes - 1; m_numTimesRecreateShouldFail = numTimes - 1;
m_proxy->loseContext(); m_proxy->loseOutputSurface();
} }
PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const
@ -629,8 +627,8 @@ bool LayerTreeHost::initializeRendererIfNeeded()
if (!m_rendererInitialized) if (!m_rendererInitialized)
return false; return false;
} }
if (m_contextLost) { if (m_outputSurfaceLost) {
if (recreateContext() != RecreateSucceeded) if (recreateOutputSurface() != RecreateSucceeded)
return false; return false;
} }
return true; return true;

@ -15,10 +15,10 @@
#include "base/time.h" #include "base/time.h"
#include "cc/animation_events.h" #include "cc/animation_events.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/graphics_context.h"
#include "cc/layer_tree_host_client.h" #include "cc/layer_tree_host_client.h"
#include "cc/layer_tree_host_common.h" #include "cc/layer_tree_host_common.h"
#include "cc/occlusion_tracker.h" #include "cc/occlusion_tracker.h"
#include "cc/output_surface.h"
#include "cc/prioritized_resource_manager.h" #include "cc/prioritized_resource_manager.h"
#include "cc/proxy.h" #include "cc/proxy.h"
#include "cc/rate_limiter.h" #include "cc/rate_limiter.h"
@ -102,7 +102,6 @@ struct CC_EXPORT RendererCapabilities {
~RendererCapabilities(); ~RendererCapabilities();
GLenum bestTextureFormat; GLenum bestTextureFormat;
bool contextHasCachedFrontBuffer;
bool usingPartialSwap; bool usingPartialSwap;
bool usingAcceleratedPainting; bool usingAcceleratedPainting;
bool usingSetVisibility; bool usingSetVisibility;
@ -137,16 +136,16 @@ public:
void finishCommitOnImplThread(LayerTreeHostImpl*); void finishCommitOnImplThread(LayerTreeHostImpl*);
void willCommit(); void willCommit();
void commitComplete(); void commitComplete();
scoped_ptr<GraphicsContext> createContext(); scoped_ptr<OutputSurface> createOutputSurface();
scoped_ptr<InputHandler> createInputHandler(); scoped_ptr<InputHandler> createInputHandler();
virtual scoped_ptr<LayerTreeHostImpl> createLayerTreeHostImpl(LayerTreeHostImplClient*); virtual scoped_ptr<LayerTreeHostImpl> createLayerTreeHostImpl(LayerTreeHostImplClient*);
void didLoseContext(); void didLoseOutputSurface();
enum RecreateResult { enum RecreateResult {
RecreateSucceeded, RecreateSucceeded,
RecreateFailedButTryAgain, RecreateFailedButTryAgain,
RecreateFailedAndGaveUp, RecreateFailedAndGaveUp,
}; };
RecreateResult recreateContext(); RecreateResult recreateOutputSurface();
void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); } void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); }
void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); } void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
void deleteContentsTexturesOnImplThread(ResourceProvider*); void deleteContentsTexturesOnImplThread(ResourceProvider*);
@ -181,7 +180,7 @@ public:
const RendererCapabilities& rendererCapabilities() const; const RendererCapabilities& rendererCapabilities() const;
// Test only hook // Test only hook
void loseContext(int numTimes); void loseOutputSurface(int numTimes);
void setNeedsAnimate(); void setNeedsAnimate();
// virtual for testing // virtual for testing
@ -284,7 +283,7 @@ private:
RenderingStats m_renderingStats; RenderingStats m_renderingStats;
bool m_rendererInitialized; bool m_rendererInitialized;
bool m_contextLost; bool m_outputSurfaceLost;
int m_numTimesRecreateShouldFail; int m_numTimesRecreateShouldFail;
int m_numFailedRecreateAttempts; int m_numFailedRecreateAttempts;

@ -279,9 +279,9 @@ bool LayerTreeHostImpl::canDraw()
return true; return true;
} }
GraphicsContext* LayerTreeHostImpl::context() const OutputSurface* LayerTreeHostImpl::outputSurface() const
{ {
return m_context.get(); return m_outputSurface.get();
} }
void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallClockTime) void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallClockTime)
@ -891,9 +891,9 @@ const LayerTreeSettings& LayerTreeHostImpl::settings() const
return m_settings; return m_settings;
} }
void LayerTreeHostImpl::didLoseContext() void LayerTreeHostImpl::didLoseOutputSurface()
{ {
m_client->didLoseContextOnImplThread(); m_client->didLoseOutputSurfaceOnImplThread();
} }
void LayerTreeHostImpl::onSwapBuffersComplete() void LayerTreeHostImpl::onSwapBuffersComplete()
@ -983,40 +983,40 @@ void LayerTreeHostImpl::setVisible(bool visible)
setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
} }
bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<GraphicsContext> context) bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurface)
{ {
// Since we will create a new resource provider, we cannot continue to use // Since we will create a new resource provider, we cannot continue to use
// the old resources (i.e. renderSurfaces and texture IDs). Clear them // the old resources (i.e. renderSurfaces and texture IDs). Clear them
// before we destroy the old resource provider. // before we destroy the old resource provider.
if (m_rootLayerImpl) { if (m_rootLayerImpl) {
clearRenderSurfaces(); clearRenderSurfaces();
sendDidLoseContextRecursive(m_rootLayerImpl.get()); sendDidLoseOutputSurfaceRecursive(m_rootLayerImpl.get());
} }
// Note: order is important here. // Note: order is important here.
m_renderer.reset(); m_renderer.reset();
m_tileManager.reset(); m_tileManager.reset();
m_resourceProvider.reset(); m_resourceProvider.reset();
m_context.reset(); m_outputSurface.reset();
if (!context->bindToClient(this)) if (!outputSurface->bindToClient(this))
return false; return false;
scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(context.get()); scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(outputSurface.get());
if (!resourceProvider) if (!resourceProvider)
return false; return false;
if (m_settings.implSidePainting) if (m_settings.implSidePainting)
m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads)); m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads));
if (context->context3D()) if (outputSurface->context3D())
m_renderer = GLRenderer::create(this, resourceProvider.get()); m_renderer = GLRenderer::create(this, resourceProvider.get());
else if (context->softwareDevice()) else if (outputSurface->softwareDevice())
m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), context->softwareDevice()); m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->softwareDevice());
if (!m_renderer) if (!m_renderer)
return false; return false;
m_resourceProvider = resourceProvider.Pass(); m_resourceProvider = resourceProvider.Pass();
m_context = context.Pass(); m_outputSurface = outputSurface.Pass();
if (!m_visible) if (!m_visible)
m_renderer->setVisible(m_visible); m_renderer->setVisible(m_visible);
@ -1556,16 +1556,16 @@ base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const
return base::TimeDelta::FromSeconds(1); return base::TimeDelta::FromSeconds(1);
} }
void LayerTreeHostImpl::sendDidLoseContextRecursive(LayerImpl* current) void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current)
{ {
DCHECK(current); DCHECK(current);
current->didLoseContext(); current->didLoseOutputSurface();
if (current->maskLayer()) if (current->maskLayer())
sendDidLoseContextRecursive(current->maskLayer()); sendDidLoseOutputSurfaceRecursive(current->maskLayer());
if (current->replicaLayer()) if (current->replicaLayer())
sendDidLoseContextRecursive(current->replicaLayer()); sendDidLoseOutputSurfaceRecursive(current->replicaLayer());
for (size_t i = 0; i < current->children().size(); ++i) for (size_t i = 0; i < current->children().size(); ++i)
sendDidLoseContextRecursive(current->children()[i]); sendDidLoseOutputSurfaceRecursive(current->children()[i]);
} }
static void clearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) static void clearRenderSurfacesOnLayerImplRecursive(LayerImpl* current)

@ -37,7 +37,7 @@ struct RenderingStats;
// LayerTreeHost->Proxy callback interface. // LayerTreeHost->Proxy callback interface.
class LayerTreeHostImplClient { class LayerTreeHostImplClient {
public: public:
virtual void didLoseContextOnImplThread() = 0; virtual void didLoseOutputSurfaceOnImplThread() = 0;
virtual void onSwapBuffersCompleteOnImplThread() = 0; virtual void onSwapBuffersCompleteOnImplThread() = 0;
virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) = 0; virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) = 0;
virtual void onCanDrawStateChanged(bool canDraw) = 0; virtual void onCanDrawStateChanged(bool canDraw) = 0;
@ -165,7 +165,7 @@ public:
// RendererClient implementation // RendererClient implementation
virtual const gfx::Size& deviceViewportSize() const OVERRIDE; virtual const gfx::Size& deviceViewportSize() const OVERRIDE;
virtual const LayerTreeSettings& settings() const OVERRIDE; virtual const LayerTreeSettings& settings() const OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
virtual void onSwapBuffersComplete() OVERRIDE; virtual void onSwapBuffersComplete() OVERRIDE;
virtual void setFullRootLayerDamage() OVERRIDE; virtual void setFullRootLayerDamage() OVERRIDE;
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
@ -181,14 +181,14 @@ public:
// Implementation // Implementation
bool canDraw(); bool canDraw();
GraphicsContext* context() const; OutputSurface* outputSurface() const;
std::string layerTreeAsText() const; std::string layerTreeAsText() const;
void finishAllRendering(); void finishAllRendering();
int sourceAnimationFrameNumber() const; int sourceAnimationFrameNumber() const;
bool initializeRenderer(scoped_ptr<GraphicsContext>); bool initializeRenderer(scoped_ptr<OutputSurface>);
bool isContextLost(); bool isContextLost();
TileManager* tileManager() { return m_tileManager.get(); } TileManager* tileManager() { return m_tileManager.get(); }
Renderer* renderer() { return m_renderer.get(); } Renderer* renderer() { return m_renderer.get(); }
@ -324,7 +324,7 @@ private:
void setBackgroundTickingEnabled(bool); void setBackgroundTickingEnabled(bool);
gfx::Size contentSize() const; gfx::Size contentSize() const;
void sendDidLoseContextRecursive(LayerImpl*); void sendDidLoseOutputSurfaceRecursive(LayerImpl*);
void clearRenderSurfaces(); void clearRenderSurfaces();
bool ensureRenderSurfaceLayerList(); bool ensureRenderSurfaceLayerList();
void clearCurrentlyScrollingLayer(); void clearCurrentlyScrollingLayer();
@ -333,7 +333,7 @@ private:
void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
scoped_ptr<Renderer> m_renderer; scoped_ptr<Renderer> m_renderer;
scoped_ptr<TileManager> m_tileManager; scoped_ptr<TileManager> m_tileManager;

@ -82,7 +82,7 @@ public:
settings.pageScalePinchZoomEnabled = GetParam(); settings.pageScalePinchZoomEnabled = GetParam();
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
m_hostImpl->initializeRenderer(createContext()); m_hostImpl->initializeRenderer(createOutputSurface());
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
} }
@ -90,7 +90,7 @@ public:
{ {
} }
virtual void didLoseContextOnImplThread() OVERRIDE { } virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVERRIDE { } virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVERRIDE { }
virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawStateChangedCalled = true; } virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawStateChangedCalled = true; }
@ -103,7 +103,7 @@ public:
void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; }
scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_ptr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputSurface, scoped_ptr<LayerImpl> root)
{ {
LayerTreeSettings settings; LayerTreeSettings settings;
settings.minimumOcclusionTrackingSize = gfx::Size(); settings.minimumOcclusionTrackingSize = gfx::Size();
@ -111,7 +111,7 @@ public:
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
myHostImpl->initializeRenderer(graphicsContext.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
root->setAnchorPoint(gfx::PointF(0, 0)); root->setAnchorPoint(gfx::PointF(0, 0));
@ -192,7 +192,7 @@ public:
void initializeRendererAndDrawFrame() void initializeRendererAndDrawFrame()
{ {
m_hostImpl->initializeRenderer(createContext()); m_hostImpl->initializeRenderer(createOutputSurface());
LayerTreeHostImpl::FrameData frame; LayerTreeHostImpl::FrameData frame;
EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
m_hostImpl->drawLayers(frame); m_hostImpl->drawLayers(frame);
@ -205,9 +205,9 @@ public:
void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor); void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor);
protected: protected:
scoped_ptr<GraphicsContext> createContext() scoped_ptr<OutputSurface> createOutputSurface()
{ {
return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>();
} }
FakeProxy m_proxy; FakeProxy m_proxy;
@ -376,7 +376,7 @@ TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
// Initialization will fail here. // Initialization will fail here.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<GraphicsContext>()); m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
setupScrollAndContentsLayers(gfx::Size(100, 100)); setupScrollAndContentsLayers(gfx::Size(100, 100));
@ -1885,7 +1885,7 @@ TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
TEST_P(LayerTreeHostImplTest, viewportCovered) TEST_P(LayerTreeHostImplTest, viewportCovered)
{ {
m_hostImpl->initializeRenderer(createContext()); m_hostImpl->initializeRenderer(createOutputSurface());
m_hostImpl->setBackgroundColor(SK_ColorGRAY); m_hostImpl->setBackgroundColor(SK_ColorGRAY);
gfx::Size viewportSize(1000, 1000); gfx::Size viewportSize(1000, 1000);
@ -1997,7 +1997,7 @@ protected:
// viewport size is never set. // viewport size is never set.
TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw)
{ {
scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>();
ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->context3D()); ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->context3D());
m_hostImpl->initializeRenderer(outputSurface.Pass()); m_hostImpl->initializeRenderer(outputSurface.Pass());
@ -2040,7 +2040,7 @@ private:
// where it should request to swap only the subBuffer that is damaged. // where it should request to swap only the subBuffer that is damaged.
TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
{ {
scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>();
PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->context3D()); PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->context3D());
// This test creates its own LayerTreeHostImpl, so // This test creates its own LayerTreeHostImpl, so
@ -2255,12 +2255,12 @@ public:
TEST_P(LayerTreeHostImplTest, noPartialSwap) TEST_P(LayerTreeHostImplTest, noPartialSwap)
{ {
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(context->context3D()); MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D());
MockContextHarness harness(mockContext); MockContextHarness harness(mockContext);
// Run test case // Run test case
scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.Pass(), FakeLayerWithQuads::create(1)); scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, outputSurface.Pass(), FakeLayerWithQuads::create(1));
// without partial swap, and no clipping, no scissor is set. // without partial swap, and no clipping, no scissor is set.
harness.mustDrawSolidQuad(); harness.mustDrawSolidQuad();
@ -2288,11 +2288,11 @@ TEST_P(LayerTreeHostImplTest, noPartialSwap)
TEST_P(LayerTreeHostImplTest, partialSwap) TEST_P(LayerTreeHostImplTest, partialSwap)
{ {
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(context->context3D()); MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D());
MockContextHarness harness(mockContext); MockContextHarness harness(mockContext);
scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.Pass(), FakeLayerWithQuads::create(1)); scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, outputSurface.Pass(), FakeLayerWithQuads::create(1));
// The first frame is not a partially-swapped one. // The first frame is not a partially-swapped one.
harness.mustSetScissor(0, 0, 10, 10); harness.mustSetScissor(0, 0, 10, 10);
@ -2344,12 +2344,12 @@ public:
static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy) static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy)
{ {
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
LayerTreeSettings settings; LayerTreeSettings settings;
settings.partialSwapEnabled = partialSwap; settings.partialSwapEnabled = partialSwap;
scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, client, proxy); scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(settings, client, proxy);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
/* /*
@ -2450,48 +2450,48 @@ TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
} }
} }
// Make sure that context lost notifications are propagated through the tree. // Make sure that output surface lost notifications are propagated through the tree.
class ContextLostNotificationCheckLayer : public LayerImpl { class OutputSurfaceLostNotificationCheckLayer : public LayerImpl {
public: public:
static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(new ContextLostNotificationCheckLayer(id)); } static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(new OutputSurfaceLostNotificationCheckLayer(id)); }
virtual void didLoseContext() OVERRIDE virtual void didLoseOutputSurface() OVERRIDE
{ {
m_didLoseContextCalled = true; m_didLoseOutputSurfaceCalled = true;
} }
bool didLoseContextCalled() const { return m_didLoseContextCalled; } bool didLoseOutputSurfaceCalled() const { return m_didLoseOutputSurfaceCalled; }
private: private:
explicit ContextLostNotificationCheckLayer(int id) explicit OutputSurfaceLostNotificationCheckLayer(int id)
: LayerImpl(id) : LayerImpl(id)
, m_didLoseContextCalled(false) , m_didLoseOutputSurfaceCalled(false)
{ {
} }
bool m_didLoseContextCalled; bool m_didLoseOutputSurfaceCalled;
}; };
TEST_P(LayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers) TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllLayers)
{ {
m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); m_hostImpl->setRootLayer(OutputSurfaceLostNotificationCheckLayer::create(1));
ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer()); OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLostNotificationCheckLayer*>(m_hostImpl->rootLayer());
root->addChild(ContextLostNotificationCheckLayer::create(1)); root->addChild(OutputSurfaceLostNotificationCheckLayer::create(1));
ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificationCheckLayer*>(root->children()[0]); OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceLostNotificationCheckLayer*>(root->children()[0]);
layer1->addChild(ContextLostNotificationCheckLayer::create(2)); layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(2));
ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificationCheckLayer*>(layer1->children()[0]); OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceLostNotificationCheckLayer*>(layer1->children()[0]);
EXPECT_FALSE(root->didLoseContextCalled()); EXPECT_FALSE(root->didLoseOutputSurfaceCalled());
EXPECT_FALSE(layer1->didLoseContextCalled()); EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled());
EXPECT_FALSE(layer2->didLoseContextCalled()); EXPECT_FALSE(layer2->didLoseOutputSurfaceCalled());
m_hostImpl->initializeRenderer(createContext()); m_hostImpl->initializeRenderer(createOutputSurface());
EXPECT_TRUE(root->didLoseContextCalled()); EXPECT_TRUE(root->didLoseOutputSurfaceCalled());
EXPECT_TRUE(layer1->didLoseContextCalled()); EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled());
EXPECT_TRUE(layer2->didLoseContextCalled()); EXPECT_TRUE(layer2->didLoseOutputSurfaceCalled());
} }
TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost)
@ -2500,7 +2500,7 @@ TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost)
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
// The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<GraphicsContext>()); m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->finishAllRendering(); m_hostImpl->finishAllRendering();
} }
@ -2518,14 +2518,14 @@ private:
unsigned m_succeedCount; unsigned m_succeedCount;
}; };
TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize) TEST_P(LayerTreeHostImplTest, context3DLostDuringInitialize)
{ {
LayerTreeSettings settings; LayerTreeSettings settings;
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
// Initialize into a known successful state. // Initialize into a known successful state.
EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface()));
EXPECT_TRUE(m_hostImpl->context()); EXPECT_TRUE(m_hostImpl->outputSurface());
EXPECT_TRUE(m_hostImpl->renderer()); EXPECT_TRUE(m_hostImpl->renderer());
EXPECT_TRUE(m_hostImpl->resourceProvider()); EXPECT_TRUE(m_hostImpl->resourceProvider());
@ -2538,15 +2538,15 @@ TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize)
for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitialization; ++i) { for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitialization; ++i) {
// The context will get lost during initialization, we shouldn't crash. We // The context will get lost during initialization, we shouldn't crash. We
// should also be in a consistent state. // should also be in a consistent state.
EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<GraphicsContext>())); EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<OutputSurface>()));
EXPECT_EQ(0, m_hostImpl->context()); EXPECT_EQ(0, m_hostImpl->outputSurface());
EXPECT_EQ(0, m_hostImpl->renderer()); EXPECT_EQ(0, m_hostImpl->renderer());
EXPECT_EQ(0, m_hostImpl->resourceProvider()); EXPECT_EQ(0, m_hostImpl->resourceProvider());
EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface()));
} }
EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<GraphicsContext>())); EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<OutputSurface>()));
EXPECT_TRUE(m_hostImpl->context()); EXPECT_TRUE(m_hostImpl->outputSurface());
EXPECT_TRUE(m_hostImpl->renderer()); EXPECT_TRUE(m_hostImpl->renderer());
EXPECT_TRUE(m_hostImpl->resourceProvider()); EXPECT_TRUE(m_hostImpl->resourceProvider());
} }
@ -2783,7 +2783,7 @@ static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
return pass.PassAs<RenderPass>(); return pass.PassAs<RenderPass>();
} }
TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface)
{ {
int layerId = 1; int layerId = 1;
@ -2899,7 +2899,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>());
// Use a context that supports IOSurfaces // Use a context that supports IOSurfaces
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<GraphicsContext>()); m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
FakeVideoFrame hwVideoFrame( FakeVideoFrame hwVideoFrame(
VideoFrame::WrapNativeTexture( VideoFrame::WrapNativeTexture(
@ -2927,9 +2927,9 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
unsigned numResources = m_hostImpl->resourceProvider()->numResources(); unsigned numResources = m_hostImpl->resourceProvider()->numResources();
// Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface, // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
// that will warn if any resource from the previous context gets used. // that will warn if any resource from the previous context gets used.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<GraphicsContext>()); m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
// Create dummy resources so that looking up an old resource will get an // Create dummy resources so that looking up an old resource will get an
// invalid texture id mapping. // invalid texture id mapping.
@ -2937,7 +2937,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
m_hostImpl->resourceProvider()->createResourceFromExternalTexture(StrictWebGraphicsContext3D::kExternalTextureId); m_hostImpl->resourceProvider()->createResourceFromExternalTexture(StrictWebGraphicsContext3D::kExternalTextureId);
// The WebVideoFrameProvider is expected to recreate its textures after a // The WebVideoFrameProvider is expected to recreate its textures after a
// lost context (or not serve a frame). // lost output surface (or not serve a frame).
hwProvider.setFrame(0); hwProvider.setFrame(0);
providerScaled.setFrame(0); providerScaled.setFrame(0);
@ -3047,9 +3047,9 @@ TEST_P(LayerTreeHostImplTest, layersFreeTextures)
ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
// Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of). // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of).
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)));
TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->context3D()); TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->context3D());
m_hostImpl->initializeRenderer(outputSurface.Pass()); m_hostImpl->initializeRenderer(outputSurface.Pass());
m_hostImpl->setRootLayer(rootLayer.Pass()); m_hostImpl->setRootLayer(rootLayer.Pass());
@ -3060,12 +3060,12 @@ TEST_P(LayerTreeHostImplTest, layersFreeTextures)
m_hostImpl->didDrawAllLayers(frame); m_hostImpl->didDrawAllLayers(frame);
m_hostImpl->swapBuffers(); m_hostImpl->swapBuffers();
EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u);
// Kill the layer tree. // Kill the layer tree.
m_hostImpl->setRootLayer(LayerImpl::create(100)); m_hostImpl->setRootLayer(LayerImpl::create(100));
// There should be no textures left in use after. // There should be no textures left in use after.
EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures());
} }
class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D {
@ -3076,11 +3076,11 @@ public:
TEST_P(LayerTreeHostImplTest, hasTransparentBackground) TEST_P(LayerTreeHostImplTest, hasTransparentBackground)
{ {
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>();
MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(context->context3D()); MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->context3D());
// Run test case // Run test case
scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.Pass(), LayerImpl::create(1)); scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, outputSurface.Pass(), LayerImpl::create(1));
myHostImpl->setBackgroundColor(SK_ColorWHITE); myHostImpl->setBackgroundColor(SK_ColorWHITE);
// Verify one quad is drawn when transparent background set is not set. // Verify one quad is drawn when transparent background set is not set.
@ -3120,9 +3120,9 @@ static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, LayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPtr, LayerImpl*& childPtr, const gfx::Size& rootSize) static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, LayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPtr, LayerImpl*& childPtr, const gfx::Size& rootSize)
{ {
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
layerTreeHostImpl->initializeRenderer(context.Pass()); layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
layerTreeHostImpl->setViewportSize(rootSize, rootSize); layerTreeHostImpl->setViewportSize(rootSize, rootSize);
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3164,11 +3164,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
LayerImpl* rootPtr; LayerImpl* rootPtr;
LayerImpl* surfaceLayerPtr; LayerImpl* surfaceLayerPtr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(100, 100); gfx::Size rootSize(100, 100);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3275,11 +3275,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
LayerImpl* layerS1Ptr; LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr; LayerImpl* layerS2Ptr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000); gfx::Size rootSize(1000, 1000);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3386,11 +3386,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
LayerImpl* layerS1Ptr; LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr; LayerImpl* layerS2Ptr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000); gfx::Size rootSize(1000, 1000);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3498,11 +3498,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
LayerImpl* layerS1Ptr; LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr; LayerImpl* layerS2Ptr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000); gfx::Size rootSize(1000, 1000);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3579,11 +3579,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
LayerImpl* rootPtr; LayerImpl* rootPtr;
LayerImpl* layerS1Ptr; LayerImpl* layerS1Ptr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000); gfx::Size rootSize(1000, 1000);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3663,11 +3663,11 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
LayerImpl* layerS1Ptr; LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr; LayerImpl* layerS2Ptr;
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000); gfx::Size rootSize(1000, 1000);
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
scoped_ptr<LayerImpl> root = LayerImpl::create(1); scoped_ptr<LayerImpl> root = LayerImpl::create(1);
@ -3782,8 +3782,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithScissor)
gfx::Rect childRect(10, 10, 50, 50); gfx::Rect childRect(10, 10, 50, 50);
gfx::Rect grandChildRect(5, 5, 150, 150); gfx::Rect grandChildRect(5, 5, 150, 150);
scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
myHostImpl->initializeRenderer(context.Pass()); myHostImpl->initializeRenderer(outputSurface.Pass());
root->setAnchorPoint(gfx::PointF(0, 0)); root->setAnchorPoint(gfx::PointF(0, 0));
root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); root->setPosition(gfx::PointF(rootRect.x(), rootRect.y()));
@ -4228,7 +4228,7 @@ public:
// RendererClient implementation. // RendererClient implementation.
virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_viewportSize; } virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_viewportSize; }
virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settings; } virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settings; }
virtual void didLoseContext() OVERRIDE { } virtual void didLoseOutputSurface() OVERRIDE { }
virtual void onSwapBuffersComplete() OVERRIDE { } virtual void onSwapBuffersComplete() OVERRIDE { }
virtual void setFullRootLayerDamage() OVERRIDE { } virtual void setFullRootLayerDamage() OVERRIDE { }
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { } virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { }
@ -4523,9 +4523,9 @@ static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses)
{ {
scoped_ptr<GraphicsContext> context(createContext()); scoped_ptr<OutputSurface> outputSurface(createOutputSurface());
ASSERT_TRUE(context->context3D()); ASSERT_TRUE(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), &m_proxy)); scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), &m_proxy));

@ -7,8 +7,8 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "cc/content_layer.h" #include "cc/content_layer.h"
#include "cc/content_layer_client.h" #include "cc/content_layer_client.h"
#include "cc/graphics_context.h"
#include "cc/layer_tree_host_impl.h" #include "cc/layer_tree_host_impl.h"
#include "cc/output_surface.h"
#include "cc/single_thread_proxy.h" #include "cc/single_thread_proxy.h"
#include "cc/test/fake_content_layer_client.h" #include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_client.h"
@ -1401,7 +1401,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D()); CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
switch (impl->sourceFrameNumber()) { switch (impl->sourceFrameNumber()) {
case 0: case 0:
@ -1435,7 +1435,7 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D()); CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
// Number of textures used for draw should always be one. // Number of textures used for draw should always be one.
EXPECT_EQ(1, context->numUsedTextures()); EXPECT_EQ(1, context->numUsedTextures());
@ -1505,7 +1505,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D()); CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
switch (impl->sourceFrameNumber()) { switch (impl->sourceFrameNumber()) {
case 0: case 0:
@ -1557,7 +1557,7 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{ {
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D()); CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
// Number of textures used for drawing should two except for frame 4 // Number of textures used for drawing should two except for frame 4
// where the viewport only contains one layer. // where the viewport only contains one layer.
@ -1958,7 +1958,7 @@ public:
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces) SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces)
// A loseContext(1) should lead to a didRecreateOutputSurface(true) // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true)
class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest {
public: public:
LayerTreeHostTestSetSingleLostContext() LayerTreeHostTestSetSingleLostContext()
@ -1972,7 +1972,7 @@ public:
virtual void didCommitAndDrawFrame() OVERRIDE virtual void didCommitAndDrawFrame() OVERRIDE
{ {
m_layerTreeHost->loseContext(1); m_layerTreeHost->loseOutputSurface(1);
} }
virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
@ -1991,7 +1991,7 @@ TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread)
runTest(true); runTest(true);
} }
// A loseContext(10) should lead to a didRecreateOutputSurface(false), and // A loseOutputSurface(10) should lead to a didRecreateOutputSurface(false), and
// a finishAllRendering() should not hang. // a finishAllRendering() should not hang.
class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest { class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest {
public: public:
@ -2006,7 +2006,7 @@ public:
virtual void didCommitAndDrawFrame() OVERRIDE virtual void didCommitAndDrawFrame() OVERRIDE
{ {
m_layerTreeHost->loseContext(10); m_layerTreeHost->loseOutputSurface(10);
} }
virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
@ -2880,7 +2880,7 @@ public:
EXPECT_TRUE(m_layer->haveBackingTexture()); EXPECT_TRUE(m_layer->haveBackingTexture());
m_layerTreeHost->setVisible(false); m_layerTreeHost->setVisible(false);
postEvictTextures(); postEvictTextures();
m_layerTreeHost->loseContext(1); m_layerTreeHost->loseOutputSurface(1);
m_layerTreeHost->setVisible(true); m_layerTreeHost->setVisible(true);
break; break;
default: default:

@ -146,7 +146,7 @@ void NinePatchLayerImpl::didDraw(ResourceProvider* resourceProvider)
{ {
} }
void NinePatchLayerImpl::didLoseContext() void NinePatchLayerImpl::didLoseOutputSurface()
{ {
m_resourceId = 0; m_resourceId = 0;
} }

@ -29,7 +29,7 @@ public:
virtual void didDraw(ResourceProvider*) OVERRIDE; virtual void didDraw(ResourceProvider*) OVERRIDE;
virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE; virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE;
virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
protected: protected:
explicit NinePatchLayerImpl(int id); explicit NinePatchLayerImpl(int id);

@ -12,8 +12,8 @@
#include "cc/single_thread_proxy.h" #include "cc/single_thread_proxy.h"
#include "cc/resource_update_queue.h" #include "cc/resource_update_queue.h"
#include "cc/texture_uploader.h" #include "cc/texture_uploader.h"
#include "cc/test/fake_graphics_context.h"
#include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_tree_test_common.h" #include "cc/test/layer_tree_test_common.h"
#include "SkBitmap.h" #include "SkBitmap.h"
@ -103,13 +103,13 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap)
m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024); m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024);
m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
scoped_ptr<GraphicsContext> context; scoped_ptr<OutputSurface> outputSurface;
scoped_ptr<ResourceProvider> resourceProvider; scoped_ptr<ResourceProvider> resourceProvider;
{ {
DebugScopedSetImplThread implThread(proxy()); DebugScopedSetImplThread implThread(proxy());
DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy());
context = WebKit::createFakeGraphicsContext(); outputSurface = createFakeOutputSurface();
resourceProvider = ResourceProvider::create(context.get()); resourceProvider = ResourceProvider::create(outputSurface.get());
params.texture->acquireBackingTexture(resourceProvider.get()); params.texture->acquireBackingTexture(resourceProvider.get());
ASSERT_TRUE(params.texture->haveBackingTexture()); ASSERT_TRUE(params.texture->haveBackingTexture());
} }

21
cc/output_surface.h Normal file

@ -0,0 +1,21 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_OUTPUT_SURFACE_H_
#define CC_OUTPUT_SURFACE_H_
#include <public/WebCompositorOutputSurface.h>
namespace WebKit {
class WebGraphicsContext3D;
}
namespace cc {
// TODO(danakj): Move WebCompositorOutputSurface implementation to here.
typedef WebKit::WebCompositorOutputSurface OutputSurface;
} // namespace cc
#endif // CC_OUTPUT_SURFACE_H_

@ -7,7 +7,7 @@
#include "cc/prioritized_resource_manager.h" #include "cc/prioritized_resource_manager.h"
#include "cc/resource.h" #include "cc/resource.h"
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
#include "cc/test/fake_graphics_context.h" #include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h" #include "cc/test/fake_proxy.h"
#include "cc/test/tiled_layer_test_common.h" #include "cc/test/tiled_layer_test_common.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
@ -22,10 +22,10 @@ public:
: m_proxy(scoped_ptr<Thread>(NULL)) : m_proxy(scoped_ptr<Thread>(NULL))
, m_textureSize(256, 256) , m_textureSize(256, 256)
, m_textureFormat(GL_RGBA) , m_textureFormat(GL_RGBA)
, m_context(WebKit::createFakeGraphicsContext()) , m_outputSurface(createFakeOutputSurface())
{ {
DebugScopedSetImplThread implThread(&m_proxy); DebugScopedSetImplThread implThread(&m_proxy);
m_resourceProvider = ResourceProvider::create(m_context.get()); m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
} }
virtual ~PrioritizedResourceTest() virtual ~PrioritizedResourceTest()
@ -98,7 +98,7 @@ protected:
FakeProxy m_proxy; FakeProxy m_proxy;
const gfx::Size m_textureSize; const gfx::Size m_textureSize;
const GLenum m_textureFormat; const GLenum m_textureFormat;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
}; };

@ -55,7 +55,7 @@ public:
// Attempts to initialize a context to use for rendering. Returns false if the context could not be created. // Attempts to initialize a context to use for rendering. Returns false if the context could not be created.
// The context will not be used and no frames may be produced until initializeRenderer() is called. // The context will not be used and no frames may be produced until initializeRenderer() is called.
virtual bool initializeContext() = 0; virtual bool initializeOutputSurface() = 0;
// Indicates that the compositing surface associated with our context is ready to use. // Indicates that the compositing surface associated with our context is ready to use.
virtual void setSurfaceReady() = 0; virtual void setSurfaceReady() = 0;
@ -67,7 +67,7 @@ public:
// Attempts to recreate the context and layer renderer after a context lost. Returns false if the renderer couldn't be // Attempts to recreate the context and layer renderer after a context lost. Returns false if the renderer couldn't be
// reinitialized. // reinitialized.
virtual bool recreateContext() = 0; virtual bool recreateOutputSurface() = 0;
virtual void renderingStats(RenderingStats*) = 0; virtual void renderingStats(RenderingStats*) = 0;
@ -98,7 +98,7 @@ public:
virtual void acquireLayerTextures() = 0; virtual void acquireLayerTextures() = 0;
// Testing hooks // Testing hooks
virtual void loseContext() = 0; virtual void loseOutputSurface() = 0;
protected: protected:
explicit Proxy(scoped_ptr<Thread> implThread); explicit Proxy(scoped_ptr<Thread> implThread);

@ -19,7 +19,7 @@ class CC_EXPORT RendererClient {
public: public:
virtual const gfx::Size& deviceViewportSize() const = 0; virtual const gfx::Size& deviceViewportSize() const = 0;
virtual const LayerTreeSettings& settings() const = 0; virtual const LayerTreeSettings& settings() const = 0;
virtual void didLoseContext() = 0; virtual void didLoseOutputSurface() = 0;
virtual void onSwapBuffersComplete() = 0; virtual void onSwapBuffersComplete() = 0;
virtual void setFullRootLayerDamage() = 0; virtual void setFullRootLayerDamage() = 0;
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0; virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;

@ -109,7 +109,7 @@ ResourceProvider::Child::~Child()
{ {
} }
scoped_ptr<ResourceProvider> ResourceProvider::create(GraphicsContext* context) scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context)
{ {
scoped_ptr<ResourceProvider> resourceProvider(new ResourceProvider(context)); scoped_ptr<ResourceProvider> resourceProvider(new ResourceProvider(context));
if (!resourceProvider->initialize()) if (!resourceProvider->initialize())
@ -119,7 +119,7 @@ scoped_ptr<ResourceProvider> ResourceProvider::create(GraphicsContext* context)
ResourceProvider::~ResourceProvider() ResourceProvider::~ResourceProvider()
{ {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !context3d->makeContextCurrent()) if (!context3d || !context3d->makeContextCurrent())
return; return;
m_textureUploader.reset(); m_textureUploader.reset();
@ -129,7 +129,7 @@ ResourceProvider::~ResourceProvider()
WebGraphicsContext3D* ResourceProvider::graphicsContext3D() WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
return m_context->context3D(); return m_outputSurface->context3D();
} }
bool ResourceProvider::inUseByConsumer(ResourceId id) bool ResourceProvider::inUseByConsumer(ResourceId id)
@ -162,7 +162,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const g
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
unsigned textureId = 0; unsigned textureId = 0;
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
GLC(context3d, textureId = context3d->createTexture()); GLC(context3d, textureId = context3d->createTexture());
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
@ -201,7 +201,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
@ -237,12 +237,12 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
{ {
Resource* resource = &it->second; Resource* resource = &it->second;
if (resource->glId && !resource->external) { if (resource->glId && !resource->external) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
GLC(context3d, context3d->deleteTexture(resource->glId)); GLC(context3d, context3d->deleteTexture(resource->glId));
} }
if (resource->glPixelBufferId) { if (resource->glPixelBufferId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId)); GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
} }
@ -286,7 +286,7 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx:
DCHECK(!resource->exported); DCHECK(!resource->exported);
if (resource->glId) { if (resource->glId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
DCHECK(m_textureUploader.get()); DCHECK(m_textureUploader.get());
context3d->bindTexture(GL_TEXTURE_2D, resource->glId); context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
@ -349,7 +349,7 @@ void ResourceProvider::flushUploads()
void ResourceProvider::flush() void ResourceProvider::flush()
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (context3d) if (context3d)
context3d->flush(); context3d->flush();
} }
@ -357,7 +357,7 @@ void ResourceProvider::flush()
bool ResourceProvider::shallowFlushIfSupported() bool ResourceProvider::shallowFlushIfSupported()
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !m_useShallowFlush) if (!context3d || !m_useShallowFlush)
return false; return false;
@ -479,8 +479,8 @@ ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware()
m_resourceProvider->unlockForWrite(m_resourceId); m_resourceProvider->unlockForWrite(m_resourceId);
} }
ResourceProvider::ResourceProvider(GraphicsContext* context) ResourceProvider::ResourceProvider(OutputSurface* context)
: m_context(context) : m_outputSurface(context)
, m_nextId(1) , m_nextId(1)
, m_nextChild(1) , m_nextChild(1)
, m_defaultResourceType(GLTexture) , m_defaultResourceType(GLTexture)
@ -494,7 +494,7 @@ ResourceProvider::ResourceProvider(GraphicsContext* context)
bool ResourceProvider::initialize() bool ResourceProvider::initialize()
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d) { if (!context3d) {
m_maxTextureSize = INT_MAX / 2; m_maxTextureSize = INT_MAX / 2;
return true; return true;
@ -559,7 +559,7 @@ void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
list->sync_point = 0; list->sync_point = 0;
list->resources.clear(); list->resources.clear();
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !context3d->makeContextCurrent()) { if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing. // FIXME: Implement this path for software compositing.
return; return;
@ -580,7 +580,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
list->sync_point = 0; list->sync_point = 0;
list->resources.clear(); list->resources.clear();
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !context3d->makeContextCurrent()) { if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing. // FIXME: Implement this path for software compositing.
return; return;
@ -604,7 +604,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso
void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources) void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources)
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !context3d->makeContextCurrent()) { if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing. // FIXME: Implement this path for software compositing.
return; return;
@ -636,7 +636,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis
void ResourceProvider::receiveFromParent(const TransferableResourceList& resources) void ResourceProvider::receiveFromParent(const TransferableResourceList& resources)
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
if (!context3d || !context3d->makeContextCurrent()) { if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing. // FIXME: Implement this path for software compositing.
return; return;
@ -660,7 +660,7 @@ void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc
bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource) bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource)
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
ResourceMap::iterator it = m_resources.find(id); ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end()); CHECK(it != m_resources.end());
Resource* source = &it->second; Resource* source = &it->second;
@ -696,7 +696,7 @@ void ResourceProvider::acquirePixelBuffer(ResourceId id)
DCHECK(!resource->exported); DCHECK(!resource->exported);
if (resource->glId) { if (resource->glId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
if (!resource->glPixelBufferId) if (!resource->glPixelBufferId)
resource->glPixelBufferId = context3d->createBuffer(); resource->glPixelBufferId = context3d->createBuffer();
@ -731,7 +731,7 @@ void ResourceProvider::releasePixelBuffer(ResourceId id)
if (resource->glId) { if (resource->glId) {
DCHECK(resource->glPixelBufferId); DCHECK(resource->glPixelBufferId);
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
context3d->bindBuffer( context3d->bindBuffer(
GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
@ -762,7 +762,7 @@ uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id)
DCHECK(!resource->exported); DCHECK(!resource->exported);
if (resource->glId) { if (resource->glId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
DCHECK(resource->glPixelBufferId); DCHECK(resource->glPixelBufferId);
context3d->bindBuffer( context3d->bindBuffer(
@ -792,7 +792,7 @@ void ResourceProvider::unmapPixelBuffer(ResourceId id)
DCHECK(!resource->exported); DCHECK(!resource->exported);
if (resource->glId) { if (resource->glId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
DCHECK(resource->glPixelBufferId); DCHECK(resource->glPixelBufferId);
context3d->bindBuffer( context3d->bindBuffer(
@ -816,7 +816,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id)
DCHECK(!resource->exported); DCHECK(!resource->exported);
if (resource->glId) { if (resource->glId) {
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
DCHECK(context3d); DCHECK(context3d);
DCHECK(resource->glPixelBufferId); DCHECK(resource->glPixelBufferId);
context3d->bindTexture(GL_TEXTURE_2D, resource->glId); context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
@ -853,7 +853,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id)
void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter) void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter)
{ {
DCHECK(m_threadChecker.CalledOnValidThread()); DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D(); WebGraphicsContext3D* context3d = m_outputSurface->context3D();
ResourceMap::iterator it = m_resources.find(resourceId); ResourceMap::iterator it = m_resources.find(resourceId);
DCHECK(it != m_resources.end()); DCHECK(it != m_resources.end());
Resource* resource = &it->second; Resource* resource = &it->second;

@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "cc/cc_export.h" #include "cc/cc_export.h"
#include "cc/graphics_context.h" #include "cc/output_surface.h"
#include "cc/texture_copier.h" #include "cc/texture_copier.h"
#include "cc/transferable_resource.h" #include "cc/transferable_resource.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
@ -46,7 +46,7 @@ public:
Bitmap, Bitmap,
}; };
static scoped_ptr<ResourceProvider> create(GraphicsContext*); static scoped_ptr<ResourceProvider> create(OutputSurface*);
virtual ~ResourceProvider(); virtual ~ResourceProvider();
@ -257,7 +257,7 @@ private:
}; };
typedef base::hash_map<int, Child> ChildMap; typedef base::hash_map<int, Child> ChildMap;
explicit ResourceProvider(GraphicsContext*); explicit ResourceProvider(OutputSurface*);
bool initialize(); bool initialize();
const Resource* lockForRead(ResourceId); const Resource* lockForRead(ResourceId);
@ -269,7 +269,7 @@ private:
bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, TransferableResource*); bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, TransferableResource*);
void deleteResourceInternal(ResourceMap::iterator it); void deleteResourceInternal(ResourceMap::iterator it);
GraphicsContext* m_context; OutputSurface* m_outputSurface;
ResourceId m_nextId; ResourceId m_nextId;
ResourceMap m_resources; ResourceMap m_resources;
int m_nextChild; int m_nextChild;

@ -5,17 +5,17 @@
#include "cc/resource_provider.h" #include "cc/resource_provider.h"
#include "base/logging.h" #include "base/logging.h"
#include "cc/graphics_context.h" #include "cc/output_surface.h"
#include "cc/scoped_ptr_deque.h" #include "cc/scoped_ptr_deque.h"
#include "cc/scoped_ptr_hash_map.h" #include "cc/scoped_ptr_hash_map.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h" #include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h" #include "cc/test/fake_web_compositor_output_surface.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h" #include "third_party/khronos/GLES2/gl2ext.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include <public/WebGraphicsContext3D.h>
using namespace WebKit; using namespace WebKit;
@ -272,13 +272,13 @@ class ResourceProviderTest : public testing::TestWithParam<ResourceProvider::Res
public: public:
ResourceProviderTest() ResourceProviderTest()
: m_sharedData(ContextSharedData::create()) : m_sharedData(ContextSharedData::create())
, m_context(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>().PassAs<WebKit::WebGraphicsContext3D>())) , m_outputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>().PassAs<WebKit::WebGraphicsContext3D>()))
, m_resourceProvider(ResourceProvider::create(m_context.get())) , m_resourceProvider(ResourceProvider::create(m_outputSurface.get()))
{ {
m_resourceProvider->setDefaultResourceType(GetParam()); m_resourceProvider->setDefaultResourceType(GetParam());
} }
ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_context->context3D()); } ResourceProviderContext* context() { return static_cast<ResourceProviderContext*>(m_outputSurface->context3D()); }
void getResourcePixels(ResourceProvider::ResourceId id, const gfx::Size& size, WGC3Denum format, uint8_t* pixels) void getResourcePixels(ResourceProvider::ResourceId id, const gfx::Size& size, WGC3Denum format, uint8_t* pixels)
{ {
@ -302,7 +302,7 @@ public:
protected: protected:
scoped_ptr<ContextSharedData> m_sharedData; scoped_ptr<ContextSharedData> m_sharedData;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
}; };
@ -417,8 +417,8 @@ TEST_P(ResourceProviderTest, TransferResources)
if (GetParam() != ResourceProvider::GLTexture) if (GetParam() != ResourceProvider::GLTexture)
return; return;
scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); scoped_ptr<OutputSurface> childOutputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childContext.get())); scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get()));
gfx::Size size(1, 1); gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA; WGC3Denum format = GL_RGBA;
@ -493,7 +493,7 @@ TEST_P(ResourceProviderTest, TransferResources)
EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1)); EXPECT_FALSE(childResourceProvider->inUseByConsumer(id1));
EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2)); EXPECT_FALSE(childResourceProvider->inUseByConsumer(id2));
ResourceProviderContext* childContext3D = static_cast<ResourceProviderContext*>(childContext->context3D()); ResourceProviderContext* childContext3D = static_cast<ResourceProviderContext*>(childOutputSurface->context3D());
{ {
ResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), id1); ResourceProvider::ScopedReadLockGL lock(childResourceProvider.get(), id1);
ASSERT_NE(0U, lock.textureId()); ASSERT_NE(0U, lock.textureId());
@ -534,8 +534,8 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
if (GetParam() != ResourceProvider::GLTexture) if (GetParam() != ResourceProvider::GLTexture)
return; return;
scoped_ptr<GraphicsContext> childContext(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>())); scoped_ptr<OutputSurface> childOutputSurface(FakeWebCompositorOutputSurface::create(ResourceProviderContext::create(m_sharedData.get()).PassAs<WebKit::WebGraphicsContext3D>()));
scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childContext.get())); scoped_ptr<ResourceProvider> childResourceProvider(ResourceProvider::create(childOutputSurface.get()));
gfx::Size size(1, 1); gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA; WGC3Denum format = GL_RGBA;
@ -595,7 +595,7 @@ TEST_P(ResourceProviderTest, ScopedSampler)
if (GetParam() != ResourceProvider::GLTexture) if (GetParam() != ResourceProvider::GLTexture)
return; return;
scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext))); scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D()); TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));

@ -121,7 +121,7 @@ public:
protected: protected:
virtual void SetUp() virtual void SetUp()
{ {
m_context = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this))); m_outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this)));
m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 150); m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 150);
m_bitmap.allocPixels(); m_bitmap.allocPixels();
@ -133,7 +133,7 @@ protected:
} }
m_resourceManager->prioritizeTextures(); m_resourceManager->prioritizeTextures();
m_resourceProvider = ResourceProvider::create(m_context.get()); m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
} }
@ -198,7 +198,7 @@ protected:
protected: protected:
// Classes required to interact and test the ResourceUpdateController // Classes required to interact and test the ResourceUpdateController
FakeProxy m_proxy; FakeProxy m_proxy;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
scoped_ptr<ResourceUpdateQueue> m_queue; scoped_ptr<ResourceUpdateQueue> m_queue;
scoped_ptr<PrioritizedResource> m_textures[4]; scoped_ptr<PrioritizedResource> m_textures[4];

@ -104,18 +104,18 @@ void Scheduler::didSwapBuffersComplete()
m_frameRateController->didFinishFrame(); m_frameRateController->didFinishFrame();
} }
void Scheduler::didLoseContext() void Scheduler::didLoseOutputSurface()
{ {
TRACE_EVENT0("cc", "Scheduler::didLoseContext"); TRACE_EVENT0("cc", "Scheduler::didLoseOutputSurface");
m_frameRateController->didAbortAllPendingFrames(); m_frameRateController->didAbortAllPendingFrames();
m_stateMachine.didLoseContext(); m_stateMachine.didLoseOutputSurface();
processScheduledActions(); processScheduledActions();
} }
void Scheduler::didRecreateContext() void Scheduler::didRecreateOutputSurface()
{ {
TRACE_EVENT0("cc", "Scheduler::didRecreateContext"); TRACE_EVENT0("cc", "Scheduler::didRecreateOutputSurface");
m_stateMachine.didRecreateContext(); m_stateMachine.didRecreateOutputSurface();
processScheduledActions(); processScheduledActions();
} }
@ -174,7 +174,7 @@ void Scheduler::processScheduledActions()
if (result.didSwap) if (result.didSwap)
m_frameRateController->didBeginFrame(); m_frameRateController->didBeginFrame();
break; break;
} case SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION: } case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION:
m_client->scheduledActionBeginContextRecreation(); m_client->scheduledActionBeginContextRecreation();
break; break;
case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:

@ -79,8 +79,8 @@ public:
void setSwapBuffersCompleteSupported(bool); void setSwapBuffersCompleteSupported(bool);
void didSwapBuffersComplete(); void didSwapBuffersComplete();
void didLoseContext(); void didLoseOutputSurface();
void didRecreateContext(); void didRecreateOutputSurface();
bool commitPending() const { return m_stateMachine.commitPending(); } bool commitPending() const { return m_stateMachine.commitPending(); }
bool redrawPending() const { return m_stateMachine.redrawPending(); } bool redrawPending() const { return m_stateMachine.redrawPending(); }

@ -28,7 +28,7 @@ SchedulerStateMachine::SchedulerStateMachine()
, m_canDraw(false) , m_canDraw(false)
, m_drawIfPossibleFailed(false) , m_drawIfPossibleFailed(false)
, m_textureState(LAYER_TEXTURE_STATE_UNLOCKED) , m_textureState(LAYER_TEXTURE_STATE_UNLOCKED)
, m_contextState(CONTEXT_ACTIVE) , m_outputSurfaceState(OUTPUT_SURFACE_ACTIVE)
{ {
} }
@ -53,7 +53,7 @@ std::string SchedulerStateMachine::toString()
base::StringAppendF(&str, "m_canDraw = %d; ", m_canDraw); base::StringAppendF(&str, "m_canDraw = %d; ", m_canDraw);
base::StringAppendF(&str, "m_drawIfPossibleFailed = %d; ", m_drawIfPossibleFailed); base::StringAppendF(&str, "m_drawIfPossibleFailed = %d; ", m_drawIfPossibleFailed);
base::StringAppendF(&str, "m_textureState = %d; ", m_textureState); base::StringAppendF(&str, "m_textureState = %d; ", m_textureState);
base::StringAppendF(&str, "m_contextState = %d; ", m_contextState); base::StringAppendF(&str, "m_outputSurfaceState = %d; ", m_outputSurfaceState);
return str; return str;
} }
@ -93,7 +93,7 @@ bool SchedulerStateMachine::shouldDraw() const
return false; return false;
if (hasDrawnThisFrame()) if (hasDrawnThisFrame())
return false; return false;
if (m_contextState != CONTEXT_ACTIVE) if (m_outputSurfaceState != OUTPUT_SURFACE_ACTIVE)
return false; return false;
return true; return true;
} }
@ -120,13 +120,13 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD; return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD;
switch (m_commitState) { switch (m_commitState) {
case COMMIT_STATE_IDLE: case COMMIT_STATE_IDLE:
if (m_contextState != CONTEXT_ACTIVE && m_needsForcedRedraw) if (m_outputSurfaceState != OUTPUT_SURFACE_ACTIVE && m_needsForcedRedraw)
return ACTION_DRAW_FORCED; return ACTION_DRAW_FORCED;
if (m_contextState != CONTEXT_ACTIVE && m_needsForcedCommit) if (m_outputSurfaceState != OUTPUT_SURFACE_ACTIVE && m_needsForcedCommit)
return ACTION_BEGIN_FRAME; return ACTION_BEGIN_FRAME;
if (m_contextState == CONTEXT_LOST) if (m_outputSurfaceState == OUTPUT_SURFACE_LOST)
return ACTION_BEGIN_CONTEXT_RECREATION; return ACTION_BEGIN_OUTPUT_SURFACE_RECREATION;
if (m_contextState == CONTEXT_RECREATING) if (m_outputSurfaceState == OUTPUT_SURFACE_RECREATING)
return ACTION_NONE; return ACTION_NONE;
if (shouldDraw()) if (shouldDraw())
return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE; return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE;
@ -143,7 +143,7 @@ SchedulerStateMachine::Action SchedulerStateMachine::nextAction() const
return ACTION_COMMIT; return ACTION_COMMIT;
case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: case COMMIT_STATE_WAITING_FOR_FIRST_DRAW:
if (shouldDraw() || m_contextState == CONTEXT_LOST) if (shouldDraw() || m_outputSurfaceState == OUTPUT_SURFACE_LOST)
return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE; return m_needsForcedRedraw ? ACTION_DRAW_FORCED : ACTION_DRAW_IF_POSSIBLE;
// COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_canDraw is false // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_canDraw is false
// or textures are not available, proceed to the next step (similar as in COMMIT_STATE_IDLE). // or textures are not available, proceed to the next step (similar as in COMMIT_STATE_IDLE).
@ -201,10 +201,10 @@ void SchedulerStateMachine::updateState(Action action)
m_textureState = LAYER_TEXTURE_STATE_UNLOCKED; m_textureState = LAYER_TEXTURE_STATE_UNLOCKED;
return; return;
case ACTION_BEGIN_CONTEXT_RECREATION: case ACTION_BEGIN_OUTPUT_SURFACE_RECREATION:
DCHECK(m_commitState == COMMIT_STATE_IDLE); DCHECK(m_commitState == COMMIT_STATE_IDLE);
DCHECK(m_contextState == CONTEXT_LOST); DCHECK(m_outputSurfaceState == OUTPUT_SURFACE_LOST);
m_contextState = CONTEXT_RECREATING; m_outputSurfaceState = OUTPUT_SURFACE_RECREATING;
return; return;
case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
@ -232,7 +232,7 @@ bool SchedulerStateMachine::vsyncCallbackNeeded() const
if (m_needsForcedRedraw) if (m_needsForcedRedraw)
return true; return true;
return m_needsRedraw && m_visible && m_contextState == CONTEXT_ACTIVE; return m_needsRedraw && m_visible && m_outputSurfaceState == OUTPUT_SURFACE_ACTIVE;
} }
void SchedulerStateMachine::didEnterVSync() void SchedulerStateMachine::didEnterVSync()
@ -307,17 +307,17 @@ void SchedulerStateMachine::beginFrameAborted()
} }
} }
void SchedulerStateMachine::didLoseContext() void SchedulerStateMachine::didLoseOutputSurface()
{ {
if (m_contextState == CONTEXT_LOST || m_contextState == CONTEXT_RECREATING) if (m_outputSurfaceState == OUTPUT_SURFACE_LOST || m_outputSurfaceState == OUTPUT_SURFACE_RECREATING)
return; return;
m_contextState = CONTEXT_LOST; m_outputSurfaceState = OUTPUT_SURFACE_LOST;
} }
void SchedulerStateMachine::didRecreateContext() void SchedulerStateMachine::didRecreateOutputSurface()
{ {
DCHECK(m_contextState == CONTEXT_RECREATING); DCHECK(m_outputSurfaceState == OUTPUT_SURFACE_RECREATING);
m_contextState = CONTEXT_ACTIVE; m_outputSurfaceState = OUTPUT_SURFACE_ACTIVE;
setNeedsCommit(); setNeedsCommit();
} }

@ -39,10 +39,10 @@ public:
LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD,
}; };
enum ContextState { enum OutputSurfaceState {
CONTEXT_ACTIVE, OUTPUT_SURFACE_ACTIVE,
CONTEXT_LOST, OUTPUT_SURFACE_LOST,
CONTEXT_RECREATING, OUTPUT_SURFACE_RECREATING,
}; };
bool commitPending() const bool commitPending() const
@ -58,7 +58,7 @@ public:
ACTION_COMMIT, ACTION_COMMIT,
ACTION_DRAW_IF_POSSIBLE, ACTION_DRAW_IF_POSSIBLE,
ACTION_DRAW_FORCED, ACTION_DRAW_FORCED,
ACTION_BEGIN_CONTEXT_RECREATION, ACTION_BEGIN_OUTPUT_SURFACE_RECREATION,
ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD,
}; };
Action nextAction() const; Action nextAction() const;
@ -120,8 +120,8 @@ public:
// when such behavior would be undesirable. // when such behavior would be undesirable.
void setCanDraw(bool can) { m_canDraw = can; } void setCanDraw(bool can) { m_canDraw = can; }
void didLoseContext(); void didLoseOutputSurface();
void didRecreateContext(); void didRecreateOutputSurface();
// Exposed for testing purposes. // Exposed for testing purposes.
void setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int); void setMaximumNumberOfFailedDrawsBeforeDrawIsForced(int);
@ -155,7 +155,7 @@ protected:
bool m_canDraw; bool m_canDraw;
bool m_drawIfPossibleFailed; bool m_drawIfPossibleFailed;
TextureState m_textureState; TextureState m_textureState;
ContextState m_contextState; OutputSurfaceState m_outputSurfaceState;
DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
}; };

@ -637,16 +637,16 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle)
state.setVisible(true); state.setVisible(true);
state.setCanDraw(true); state.setCanDraw(true);
state.didLoseContext(); state.didLoseOutputSurface();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
state.updateState(state.nextAction()); state.updateState(state.nextAction());
// Once context recreation begins, nothing should happen. // Once context recreation begins, nothing should happen.
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Recreate the context // Recreate the context
state.didRecreateContext(); state.didRecreateOutputSurface();
// When the context is recreated, we should begin a commit // When the context is recreated, we should begin a commit
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
@ -660,9 +660,9 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhileRe
state.setVisible(true); state.setVisible(true);
state.setCanDraw(true); state.setCanDraw(true);
state.didLoseContext(); state.didLoseOutputSurface();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
state.updateState(state.nextAction()); state.updateState(state.nextAction());
// Once context recreation begins, nothing should happen. // Once context recreation begins, nothing should happen.
@ -673,7 +673,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhileRe
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Recreate the context // Recreate the context
state.didRecreateContext(); state.didRecreateOutputSurface();
// When the context is recreated, we should begin a commit // When the context is recreated, we should begin a commit
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
@ -710,7 +710,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress)
state.didLeaveVSync(); state.didLeaveVSync();
// Cause a lost context while the begin frame is in flight. // Cause a lost context while the begin frame is in flight.
state.didLoseContext(); state.didLoseOutputSurface();
// Ask for another draw. Expect nothing happens. // Ask for another draw. Expect nothing happens.
state.setNeedsRedraw(true); state.setNeedsRedraw(true);
@ -728,9 +728,9 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress)
// Expect to be told to begin context recreation, independent of vsync state // Expect to be told to begin context recreation, independent of vsync state
state.didEnterVSync(); state.didEnterVSync();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
state.didLeaveVSync(); state.didLeaveVSync();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
} }
TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCommitRequested) TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCommitRequested)
@ -753,7 +753,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCo
state.didLeaveVSync(); state.didLeaveVSync();
// Cause a lost context while the begin frame is in flight. // Cause a lost context while the begin frame is in flight.
state.didLoseContext(); state.didLoseOutputSurface();
// Ask for another draw and also set needs commit. Expect nothing happens. // Ask for another draw and also set needs commit. Expect nothing happens.
state.setNeedsRedraw(true); state.setNeedsRedraw(true);
@ -772,9 +772,9 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCo
// Expect to be told to begin context recreation, independent of vsync state // Expect to be told to begin context recreation, independent of vsync state
state.didEnterVSync(); state.didEnterVSync();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
state.didLeaveVSync(); state.didLeaveVSync();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
} }
@ -785,7 +785,7 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost)
state.setCanDraw(true); state.setCanDraw(true);
// Cause a lost context lost. // Cause a lost context lost.
state.didLoseContext(); state.didLoseOutputSurface();
// Ask a forced redraw and verify it ocurrs. // Ask a forced redraw and verify it ocurrs.
state.setNeedsForcedRedraw(true); state.setNeedsForcedRedraw(true);
@ -797,7 +797,7 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost)
state.setNeedsForcedRedraw(false); state.setNeedsForcedRedraw(false);
// Expect to be told to begin context recreation, independent of vsync state // Expect to be told to begin context recreation, independent of vsync state
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, state.nextAction());
state.updateState(state.nextAction()); state.updateState(state.nextAction());
// Ask a forced redraw and verify it ocurrs. // Ask a forced redraw and verify it ocurrs.
@ -853,7 +853,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost)
state.setCanDraw(true); state.setCanDraw(true);
state.setNeedsCommit(); state.setNeedsCommit();
state.setNeedsForcedCommit(); state.setNeedsForcedCommit();
state.didLoseContext(); state.didLoseOutputSurface();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
} }

@ -5,7 +5,7 @@
#include "cc/scoped_resource.h" #include "cc/scoped_resource.h"
#include "cc/renderer.h" #include "cc/renderer.h"
#include "cc/test/fake_graphics_context.h" #include "cc/test/fake_output_surface.h"
#include "cc/test/tiled_layer_test_common.h" #include "cc/test/tiled_layer_test_common.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
@ -17,7 +17,7 @@ namespace {
TEST(ScopedResourceTest, NewScopedResource) TEST(ScopedResourceTest, NewScopedResource)
{ {
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); scoped_ptr<OutputSurface> context(createFakeOutputSurface());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get()); scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
@ -31,7 +31,7 @@ TEST(ScopedResourceTest, NewScopedResource)
TEST(ScopedResourceTest, CreateScopedResource) TEST(ScopedResourceTest, CreateScopedResource)
{ {
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); scoped_ptr<OutputSurface> context(createFakeOutputSurface());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get()); scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
@ -47,7 +47,7 @@ TEST(ScopedResourceTest, CreateScopedResource)
TEST(ScopedResourceTest, ScopedResourceIsDeleted) TEST(ScopedResourceTest, ScopedResourceIsDeleted)
{ {
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); scoped_ptr<OutputSurface> context(createFakeOutputSurface());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
{ {
@ -74,7 +74,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted)
TEST(ScopedResourceTest, LeakScopedResource) TEST(ScopedResourceTest, LeakScopedResource)
{ {
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); scoped_ptr<OutputSurface> context(createFakeOutputSurface());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get())); scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
{ {

@ -125,7 +125,7 @@ void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
} }
} }
void ScrollbarLayerImpl::didLoseContext() void ScrollbarLayerImpl::didLoseOutputSurface()
{ {
m_backTrackResourceId = 0; m_backTrackResourceId = 0;
m_foreTrackResourceId = 0; m_foreTrackResourceId = 0;

@ -42,7 +42,7 @@ public:
virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
protected: protected:
explicit ScrollbarLayerImpl(int id); explicit ScrollbarLayerImpl(int id);

@ -6,8 +6,8 @@
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "cc/draw_quad.h" #include "cc/draw_quad.h"
#include "cc/graphics_context.h"
#include "cc/layer_tree_host.h" #include "cc/layer_tree_host.h"
#include "cc/output_surface.h"
#include "cc/resource_update_controller.h" #include "cc/resource_update_controller.h"
#include "cc/thread.h" #include "cc/thread.h"
@ -21,7 +21,7 @@ scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost)
SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost)
: Proxy(scoped_ptr<Thread>(NULL)) : Proxy(scoped_ptr<Thread>(NULL))
, m_layerTreeHost(layerTreeHost) , m_layerTreeHost(layerTreeHost)
, m_contextLost(false) , m_outputSurfaceLost(false)
, m_rendererInitialized(false) , m_rendererInitialized(false)
, m_nextFrameIsNewlyCommittedFrame(false) , m_nextFrameIsNewlyCommittedFrame(false)
, m_totalCommitCount(0) , m_totalCommitCount(0)
@ -82,13 +82,13 @@ bool SingleThreadProxy::isStarted() const
return m_layerTreeHostImpl.get(); return m_layerTreeHostImpl.get();
} }
bool SingleThreadProxy::initializeContext() bool SingleThreadProxy::initializeOutputSurface()
{ {
DCHECK(Proxy::isMainThread()); DCHECK(Proxy::isMainThread());
scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurface();
if (!context.get()) if (!outputSurface.get())
return false; return false;
m_contextBeforeInitialization = context.Pass(); m_outputSurfaceBeforeInitialization = outputSurface.Pass();
return true; return true;
} }
@ -106,10 +106,10 @@ void SingleThreadProxy::setVisible(bool visible)
bool SingleThreadProxy::initializeRenderer() bool SingleThreadProxy::initializeRenderer()
{ {
DCHECK(Proxy::isMainThread()); DCHECK(Proxy::isMainThread());
DCHECK(m_contextBeforeInitialization.get()); DCHECK(m_outputSurfaceBeforeInitialization.get());
{ {
DebugScopedSetImplThread impl(this); DebugScopedSetImplThread impl(this);
bool ok = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitialization.Pass()); bool ok = m_layerTreeHostImpl->initializeRenderer(m_outputSurfaceBeforeInitialization.Pass());
if (ok) { if (ok) {
m_rendererInitialized = true; m_rendererInitialized = true;
m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities(); m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities();
@ -119,14 +119,14 @@ bool SingleThreadProxy::initializeRenderer()
} }
} }
bool SingleThreadProxy::recreateContext() bool SingleThreadProxy::recreateOutputSurface()
{ {
TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext"); TRACE_EVENT0("cc", "SingleThreadProxy::recreateContext");
DCHECK(Proxy::isMainThread()); DCHECK(Proxy::isMainThread());
DCHECK(m_contextLost); DCHECK(m_outputSurfaceLost);
scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurface();
if (!context.get()) if (!outputSurface.get())
return false; return false;
bool initialized; bool initialized;
@ -135,14 +135,14 @@ bool SingleThreadProxy::recreateContext()
DebugScopedSetImplThread impl(this); DebugScopedSetImplThread impl(this);
if (!m_layerTreeHostImpl->contentsTexturesPurged()) if (!m_layerTreeHostImpl->contentsTexturesPurged())
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
initialized = m_layerTreeHostImpl->initializeRenderer(context.Pass()); initialized = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
if (initialized) { if (initialized) {
m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities(); m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities();
} }
} }
if (initialized) if (initialized)
m_contextLost = false; m_outputSurfaceLost = false;
return initialized; return initialized;
} }
@ -161,11 +161,11 @@ const RendererCapabilities& SingleThreadProxy::rendererCapabilities() const
return m_RendererCapabilitiesForMainThread; return m_RendererCapabilitiesForMainThread;
} }
void SingleThreadProxy::loseContext() void SingleThreadProxy::loseOutputSurface()
{ {
DCHECK(Proxy::isMainThread()); DCHECK(Proxy::isMainThread());
m_layerTreeHost->didLoseContext(); m_layerTreeHost->didLoseOutputSurface();
m_contextLost = true; m_outputSurfaceLost = true;
} }
void SingleThreadProxy::setNeedsAnimate() void SingleThreadProxy::setNeedsAnimate()
@ -359,7 +359,7 @@ bool SingleThreadProxy::commitAndComposite()
bool SingleThreadProxy::doComposite() bool SingleThreadProxy::doComposite()
{ {
DCHECK(!m_contextLost); DCHECK(!m_outputSurfaceLost);
{ {
DebugScopedSetImplThread impl(this); DebugScopedSetImplThread impl(this);
@ -384,8 +384,8 @@ bool SingleThreadProxy::doComposite()
} }
if (m_layerTreeHostImpl->isContextLost()) { if (m_layerTreeHostImpl->isContextLost()) {
m_contextLost = true; m_outputSurfaceLost = true;
m_layerTreeHost->didLoseContext(); m_layerTreeHost->didLoseOutputSurface();
return false; return false;
} }

@ -26,14 +26,14 @@ public:
virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE; virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE; virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE; virtual bool initializeOutputSurface() OVERRIDE;
virtual void setSurfaceReady() OVERRIDE; virtual void setSurfaceReady() OVERRIDE;
virtual void setVisible(bool) OVERRIDE; virtual void setVisible(bool) OVERRIDE;
virtual bool initializeRenderer() OVERRIDE; virtual bool initializeRenderer() OVERRIDE;
virtual bool recreateContext() OVERRIDE; virtual bool recreateOutputSurface() OVERRIDE;
virtual void renderingStats(RenderingStats*) OVERRIDE; virtual void renderingStats(RenderingStats*) OVERRIDE;
virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE;
virtual void loseContext() OVERRIDE; virtual void loseOutputSurface() OVERRIDE;
virtual void setNeedsAnimate() OVERRIDE; virtual void setNeedsAnimate() OVERRIDE;
virtual void setNeedsCommit() OVERRIDE; virtual void setNeedsCommit() OVERRIDE;
virtual void setNeedsRedraw() OVERRIDE; virtual void setNeedsRedraw() OVERRIDE;
@ -47,7 +47,7 @@ public:
virtual void forceSerializeOnSwapBuffers() OVERRIDE; virtual void forceSerializeOnSwapBuffers() OVERRIDE;
// LayerTreeHostImplClient implementation // LayerTreeHostImplClient implementation
virtual void didLoseContextOnImplThread() OVERRIDE { } virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE;
virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE { } virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE { }
virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { } virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { }
@ -71,11 +71,11 @@ private:
// Accessed on main thread only. // Accessed on main thread only.
LayerTreeHost* m_layerTreeHost; LayerTreeHost* m_layerTreeHost;
bool m_contextLost; bool m_outputSurfaceLost;
// Holds on to the context between initializeContext() and initializeRenderer() calls. Shouldn't // Holds on to the context between initializeContext() and initializeRenderer() calls. Shouldn't
// be used for anything else. // be used for anything else.
scoped_ptr<GraphicsContext> m_contextBeforeInitialization; scoped_ptr<OutputSurface> m_outputSurfaceBeforeInitialization;
// Used on the Thread, but checked on main thread during initialization/shutdown. // Used on the Thread, but checked on main thread during initialization/shutdown.
scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl; scoped_ptr<LayerTreeHostImpl> m_layerTreeHostImpl;

@ -71,7 +71,6 @@ SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res
m_capabilities.maxTextureSize = INT_MAX; m_capabilities.maxTextureSize = INT_MAX;
m_capabilities.bestTextureFormat = GL_RGBA; m_capabilities.bestTextureFormat = GL_RGBA;
m_capabilities.contextHasCachedFrontBuffer = true;
m_capabilities.usingSetVisibility = true; m_capabilities.usingSetVisibility = true;
// The updater can access bitmaps while the SoftwareRenderer is using them. // The updater can access bitmaps while the SoftwareRenderer is using them.
m_capabilities.allowPartialTextureUpdates = true; m_capabilities.allowPartialTextureUpdates = true;

@ -40,7 +40,7 @@ public:
// RendererClient implementation. // RendererClient implementation.
virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_viewportSize; } virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_viewportSize; }
virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settings; } virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settings; }
virtual void didLoseContext() OVERRIDE { } virtual void didLoseOutputSurface() OVERRIDE { }
virtual void onSwapBuffersComplete() OVERRIDE { } virtual void onSwapBuffersComplete() OVERRIDE { }
virtual void setFullRootLayerDamage() OVERRIDE { } virtual void setFullRootLayerDamage() OVERRIDE { }
virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { }; virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE { };

@ -1,22 +0,0 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TEST_FAKE_GRAPHICS_CONTEXT_H_
#define CC_TEST_FAKE_GRAPHICS_CONTEXT_H_
#include "cc/graphics_context.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include <public/WebCompositorOutputSurface.h>
namespace WebKit {
static inline scoped_ptr<cc::GraphicsContext> createFakeGraphicsContext()
{
return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::GraphicsContext>();
}
} // namespace WebKit
#endif // CC_TEST_FAKE_GRAPHICS_CONTEXT_H_

@ -0,0 +1,22 @@
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_
#define CC_TEST_FAKE_OUTPUT_SURFACE_H_
#include "cc/output_surface.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include <public/WebCompositorOutputSurface.h>
namespace cc {
static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface()
{
return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>();
}
} // namespace WebKit
#endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_

@ -16,7 +16,7 @@ bool FakeProxy::isStarted() const
return true; return true;
} }
bool FakeProxy::initializeContext() bool FakeProxy::initializeOutputSurface()
{ {
return true; return true;
} }
@ -26,7 +26,7 @@ bool FakeProxy::initializeRenderer()
return true; return true;
} }
bool FakeProxy::recreateContext() bool FakeProxy::recreateOutputSurface()
{ {
return true; return true;
} }

@ -19,11 +19,11 @@ public:
virtual void startPageScaleAnimation(gfx::Vector2d targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE { } virtual void startPageScaleAnimation(gfx::Vector2d targetPosition, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE { }
virtual void finishAllRendering() OVERRIDE { } virtual void finishAllRendering() OVERRIDE { }
virtual bool isStarted() const OVERRIDE; virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE; virtual bool initializeOutputSurface() OVERRIDE;
virtual void setSurfaceReady() OVERRIDE { } virtual void setSurfaceReady() OVERRIDE { }
virtual void setVisible(bool) OVERRIDE { } virtual void setVisible(bool) OVERRIDE { }
virtual bool initializeRenderer() OVERRIDE; virtual bool initializeRenderer() OVERRIDE;
virtual bool recreateContext() OVERRIDE; virtual bool recreateOutputSurface() OVERRIDE;
virtual void renderingStats(RenderingStats*) OVERRIDE { } virtual void renderingStats(RenderingStats*) OVERRIDE { }
virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE;
virtual void setNeedsAnimate() OVERRIDE { } virtual void setNeedsAnimate() OVERRIDE { }
@ -37,7 +37,7 @@ public:
virtual void forceSerializeOnSwapBuffers() OVERRIDE { } virtual void forceSerializeOnSwapBuffers() OVERRIDE { }
virtual size_t maxPartialTextureUpdates() const OVERRIDE; virtual size_t maxPartialTextureUpdates() const OVERRIDE;
virtual void acquireLayerTextures() OVERRIDE { } virtual void acquireLayerTextures() OVERRIDE { }
virtual void loseContext() OVERRIDE { } virtual void loseOutputSurface() OVERRIDE { }
virtual RendererCapabilities& rendererCapabilities(); virtual RendererCapabilities& rendererCapabilities();
void setMaxPartialTextureUpdates(size_t); void setMaxPartialTextureUpdates(size_t);

@ -0,0 +1,31 @@
// Copyright 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
class ContextThatCountsMakeCurrents : public WebKit::FakeWebGraphicsContext3D {
public:
ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { }
virtual bool makeContextCurrent() OVERRIDE
{
m_makeCurrentCount++;
return true;
}
int makeCurrentCount() const { return m_makeCurrentCount; }
private:
int m_makeCurrentCount;
};
TEST(FakeWebGraphicsContext3DTest, CreationShouldNotMakeCurrent)
{
scoped_ptr<ContextThatCountsMakeCurrents> context(new ContextThatCountsMakeCurrents);
EXPECT_TRUE(context.get());
EXPECT_EQ(0, context->makeCurrentCount());
}

@ -4,10 +4,11 @@
#include "cc/texture_layer.h" #include "cc/texture_layer.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "cc/layer_tree_host.h" #include "cc/layer_tree_host.h"
#include "cc/texture_layer_client.h" #include "cc/texture_layer_client.h"
#include "cc/texture_layer_impl.h" #include "cc/texture_layer_impl.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
namespace cc { namespace cc {

@ -67,7 +67,7 @@ void TextureLayerImpl::dumpLayerProperties(std::string* str, int indent) const
LayerImpl::dumpLayerProperties(str, indent); LayerImpl::dumpLayerProperties(str, indent);
} }
void TextureLayerImpl::didLoseContext() void TextureLayerImpl::didLoseOutputSurface()
{ {
m_textureId = 0; m_textureId = 0;
m_externalTextureResource = 0; m_externalTextureResource = 0;

@ -22,7 +22,7 @@ public:
virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
virtual void didDraw(ResourceProvider*) OVERRIDE; virtual void didDraw(ResourceProvider*) OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE; virtual void dumpLayerProperties(std::string*, int indent) const OVERRIDE;

@ -9,9 +9,9 @@
#include "cc/delay_based_time_source.h" #include "cc/delay_based_time_source.h"
#include "cc/draw_quad.h" #include "cc/draw_quad.h"
#include "cc/frame_rate_controller.h" #include "cc/frame_rate_controller.h"
#include "cc/graphics_context.h"
#include "cc/input_handler.h" #include "cc/input_handler.h"
#include "cc/layer_tree_host.h" #include "cc/layer_tree_host.h"
#include "cc/output_surface.h"
#include "cc/scheduler.h" #include "cc/scheduler.h"
#include "cc/scoped_thread_proxy.h" #include "cc/scoped_thread_proxy.h"
#include "cc/thread.h" #include "cc/thread.h"
@ -147,14 +147,14 @@ bool ThreadProxy::isStarted() const
return m_started; return m_started;
} }
bool ThreadProxy::initializeContext() bool ThreadProxy::initializeOutputSurface()
{ {
TRACE_EVENT0("cc", "ThreadProxy::initializeContext"); TRACE_EVENT0("cc", "ThreadProxy::initializeOutputSurface");
scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); scoped_ptr<OutputSurface> context = m_layerTreeHost->createOutputSurface();
if (!context.get()) if (!context.get())
return false; return false;
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeContextOnImplThread, base::Unretained(this), base::Passed(context.Pass()))); Proxy::implThread()->postTask(base::Bind(&ThreadProxy::initializeOutputSurfaceOnImplThread, base::Unretained(this), base::Passed(context.Pass())));
return true; return true;
} }
@ -210,30 +210,30 @@ bool ThreadProxy::initializeRenderer()
return initializeSucceeded; return initializeSucceeded;
} }
bool ThreadProxy::recreateContext() bool ThreadProxy::recreateOutputSurface()
{ {
TRACE_EVENT0("cc", "ThreadProxy::recreateContext"); TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurface");
DCHECK(isMainThread()); DCHECK(isMainThread());
// Try to create the context. // Try to create the surface.
scoped_ptr<GraphicsContext> context = m_layerTreeHost->createContext(); scoped_ptr<OutputSurface> outputSurface = m_layerTreeHost->createOutputSurface();
if (!context.get()) if (!outputSurface.get())
return false; return false;
if (m_layerTreeHost->needsSharedContext()) if (m_layerTreeHost->needsSharedContext())
if (!WebSharedGraphicsContext3D::createCompositorThreadContext()) if (!WebSharedGraphicsContext3D::createCompositorThreadContext())
return false; return false;
// Make a blocking call to recreateContextOnImplThread. The results of that // Make a blocking call to recreateOutputSurfaceOnImplThread. The results of that
// call are pushed into the recreateSucceeded and capabilities local // call are pushed into the recreateSucceeded and capabilities local
// variables. // variables.
CompletionEvent completion; CompletionEvent completion;
bool recreateSucceeded = false; bool recreateSucceeded = false;
RendererCapabilities capabilities; RendererCapabilities capabilities;
DebugScopedSetMainThreadBlocked mainThreadBlocked(this); DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateContextOnImplThread, Proxy::implThread()->postTask(base::Bind(&ThreadProxy::recreateOutputSurfaceOnImplThread,
base::Unretained(this), base::Unretained(this),
&completion, &completion,
base::Passed(context.Pass()), base::Passed(outputSurface.Pass()),
&recreateSucceeded, &recreateSucceeded,
&capabilities)); &capabilities));
completion.wait(); completion.wait();
@ -263,9 +263,9 @@ const RendererCapabilities& ThreadProxy::rendererCapabilities() const
return m_RendererCapabilitiesMainThreadCopy; return m_RendererCapabilitiesMainThreadCopy;
} }
void ThreadProxy::loseContext() void ThreadProxy::loseOutputSurface()
{ {
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseContextOnImplThread, base::Unretained(this))); Proxy::implThread()->postTask(base::Bind(&ThreadProxy::didLoseOutputSurfaceOnImplThread, base::Unretained(this)));
} }
void ThreadProxy::setNeedsAnimate() void ThreadProxy::setNeedsAnimate()
@ -297,11 +297,11 @@ void ThreadProxy::setNeedsCommit()
Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplThread, base::Unretained(this))); Proxy::implThread()->postTask(base::Bind(&ThreadProxy::setNeedsCommitOnImplThread, base::Unretained(this)));
} }
void ThreadProxy::didLoseContextOnImplThread() void ThreadProxy::didLoseOutputSurfaceOnImplThread()
{ {
DCHECK(isImplThread()); DCHECK(isImplThread());
TRACE_EVENT0("cc", "ThreadProxy::didLoseContextOnImplThread"); TRACE_EVENT0("cc", "ThreadProxy::didLoseOutputSurfaceOnImplThread");
m_schedulerOnImplThread->didLoseContext(); m_schedulerOnImplThread->didLoseOutputSurface();
} }
void ThreadProxy::onSwapBuffersCompleteOnImplThread() void ThreadProxy::onSwapBuffersCompleteOnImplThread()
@ -869,20 +869,20 @@ void ThreadProxy::beginContextRecreation()
{ {
TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation"); TRACE_EVENT0("cc", "ThreadProxy::beginContextRecreation");
DCHECK(isMainThread()); DCHECK(isMainThread());
m_layerTreeHost->didLoseContext(); m_layerTreeHost->didLoseOutputSurface();
m_contextRecreationCallback.Reset(base::Bind(&ThreadProxy::tryToRecreateContext, base::Unretained(this))); m_outputSurfaceRecreationCallback.Reset(base::Bind(&ThreadProxy::tryToRecreateOutputSurface, base::Unretained(this)));
Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); Proxy::mainThread()->postTask(m_outputSurfaceRecreationCallback.callback());
} }
void ThreadProxy::tryToRecreateContext() void ThreadProxy::tryToRecreateOutputSurface()
{ {
DCHECK(isMainThread()); DCHECK(isMainThread());
DCHECK(m_layerTreeHost); DCHECK(m_layerTreeHost);
LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext(); LayerTreeHost::RecreateResult result = m_layerTreeHost->recreateOutputSurface();
if (result == LayerTreeHost::RecreateFailedButTryAgain) if (result == LayerTreeHost::RecreateFailedButTryAgain)
Proxy::mainThread()->postTask(m_contextRecreationCallback.callback()); Proxy::mainThread()->postTask(m_outputSurfaceRecreationCallback.callback());
else if (result == LayerTreeHost::RecreateSucceeded) else if (result == LayerTreeHost::RecreateSucceeded)
m_contextRecreationCallback.Cancel(); m_outputSurfaceRecreationCallback.Cancel();
} }
void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputHandler* handler) void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputHandler* handler)
@ -906,19 +906,19 @@ void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
completion->signal(); completion->signal();
} }
void ThreadProxy::initializeContextOnImplThread(scoped_ptr<GraphicsContext> context) void ThreadProxy::initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface> outputSurface)
{ {
TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread"); TRACE_EVENT0("cc", "ThreadProxy::initializeContextOnImplThread");
DCHECK(isImplThread()); DCHECK(isImplThread());
m_contextBeforeInitializationOnImplThread = context.Pass(); m_outputSurfaceBeforeInitializationOnImplThread = outputSurface.Pass();
} }
void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bool* initializeSucceeded, RendererCapabilities* capabilities) void ThreadProxy::initializeRendererOnImplThread(CompletionEvent* completion, bool* initializeSucceeded, RendererCapabilities* capabilities)
{ {
TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread"); TRACE_EVENT0("cc", "ThreadProxy::initializeRendererOnImplThread");
DCHECK(isImplThread()); DCHECK(isImplThread());
DCHECK(m_contextBeforeInitializationOnImplThread.get()); DCHECK(m_outputSurfaceBeforeInitializationOnImplThread.get());
*initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_contextBeforeInitializationOnImplThread.Pass()); *initializeSucceeded = m_layerTreeHostImpl->initializeRenderer(m_outputSurfaceBeforeInitializationOnImplThread.Pass());
if (*initializeSucceeded) { if (*initializeSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities(); *capabilities = m_layerTreeHostImpl->rendererCapabilities();
m_schedulerOnImplThread->setSwapBuffersCompleteSupported( m_schedulerOnImplThread->setSwapBuffersCompleteSupported(
@ -950,15 +950,15 @@ size_t ThreadProxy::maxPartialTextureUpdates() const
return ResourceUpdateController::maxPartialTextureUpdates(); return ResourceUpdateController::maxPartialTextureUpdates();
} }
void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, scoped_ptr<GraphicsContext> context, bool* recreateSucceeded, RendererCapabilities* capabilities) void ThreadProxy::recreateOutputSurfaceOnImplThread(CompletionEvent* completion, scoped_ptr<OutputSurface> outputSurface, bool* recreateSucceeded, RendererCapabilities* capabilities)
{ {
TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); TRACE_EVENT0("cc", "ThreadProxy::recreateOutputSurfaceOnImplThread");
DCHECK(isImplThread()); DCHECK(isImplThread());
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
*recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(context.Pass()); *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
if (*recreateSucceeded) { if (*recreateSucceeded) {
*capabilities = m_layerTreeHostImpl->rendererCapabilities(); *capabilities = m_layerTreeHostImpl->rendererCapabilities();
m_schedulerOnImplThread->didRecreateContext(); m_schedulerOnImplThread->didRecreateOutputSurface();
} }
completion->signal(); completion->signal();
} }

@ -34,14 +34,14 @@ public:
virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE; virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, float scale, base::TimeDelta duration) OVERRIDE;
virtual void finishAllRendering() OVERRIDE; virtual void finishAllRendering() OVERRIDE;
virtual bool isStarted() const OVERRIDE; virtual bool isStarted() const OVERRIDE;
virtual bool initializeContext() OVERRIDE; virtual bool initializeOutputSurface() OVERRIDE;
virtual void setSurfaceReady() OVERRIDE; virtual void setSurfaceReady() OVERRIDE;
virtual void setVisible(bool) OVERRIDE; virtual void setVisible(bool) OVERRIDE;
virtual bool initializeRenderer() OVERRIDE; virtual bool initializeRenderer() OVERRIDE;
virtual bool recreateContext() OVERRIDE; virtual bool recreateOutputSurface() OVERRIDE;
virtual void renderingStats(RenderingStats*) OVERRIDE; virtual void renderingStats(RenderingStats*) OVERRIDE;
virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE; virtual const RendererCapabilities& rendererCapabilities() const OVERRIDE;
virtual void loseContext() OVERRIDE; virtual void loseOutputSurface() OVERRIDE;
virtual void setNeedsAnimate() OVERRIDE; virtual void setNeedsAnimate() OVERRIDE;
virtual void setNeedsCommit() OVERRIDE; virtual void setNeedsCommit() OVERRIDE;
virtual void setNeedsRedraw() OVERRIDE; virtual void setNeedsRedraw() OVERRIDE;
@ -55,7 +55,7 @@ public:
virtual void forceSerializeOnSwapBuffers() OVERRIDE; virtual void forceSerializeOnSwapBuffers() OVERRIDE;
// LayerTreeHostImplClient implementation // LayerTreeHostImplClient implementation
virtual void didLoseContextOnImplThread() OVERRIDE; virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE;
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE; virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE;
virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE; virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE;
virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE; virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE;
@ -97,7 +97,7 @@ private:
void didCompleteSwapBuffers(); void didCompleteSwapBuffers();
void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime); void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallClockTime);
void beginContextRecreation(); void beginContextRecreation();
void tryToRecreateContext(); void tryToRecreateOutputSurface();
// Called on impl thread // Called on impl thread
struct ReadbackRequest { struct ReadbackRequest {
@ -115,13 +115,13 @@ private:
void initializeImplOnImplThread(CompletionEvent*, InputHandler*); void initializeImplOnImplThread(CompletionEvent*, InputHandler*);
void setSurfaceReadyOnImplThread(); void setSurfaceReadyOnImplThread();
void setVisibleOnImplThread(CompletionEvent*, bool); void setVisibleOnImplThread(CompletionEvent*, bool);
void initializeContextOnImplThread(scoped_ptr<GraphicsContext>); void initializeOutputSurfaceOnImplThread(scoped_ptr<OutputSurface>);
void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSucceeded, RendererCapabilities*); void initializeRendererOnImplThread(CompletionEvent*, bool* initializeSucceeded, RendererCapabilities*);
void layerTreeHostClosedOnImplThread(CompletionEvent*); void layerTreeHostClosedOnImplThread(CompletionEvent*);
void manageTilesOnImplThread(); void manageTilesOnImplThread();
void setFullRootLayerDamageOnImplThread(); void setFullRootLayerDamageOnImplThread();
void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*); void acquireLayerTexturesForMainThreadOnImplThread(CompletionEvent*);
void recreateContextOnImplThread(CompletionEvent*, scoped_ptr<GraphicsContext>, bool* recreateSucceeded, RendererCapabilities*); void recreateOutputSurfaceOnImplThread(CompletionEvent*, scoped_ptr<OutputSurface>, bool* recreateSucceeded, RendererCapabilities*);
void renderingStatsOnImplThread(CompletionEvent*, RenderingStats*); void renderingStatsOnImplThread(CompletionEvent*, RenderingStats*);
ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool forcedDraw); ScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapInternal(bool forcedDraw);
void forceSerializeOnSwapBuffersOnImplThread(CompletionEvent*); void forceSerializeOnSwapBuffersOnImplThread(CompletionEvent*);
@ -131,7 +131,7 @@ private:
bool m_animateRequested; // Set only when setNeedsAnimate is called. bool m_animateRequested; // Set only when setNeedsAnimate is called.
bool m_commitRequested; // Set only when setNeedsCommit is called. bool m_commitRequested; // Set only when setNeedsCommit is called.
bool m_commitRequestSentToImplThread; // Set by setNeedsCommit and setNeedsAnimate. bool m_commitRequestSentToImplThread; // Set by setNeedsCommit and setNeedsAnimate.
base::CancelableClosure m_contextRecreationCallback; base::CancelableClosure m_outputSurfaceRecreationCallback;
LayerTreeHost* m_layerTreeHost; LayerTreeHost* m_layerTreeHost;
bool m_rendererInitialized; bool m_rendererInitialized;
RendererCapabilities m_RendererCapabilitiesMainThreadCopy; RendererCapabilities m_RendererCapabilitiesMainThreadCopy;
@ -150,7 +150,7 @@ private:
// Holds on to the context we might use for compositing in between initializeContext() // Holds on to the context we might use for compositing in between initializeContext()
// and initializeRenderer() calls. // and initializeRenderer() calls.
scoped_ptr<GraphicsContext> m_contextBeforeInitializationOnImplThread; scoped_ptr<OutputSurface> m_outputSurfaceBeforeInitializationOnImplThread;
// Set when the main thread is waiting on a scheduledActionBeginFrame to be issued. // Set when the main thread is waiting on a scheduledActionBeginFrame to be issued.
CompletionEvent* m_beginFrameCompletionEventOnImplThread; CompletionEvent* m_beginFrameCompletionEventOnImplThread;

@ -236,7 +236,7 @@ Region TiledLayerImpl::visibleContentOpaqueRegion() const
return m_tiler->opaqueRegionInContentRect(visibleContentRect()); return m_tiler->opaqueRegionInContentRect(visibleContentRect());
} }
void TiledLayerImpl::didLoseContext() void TiledLayerImpl::didLoseOutputSurface()
{ {
m_tiler->reset(); m_tiler->reset();
} }

@ -33,7 +33,7 @@ public:
void pushInvalidTile(int, int); void pushInvalidTile(int, int);
virtual Region visibleContentOpaqueRegion() const OVERRIDE; virtual Region visibleContentOpaqueRegion() const OVERRIDE;
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
protected: protected:
explicit TiledLayerImpl(int id); explicit TiledLayerImpl(int id);

@ -11,8 +11,8 @@
#include "cc/resource_update_controller.h" #include "cc/resource_update_controller.h"
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
#include "cc/test/animation_test_common.h" #include "cc/test/animation_test_common.h"
#include "cc/test/fake_graphics_context.h"
#include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h" #include "cc/test/fake_proxy.h"
#include "cc/test/geometry_test_utils.h" #include "cc/test/geometry_test_utils.h"
#include "cc/test/tiled_layer_test_common.h" #include "cc/test/tiled_layer_test_common.h"
@ -48,7 +48,7 @@ class TiledLayerTest : public testing::Test {
public: public:
TiledLayerTest() TiledLayerTest()
: m_proxy(NULL) : m_proxy(NULL)
, m_context(WebKit::createFakeGraphicsContext()) , m_outputSurface(createFakeOutputSurface())
, m_queue(make_scoped_ptr(new ResourceUpdateQueue)) , m_queue(make_scoped_ptr(new ResourceUpdateQueue))
, m_occlusion(0) , m_occlusion(0)
{ {
@ -61,7 +61,7 @@ public:
m_resourceManager = PrioritizedResourceManager::create(Renderer::ContentPool, m_proxy); m_resourceManager = PrioritizedResourceManager::create(Renderer::ContentPool, m_proxy);
m_layerTreeHost->initializeRendererIfNeeded(); m_layerTreeHost->initializeRendererIfNeeded();
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy); DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
m_resourceProvider = ResourceProvider::create(m_context.get()); m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
} }
virtual ~TiledLayerTest() virtual ~TiledLayerTest()
@ -164,7 +164,7 @@ public:
public: public:
Proxy* m_proxy; Proxy* m_proxy;
LayerTreeSettings m_settings; LayerTreeSettings m_settings;
scoped_ptr<GraphicsContext> m_context; scoped_ptr<OutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider; scoped_ptr<ResourceProvider> m_resourceProvider;
scoped_ptr<ResourceUpdateQueue> m_queue; scoped_ptr<ResourceUpdateQueue> m_queue;
RenderingStats m_stats; RenderingStats m_stats;

@ -410,7 +410,7 @@ void VideoLayerImpl::didUpdateMatrix(const float matrix[16])
setNeedsRedraw(); setNeedsRedraw();
} }
void VideoLayerImpl::didLoseContext() void VideoLayerImpl::didLoseOutputSurface()
{ {
freePlaneData(layerTreeHostImpl()->resourceProvider()); freePlaneData(layerTreeHostImpl()->resourceProvider());
} }

@ -50,7 +50,7 @@ public:
virtual void didReceiveFrame(); // Callable on impl thread. virtual void didReceiveFrame(); // Callable on impl thread.
virtual void didUpdateMatrix(const float*); // Callable on impl thread. virtual void didUpdateMatrix(const float*); // Callable on impl thread.
virtual void didLoseContext() OVERRIDE; virtual void didLoseOutputSurface() OVERRIDE;
void setNeedsRedraw(); void setNeedsRedraw();

@ -208,7 +208,7 @@ scoped_ptr<FontAtlas> WebLayerTreeViewImpl::createFontAtlas()
void WebLayerTreeViewImpl::loseCompositorContext(int numTimes) void WebLayerTreeViewImpl::loseCompositorContext(int numTimes)
{ {
m_layerTreeHost->loseContext(numTimes); m_layerTreeHost->loseOutputSurface(numTimes);
} }
void WebLayerTreeViewImpl::willBeginFrame() void WebLayerTreeViewImpl::willBeginFrame()