0

cc: Move WebCompositorOutputSurface and related classes into cc/

This moves:
- WebKit::WebCompositorOutputSurface to cc::OutputSurface
- WebKit::WebCompositorOutputSurfaceClient to cc::OutputSurfaceClient
- Webkit::WebCompositorSoftwareOutputDevice to cc::SoftwareOutputDevice

They become new files in cc/ so they are chromified style. This affects
the various call-sites. This allows us to pass cc::CompositorFrame
directly, without any need for WebCompositorFrame.

BUG=146080
Depends on: https://bugs.webkit.org/show_bug.cgi?id=103967

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171847 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
danakj@chromium.org
2012-12-07 21:43:16 +00:00
parent f850763f96
commit a46f329337
62 changed files with 755 additions and 442 deletions
cc
content
ui/compositor
webkit/compositor_bindings

@ -7,6 +7,8 @@ include_rules = [
"+ui/gfx",
"+ui/gl",
# TODO(danakj): Drop dependencies on WebKit Platform API from cc.
"+third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h",
"+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h",
"+third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAllocation.h",
"+third_party/WebKit/Source/Platform/chromium/public/WebImage.h",
]

@ -8,8 +8,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using namespace WebKitTests;
namespace cc {
namespace {

@ -118,6 +118,7 @@
'occlusion_tracker.cc',
'occlusion_tracker.h',
'output_surface.h',
'output_surface_client.h',
'overdraw_metrics.cc',
'overdraw_metrics.h',
'page_scale_animation.cc',
@ -212,6 +213,7 @@
'single_thread_proxy.h',
'skpicture_content_layer_updater.cc',
'skpicture_content_layer_updater.h',
'software_output_device.h',
'software_renderer.cc',
'software_renderer.h',
'solid_color_draw_quad.cc',

@ -79,8 +79,10 @@
'test/fake_proxy.cc',
'test/fake_proxy.h',
'test/fake_tile_manager_client.h',
'test/fake_web_compositor_output_surface.h',
'test/fake_web_compositor_software_output_device.h',
'test/fake_output_surface.cc',
'test/fake_output_surface.h',
'test/fake_software_output_device.cc',
'test/fake_software_output_device.h',
'test/fake_web_graphics_context_3d.h',
'test/fake_web_scrollbar_theme_geometry.h',
'test/geometry_test_utils.cc',

@ -15,7 +15,6 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/mock_quad_culler.h"
@ -23,7 +22,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/transform.h"
using WebKit::FakeWebCompositorOutputSurface;
using WebKit::FakeWebGraphicsContext3D;
using namespace WebKitTests;

@ -9,7 +9,7 @@
#include "cc/resource_provider.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/render_pass_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
@ -123,7 +123,7 @@ protected:
GLRendererTest()
: m_suggestHaveBackbufferYes(1, true)
, m_suggestHaveBackbufferNo(1, false)
, m_context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext())))
, m_context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FrameCountingMemoryAllocationSettingContext())))
, m_resourceProvider(ResourceProvider::create(m_context.get()))
, m_renderer(&m_mockClient, m_resourceProvider.get())
{
@ -139,7 +139,7 @@ protected:
m_renderer.swapBuffers();
}
FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); }
FrameCountingMemoryAllocationSettingContext* context() { return static_cast<FrameCountingMemoryAllocationSettingContext*>(m_context->Context3D()); }
WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes;
WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo;
@ -305,7 +305,7 @@ public:
TEST(GLRendererTest2, initializationDoesNotMakeSynchronousCalls)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext)));
scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ForbidSynchronousCallContext)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -348,7 +348,7 @@ private:
TEST(GLRendererTest2, initializationWithQuicklyLostContextDoesNotAssert)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> context(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext)));
scoped_ptr<OutputSurface> context(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new LoseContextOnFirstGetContext)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -370,7 +370,7 @@ public:
TEST(GLRendererTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -397,8 +397,8 @@ private:
TEST(GLRendererTest2, opaqueBackground)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -420,8 +420,8 @@ TEST(GLRendererTest2, opaqueBackground)
TEST(GLRendererTest2, transparentBackground)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ClearCountingContext)));
ClearCountingContext* context = static_cast<ClearCountingContext*>(outputSurface->Context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -471,8 +471,8 @@ private:
TEST(GLRendererTest2, visibilityChangeIsLastCall)
{
FakeRendererClient mockClient;
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext)));
VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new VisibilityChangeIsLastCallTrackingContext)));
VisibilityChangeIsLastCallTrackingContext* context = static_cast<VisibilityChangeIsLastCallTrackingContext*>(outputSurface->Context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&mockClient, resourceProvider.get());
@ -523,8 +523,8 @@ private:
TEST(GLRendererTest2, activeTextureState)
{
FakeRendererClient fakeClient;
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TextureStateTrackingContext)));
TextureStateTrackingContext* context = static_cast<TextureStateTrackingContext*>(outputSurface->Context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
FakeRendererGL renderer(&fakeClient, resourceProvider.get());

@ -7,8 +7,6 @@
#include "cc/layer_tree_host.h"
#include "cc/test/layer_tree_test_common.h"
using namespace WebKitTests;
namespace cc {
namespace {

@ -31,7 +31,7 @@ IOSurfaceLayerImpl::~IOSurfaceLayerImpl()
OutputSurface* outputSurface = layerTreeHostImpl()->outputSurface();
// FIXME: Implement this path for software compositing.
WebKit::WebGraphicsContext3D* context3d = outputSurface->context3D();
WebKit::WebGraphicsContext3D* context3d = outputSurface->Context3D();
if (context3d)
context3d->deleteTexture(m_ioSurfaceTextureId);
}

@ -11,8 +11,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/transform.h"
using namespace WebKitTests;
namespace cc {
namespace {

@ -11,13 +11,10 @@ namespace gfx {
class Vector2d;
}
namespace WebKit {
class WebCompositorOutputSurface;
}
namespace cc {
class FontAtlas;
class InputHandler;
class OutputSurface;
class LayerTreeHostClient {
public:
@ -27,7 +24,7 @@ public:
virtual void animate(double frameBeginTime) = 0;
virtual void layout() = 0;
virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) = 0;
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() = 0;
virtual scoped_ptr<OutputSurface> createOutputSurface() = 0;
virtual void didRecreateOutputSurface(bool success) = 0;
virtual scoped_ptr<InputHandler> createInputHandler() = 0;
virtual void willCommit() = 0;

@ -793,16 +793,19 @@ void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy
m_client->setNeedsCommitOnImplThread();
}
void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds)
void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval)
{
base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimebase * base::Time::kMicrosecondsPerSecond);
base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSeconds * base::Time::kMicrosecondsPerSecond);
m_client->onVSyncParametersChanged(timebase, interval);
}
void LayerTreeHostImpl::OnSendFrameToParentCompositorAck(const CompositorFrameAck&)
{
// TODO(danakj): Implement this.
}
void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*)
{
m_client->onCanDrawStateChanged(canDraw());
m_client->onCanDrawStateChanged(canDraw());
}
void LayerTreeHostImpl::drawLayers(FrameData& frame)
@ -958,7 +961,7 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa
m_resourceProvider.reset();
m_outputSurface.reset();
if (!outputSurface->bindToClient(this))
if (!outputSurface->BindToClient(this))
return false;
scoped_ptr<ResourceProvider> resourceProvider = ResourceProvider::create(outputSurface.get());
@ -968,10 +971,10 @@ bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa
if (m_settings.implSidePainting)
m_tileManager.reset(new TileManager(this, resourceProvider.get(), m_settings.numRasterThreads));
if (outputSurface->context3D())
if (outputSurface->Context3D())
m_renderer = GLRenderer::create(this, resourceProvider.get());
else if (outputSurface->softwareDevice())
m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->softwareDevice());
else if (outputSurface->SoftwareDevice())
m_renderer = SoftwareRenderer::create(this, resourceProvider.get(), outputSurface->SoftwareDevice());
if (!m_renderer)
return false;

@ -13,13 +13,13 @@
#include "cc/cc_export.h"
#include "cc/input_handler.h"
#include "cc/layer_tree_impl.h"
#include "cc/output_surface_client.h"
#include "cc/render_pass.h"
#include "cc/render_pass_sink.h"
#include "cc/renderer.h"
#include "cc/tile_manager.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
#include <public/WebCompositorOutputSurfaceClient.h>
namespace cc {
@ -115,7 +115,7 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
public TileManagerClient,
public LayerTreeImplClient,
public AnimationRegistrar,
public NON_EXPORTED_BASE(WebKit::WebCompositorOutputSurfaceClient) {
public OutputSurfaceClient {
typedef std::vector<LayerImpl*> LayerList;
typedef base::hash_set<LayerAnimationController*> AnimationControllerSet;
@ -179,8 +179,9 @@ public:
virtual void ScheduleManageTiles() OVERRIDE;
virtual void ScheduleCheckForCompletedSetPixels() OVERRIDE;
// WebCompositorOutputSurfaceClient implementation.
virtual void onVSyncParametersChanged(double monotonicTimebase, double intervalInSeconds) OVERRIDE;
// OutputSurfaceClient implementation.
virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDelta interval) OVERRIDE;
virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVERRIDE;
// LayerTreeImplClient implementation.
virtual void OnCanDrawStateChangedForTree(LayerTreeImpl*) OVERRIDE;

@ -23,8 +23,8 @@
#include "cc/single_thread_proxy.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_scrollbar_theme_geometry.h"
#include "cc/test/geometry_test_utils.h"
@ -209,7 +209,7 @@ public:
protected:
scoped_ptr<OutputSurface> createOutputSurface()
{
return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>();
return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>();
}
FakeProxy m_proxy;
@ -378,7 +378,7 @@ TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
// Initialization will fail here.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
setupScrollAndContentsLayers(gfx::Size(100, 100));
@ -1999,8 +1999,8 @@ protected:
// viewport size is never set.
TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>();
ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurface>();
ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(outputSurface->Context3D());
m_hostImpl->initializeRenderer(outputSurface.Pass());
scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1);
@ -2042,8 +2042,8 @@ private:
// where it should request to swap only the subBuffer that is damaged.
TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>();
PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<OutputSurface>();
PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(outputSurface->Context3D());
// This test creates its own LayerTreeHostImpl, so
// that we can force partial swap enabled.
@ -2257,8 +2257,8 @@ public:
TEST_P(LayerTreeHostImplTest, noPartialSwap)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D());
MockContextHarness harness(mockContext);
// Run test case
@ -2291,8 +2291,8 @@ TEST_P(LayerTreeHostImplTest, noPartialSwap)
TEST_P(LayerTreeHostImplTest, partialSwap)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3D());
MockContextHarness harness(mockContext);
createLayerTreeHost(true, outputSurface.Pass());
@ -2348,7 +2348,7 @@ public:
static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, LayerTreeHostImplClient* client, Proxy* proxy)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
LayerTreeSettings settings;
settings.partialSwapEnabled = partialSwap;
@ -2504,7 +2504,7 @@ TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost)
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.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<OutputSurface>());
m_hostImpl->finishAllRendering();
}
@ -2542,14 +2542,14 @@ TEST_P(LayerTreeHostImplTest, context3DLostDuringInitialize)
for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitialization; ++i) {
// The context will get lost during initialization, we shouldn't crash. We
// should also be in a consistent state.
EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<OutputSurface>()));
EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(i))).PassAs<OutputSurface>()));
EXPECT_EQ(0, m_hostImpl->outputSurface());
EXPECT_EQ(0, m_hostImpl->renderer());
EXPECT_EQ(0, m_hostImpl->resourceProvider());
EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface()));
}
EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<OutputSurface>()));
EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<OutputSurface>()));
EXPECT_TRUE(m_hostImpl->outputSurface());
EXPECT_TRUE(m_hostImpl->renderer());
EXPECT_TRUE(m_hostImpl->resourceProvider());
@ -2896,7 +2896,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface)
rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>());
// Use a context that supports IOSurfaces
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
FakeVideoFrame hwVideoFrame(
VideoFrame::WrapNativeTexture(
@ -2926,7 +2926,7 @@ TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface)
// Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
// that will warn if any resource from the previous context gets used.
m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<OutputSurface>());
// Create dummy resources so that looking up an old resource will get an
// invalid texture id mapping.
@ -3043,8 +3043,8 @@ TEST_P(LayerTreeHostImplTest, layersFreeTextures)
rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
// Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of).
scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)));
TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)));
TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<TrackingWebGraphicsContext3D*>(outputSurface->Context3D());
m_hostImpl->initializeRenderer(outputSurface.Pass());
m_hostImpl->setRootLayer(rootLayer.Pass());
@ -3071,8 +3071,8 @@ public:
TEST_P(LayerTreeHostImplTest, hasTransparentBackground)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>();
MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->context3D());
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>();
MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(outputSurface->Context3D());
// Run test case
createLayerTreeHost(false, outputSurface.Pass());
@ -3116,7 +3116,7 @@ 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)
{
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
layerTreeHostImpl->setViewportSize(rootSize, rootSize);
@ -3160,7 +3160,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
LayerImpl* rootPtr;
LayerImpl* surfaceLayerPtr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(100, 100);
@ -3271,7 +3271,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000);
@ -3382,7 +3382,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000);
@ -3494,7 +3494,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000);
@ -3575,7 +3575,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
LayerImpl* rootPtr;
LayerImpl* layerS1Ptr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000);
@ -3659,7 +3659,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
LayerImpl* layerS1Ptr;
LayerImpl* layerS2Ptr;
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
gfx::Size rootSize(1000, 1000);
@ -3778,7 +3778,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithScissor)
gfx::Rect childRect(10, 10, 50, 50);
gfx::Rect grandChildRect(5, 5, 150, 150);
scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface>();
myHostImpl->initializeRenderer(outputSurface.Pass());
root->setAnchorPoint(gfx::PointF(0, 0));
@ -4520,7 +4520,7 @@ static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses)
{
scoped_ptr<OutputSurface> outputSurface(createOutputSurface());
ASSERT_TRUE(outputSurface->context3D());
ASSERT_TRUE(outputSurface->Context3D());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get()));
scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(), &m_proxy));

@ -21,7 +21,7 @@ namespace {
static const int kTimeLimitMillis = 2000;
class LayerTreeHostPerfTest : public WebKitTests::ThreadedTest {
class LayerTreeHostPerfTest : public ThreadedTest {
public:
LayerTreeHostPerfTest()
: num_draws_(0) {

@ -13,8 +13,8 @@
#include "cc/single_thread_proxy.h"
#include "cc/test/fake_content_layer_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_web_compositor_output_surface.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_tree_test_common.h"
#include "cc/test/occlusion_tracker_test_common.h"
@ -1403,7 +1403,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D());
switch (impl->activeTree()->source_frame_number()) {
case 0:
@ -1437,7 +1437,7 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D());
// Number of textures used for draw should always be one.
EXPECT_EQ(1, context->numUsedTextures());
@ -1507,7 +1507,7 @@ public:
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D());
switch (impl->activeTree()->source_frame_number()) {
case 0:
@ -1559,7 +1559,7 @@ public:
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->context3D());
CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface()->Context3D());
// Number of textures used for drawing should two except for frame 4
// where the viewport only contains one layer.
@ -2960,9 +2960,9 @@ public:
m_children.push_back(ContentLayerWithUpdateTracking::create(&m_client));
}
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface()
virtual scoped_ptr<OutputSurface> createOutputSurface()
{
return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>();
return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
}
virtual void beginTest()

@ -5,7 +5,10 @@
#ifndef CC_OUTPUT_SURFACE_H_
#define CC_OUTPUT_SURFACE_H_
#include <public/WebCompositorOutputSurface.h>
#define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this.
#include "cc/cc_export.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
namespace WebKit {
class WebGraphicsContext3D;
@ -13,8 +16,47 @@ class WebGraphicsContext3D;
namespace cc {
// TODO(danakj): Move WebCompositorOutputSurface implementation to here.
typedef WebKit::WebCompositorOutputSurface OutputSurface;
class CompositorFrame;
class OutputSurfaceClient;
class SoftwareOutputDevice;
// Represents the output surface for a compositor. The compositor owns
// and manages its destruction. Its lifetime is:
// 1. Created on the main thread by the LayerTreeHost through its client.
// 2. Passed to the compositor thread and bound to a client via BindToClient.
// From here on, it will only be used on the compositor thread.
// 3. If the 3D context is lost, then the compositor will delete the output
// surface (on the compositor thread) and go back to step 1.
class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface {
public:
virtual ~OutputSurface() {}
// Called by the compositor on the compositor thread. This is a place where
// thread-specific data for the output surface can be initialized, since from
// this point on the output surface will only be used on the compositor
// thread.
virtual bool BindToClient(OutputSurfaceClient*) = 0;
struct Capabilities {
Capabilities()
: has_parent_compositor(false) {}
bool has_parent_compositor;
};
virtual const Capabilities& Capabilities() const = 0;
// Obtain the 3d context or the software device associated with this output
// surface. Either of these may return a null pointer, but not both.
// In the event of a lost context, the entire output surface should be
// recreated.
virtual WebKit::WebGraphicsContext3D* Context3D() const = 0;
virtual SoftwareOutputDevice* SoftwareDevice() const = 0;
// Sends frame data to the parent compositor. This should only be called when
// capabilities().has_parent_compositor.
virtual void SendFrameToParentCompositor(const CompositorFrame&) {}
};
} // namespace cc

@ -0,0 +1,27 @@
// 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_CLIENT_H_
#define CC_OUTPUT_SURFACE_CLIENT_H_
#include "base/time.h"
#include "cc/cc_export.h"
namespace cc {
class CompositorFrameAck;
class CC_EXPORT OutputSurfaceClient {
public:
virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
base::TimeDelta interval) = 0;
virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) = 0;
protected:
virtual ~OutputSurfaceClient() {}
};
} // namespace cc
#endif // CC_OUTPUT_SURFACE_CLIENT_H_

@ -9,7 +9,6 @@
#include "base/logging.h"
#include "base/time.h"
#include "base/memory/scoped_ptr.h"
#include <public/WebCompositorOutputSurface.h>
#include "cc/cc_export.h"
namespace gfx {

@ -125,7 +125,7 @@ scoped_ptr<ResourceProvider> ResourceProvider::create(OutputSurface* context)
ResourceProvider::~ResourceProvider()
{
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !context3d->makeContextCurrent())
return;
m_textureUploader.reset();
@ -135,7 +135,7 @@ ResourceProvider::~ResourceProvider()
WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
{
DCHECK(m_threadChecker.CalledOnValidThread());
return m_outputSurface->context3D();
return m_outputSurface->Context3D();
}
bool ResourceProvider::inUseByConsumer(ResourceId id)
@ -168,7 +168,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const g
DCHECK(m_threadChecker.CalledOnValidThread());
unsigned textureId = 0;
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
GLC(context3d, textureId = context3d->createTexture());
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
@ -207,7 +207,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
@ -243,17 +243,17 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
{
Resource* resource = &it->second;
if (resource->glId && !resource->external) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
GLC(context3d, context3d->deleteTexture(resource->glId));
}
if (resource->glUploadQueryId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
GLC(context3d, context3d->deleteQueryEXT(resource->glUploadQueryId));
}
if (resource->glPixelBufferId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
GLC(context3d, context3d->deleteBuffer(resource->glPixelBufferId));
}
@ -297,7 +297,7 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx:
DCHECK(!resource->exported);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(m_textureUploader.get());
context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
@ -360,7 +360,7 @@ void ResourceProvider::flushUploads()
void ResourceProvider::flush()
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (context3d)
context3d->flush();
}
@ -368,7 +368,7 @@ void ResourceProvider::flush()
bool ResourceProvider::shallowFlushIfSupported()
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !m_useShallowFlush)
return false;
@ -505,7 +505,7 @@ ResourceProvider::ResourceProvider(OutputSurface* context)
bool ResourceProvider::initialize()
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d) {
m_maxTextureSize = INT_MAX / 2;
return true;
@ -570,7 +570,7 @@ void ResourceProvider::prepareSendToParent(const ResourceIdArray& resources, Tra
DCHECK(m_threadChecker.CalledOnValidThread());
list->sync_point = 0;
list->resources.clear();
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
return;
@ -591,7 +591,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso
DCHECK(m_threadChecker.CalledOnValidThread());
list->sync_point = 0;
list->resources.clear();
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
return;
@ -615,7 +615,7 @@ void ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& reso
void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources)
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
return;
@ -647,7 +647,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis
void ResourceProvider::receiveFromParent(const TransferableResourceList& resources)
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
return;
@ -671,7 +671,7 @@ void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc
bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource)
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* source = &it->second;
@ -707,7 +707,7 @@ void ResourceProvider::acquirePixelBuffer(ResourceId id)
DCHECK(!resource->exported);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
if (!resource->glPixelBufferId)
resource->glPixelBufferId = context3d->createBuffer();
@ -742,7 +742,7 @@ void ResourceProvider::releasePixelBuffer(ResourceId id)
if (resource->glId) {
DCHECK(resource->glPixelBufferId);
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
context3d->bindBuffer(
GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
@ -773,7 +773,7 @@ uint8_t* ResourceProvider::mapPixelBuffer(ResourceId id)
DCHECK(!resource->exported);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glPixelBufferId);
context3d->bindBuffer(
@ -803,7 +803,7 @@ void ResourceProvider::unmapPixelBuffer(ResourceId id)
DCHECK(!resource->exported);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glPixelBufferId);
context3d->bindBuffer(
@ -827,7 +827,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id)
DCHECK(!resource->exported);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glPixelBufferId);
context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
@ -864,7 +864,7 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id)
void ResourceProvider::bindForSampling(ResourceProvider::ResourceId resourceId, GLenum target, GLenum filter)
{
DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
ResourceMap::iterator it = m_resources.find(resourceId);
DCHECK(it != m_resources.end());
Resource* resource = &it->second;
@ -890,7 +890,7 @@ void ResourceProvider::beginSetPixels(ResourceId id)
lockForWrite(id);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glPixelBufferId);
context3d->bindTexture(GL_TEXTURE_2D, resource->glId);
@ -930,7 +930,7 @@ bool ResourceProvider::didSetPixelsComplete(ResourceId id) {
DCHECK(resource->pendingSetPixels);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->context3D();
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glUploadQueryId);
unsigned complete = 1;

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

@ -5,8 +5,8 @@
#include "cc/resource_update_controller.h"
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/scheduler_test_common.h"
#include "cc/test/tiled_layer_test_common.h"
@ -121,7 +121,7 @@ public:
protected:
virtual void SetUp()
{
m_outputSurface = FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this)));
m_outputSurface = FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>(new WebGraphicsContext3DForUploadTest(this)));
m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 150);
m_bitmap.allocPixels();

@ -128,7 +128,7 @@ TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
EXPECT_EQ(300, ccScrollbarLayer->maximum());
}
class ScrollbarLayerTestMaxTextureSize : public WebKitTests::ThreadedTest {
class ScrollbarLayerTestMaxTextureSize : public ThreadedTest {
public:
ScrollbarLayerTestMaxTextureSize() {}

@ -0,0 +1,31 @@
// 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_SOFTWARE_OUTPUT_DEVICE_H_
#define CC_SOFTWARE_OUTPUT_DEVICE_H_
#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h"
#include "ui/gfx/size.h"
namespace cc {
// This is a "tear-off" class providing software drawing support to
// OutputSurface, such as to a platform-provided window framebuffer.
class SoftwareOutputDevice {
public:
virtual ~SoftwareOutputDevice() {}
// Lock the framebuffer and return a pointer to a WebImage referring to its
// pixels. Set forWrite if you intend to change the pixels. Readback
// is supported whether or not forWrite is set.
// TODO(danakj): Switch this from WebImage to a Skia type.
virtual WebKit::WebImage* Lock(bool forWrite) = 0;
virtual void Unlock() = 0;
virtual void DidChangeViewportSize(gfx::Size) = 0;
};
} // namespace cc
#endif // CC_SOFTWARE_OUTPUT_DEVICE_H_

@ -4,14 +4,13 @@
#include "cc/software_renderer.h"
#include <public/WebCompositorSoftwareOutputDevice.h>
#include <public/WebImage.h>
#include <public/WebSize.h>
#include "base/debug/trace_event.h"
#include "cc/debug_border_draw_quad.h"
#include "cc/math_util.h"
#include "cc/render_pass_draw_quad.h"
#include "cc/software_output_device.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/texture_draw_quad.h"
#include "cc/tile_draw_quad.h"
@ -24,9 +23,6 @@
#include "ui/gfx/skia_util.h"
#include "ui/gfx/transform.h"
using WebKit::WebCompositorSoftwareOutputDevice;
using WebKit::WebSize;
namespace cc {
namespace {
@ -56,12 +52,12 @@ bool isScaleAndTranslate(const SkMatrix& matrix)
} // anonymous namespace
scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, ResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice)
scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, ResourceProvider* resourceProvider, SoftwareOutputDevice* outputDevice)
{
return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, outputDevice));
}
SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevice)
SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* resourceProvider, SoftwareOutputDevice* outputDevice)
: DirectRenderer(client, resourceProvider)
, m_visible(true)
, m_outputDevice(outputDevice)
@ -89,13 +85,13 @@ const RendererCapabilities& SoftwareRenderer::capabilities() const
void SoftwareRenderer::viewportChanged()
{
m_outputDevice->didChangeViewportSize(WebSize(viewportSize().width(), viewportSize().height()));
m_outputDevice->DidChangeViewportSize(viewportSize());
}
void SoftwareRenderer::beginDrawingFrame(DrawingFrame& frame)
{
TRACE_EVENT0("cc", "SoftwareRenderer::beginDrawingFrame");
m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->lock(true)->getSkBitmap()));
m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->Lock(true)->getSkBitmap()));
}
void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame)
@ -104,7 +100,7 @@ void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame)
m_currentFramebufferLock.reset();
m_skCurrentCanvas = 0;
m_skRootCanvas.reset();
m_outputDevice->unlock();
m_outputDevice->Unlock();
}
bool SoftwareRenderer::flippedFramebuffer() const
@ -370,12 +366,12 @@ bool SoftwareRenderer::swapBuffers()
void SoftwareRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect)
{
TRACE_EVENT0("cc", "SoftwareRenderer::getFramebufferPixels");
SkBitmap fullBitmap = m_outputDevice->lock(false)->getSkBitmap();
SkBitmap fullBitmap = m_outputDevice->Lock(false)->getSkBitmap();
SkBitmap subsetBitmap;
SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - rect.bottom(), rect.width(), rect.height());
fullBitmap.extractSubset(&subsetBitmap, invertRect);
subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.width() * 4);
m_outputDevice->unlock();
m_outputDevice->Unlock();
}
void SoftwareRenderer::setVisible(bool visible)

@ -9,23 +9,20 @@
#include "cc/cc_export.h"
#include "cc/direct_renderer.h"
namespace WebKit {
class WebCompositorSoftwareOutputDevice;
}
namespace cc {
class DebugBorderDrawQuad;
class RendererClient;
class RenderPassDrawQuad;
class ResourceProvider;
class SoftwareOutputDevice;
class SolidColorDrawQuad;
class TextureDrawQuad;
class TileDrawQuad;
class RenderPassDrawQuad;
class CC_EXPORT SoftwareRenderer : public DirectRenderer {
public:
static scoped_ptr<SoftwareRenderer> create(RendererClient*, ResourceProvider*, WebKit::WebCompositorSoftwareOutputDevice*);
static scoped_ptr<SoftwareRenderer> create(RendererClient*, ResourceProvider*, SoftwareOutputDevice*);
virtual ~SoftwareRenderer();
virtual const RendererCapabilities& capabilities() const OVERRIDE;
@ -56,7 +53,7 @@ protected:
virtual void ensureScissorTestDisabled() OVERRIDE;
private:
SoftwareRenderer(RendererClient*, ResourceProvider*, WebKit::WebCompositorSoftwareOutputDevice*);
SoftwareRenderer(RendererClient*, ResourceProvider*, SoftwareOutputDevice*);
bool isSoftwareResource(ResourceProvider::ResourceId) const;
@ -70,7 +67,7 @@ private:
RendererCapabilities m_capabilities;
bool m_visible;
WebKit::WebCompositorSoftwareOutputDevice* m_outputDevice;
SoftwareOutputDevice* m_outputDevice;
scoped_ptr<SkCanvas> m_skRootCanvas;
SkCanvas* m_skCurrentCanvas;
SkPaint m_skCurrentPaint;

@ -9,8 +9,8 @@
#include "cc/render_pass_draw_quad.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_web_compositor_software_output_device.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_software_output_device.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/render_pass_test_common.h"
#include "cc/tile_draw_quad.h"
@ -26,13 +26,13 @@ namespace {
class SoftwareRendererTest : public testing::Test, public RendererClient {
public:
void initializeRenderer() {
m_outputSurface = FakeWebCompositorOutputSurface::createSoftware(scoped_ptr<WebKit::WebCompositorSoftwareOutputDevice>(new FakeWebCompositorSoftwareOutputDevice));
m_outputSurface = FakeOutputSurface::CreateSoftware(scoped_ptr<SoftwareOutputDevice>(new FakeSoftwareOutputDevice));
m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
m_renderer = SoftwareRenderer::create(this, resourceProvider(), softwareDevice());
}
WebCompositorSoftwareOutputDevice* softwareDevice() const { return m_outputSurface->softwareDevice(); }
FakeWebCompositorOutputSurface* outputSurface() const { return m_outputSurface.get(); }
SoftwareOutputDevice* softwareDevice() const { return m_outputSurface->SoftwareDevice(); }
FakeOutputSurface* outputSurface() const { return m_outputSurface.get(); }
ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); }
SoftwareRenderer* renderer() const { return m_renderer.get(); }
void setViewportSize(gfx::Size viewportSize) { m_viewportSize = viewportSize; }
@ -48,7 +48,7 @@ public:
virtual bool hasImplThread() const OVERRIDE { return false; }
protected:
scoped_ptr<FakeWebCompositorOutputSurface> m_outputSurface;
scoped_ptr<FakeOutputSurface> m_outputSurface;
scoped_ptr<ResourceProvider> m_resourceProvider;
scoped_ptr<SoftwareRenderer> m_renderer;
gfx::Size m_viewportSize;

@ -70,7 +70,7 @@ int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY
} // namespace
namespace WebKitTests {
namespace cc {
FakeFloatAnimationCurve::FakeFloatAnimationCurve()
: m_duration(1)
@ -185,4 +185,4 @@ int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta
return addAnimatedTransform(*layer.layerAnimationController(), duration, deltaX, deltaY);
}
} // namespace WebKitTests
} // namespace cc

@ -14,7 +14,7 @@ class LayerImpl;
class Layer;
}
namespace WebKitTests {
namespace cc {
class FakeFloatAnimationCurve : public cc::FloatAnimationCurve {
public:
@ -69,6 +69,6 @@ int addOpacityTransitionToLayer(cc::LayerImpl&, double duration, float startOpac
int addAnimatedTransformToLayer(cc::Layer&, double duration, int deltaX, int deltaY);
int addAnimatedTransformToLayer(cc::LayerImpl&, double duration, int deltaX, int deltaY);
} // namespace WebKitTests
} // namespace cc
#endif // CC_TEST_ANIMATION_TEST_COMMON_H_

@ -6,14 +6,14 @@
namespace cc {
scoped_ptr<WebKit::WebCompositorOutputSurface> FakeLayerImplTreeHostClient::createOutputSurface()
scoped_ptr<OutputSurface> FakeLayerImplTreeHostClient::createOutputSurface()
{
if (m_useSoftwareRendering) {
return WebKit::FakeWebCompositorOutputSurface::createSoftware(make_scoped_ptr(new WebKit::FakeWebCompositorSoftwareOutputDevice).PassAs<WebKit::WebCompositorSoftwareOutputDevice>()).PassAs<WebKit::WebCompositorOutputSurface>();
return FakeOutputSurface::CreateSoftware(make_scoped_ptr(new FakeSoftwareOutputDevice).PassAs<SoftwareOutputDevice>()).PassAs<OutputSurface>();
}
WebKit::WebGraphicsContext3D::Attributes attrs;
return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>();
return FakeOutputSurface::Create3d(WebKit::CompositorFakeWebGraphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
}
scoped_ptr<InputHandler> FakeLayerImplTreeHostClient::createInputHandler()

@ -9,7 +9,7 @@
#include "cc/input_handler.h"
#include "cc/layer_tree_host.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_output_surface.h"
namespace cc {
@ -26,7 +26,7 @@ public:
virtual void layout() OVERRIDE { }
virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE { }
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE { }
virtual scoped_ptr<InputHandler> createInputHandler() OVERRIDE;
virtual void willCommit() OVERRIDE { }

@ -0,0 +1,46 @@
// 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.
#include "cc/test/fake_output_surface.h"
namespace cc {
FakeOutputSurface::FakeOutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
context3d_ = context3d.Pass();
}
FakeOutputSurface::FakeOutputSurface(
scoped_ptr<SoftwareOutputDevice> software_device) {
software_device_ = software_device.Pass();
}
FakeOutputSurface::~FakeOutputSurface() {}
bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
if (!context3d_)
return true;
DCHECK(client);
if (!context3d_->makeContextCurrent())
return false;
client_ = client;
return true;
}
const struct OutputSurface::Capabilities& FakeOutputSurface::Capabilities()
const {
return capabilities_;
}
WebKit::WebGraphicsContext3D* FakeOutputSurface::Context3D() const {
return context3d_.get();
}
SoftwareOutputDevice* FakeOutputSurface::SoftwareDevice() const {
return software_device_.get();
}
void FakeOutputSurface::SendFrameToParentCompositor(const CompositorFrame&) {}
} // namespace cc

@ -5,18 +5,59 @@
#ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_
#define CC_TEST_FAKE_OUTPUT_SURFACE_H_
#include "base/logging.h"
#include "base/memory/scoped_ptr.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>
#include "cc/test/fake_software_output_device.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
namespace cc {
class FakeOutputSurface : public OutputSurface {
public:
virtual ~FakeOutputSurface();
static inline scoped_ptr<FakeOutputSurface> Create3d(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
return make_scoped_ptr(new FakeOutputSurface(context3d.Pass()));
}
static inline scoped_ptr<FakeOutputSurface> CreateSoftware(
scoped_ptr<SoftwareOutputDevice> software_device) {
return make_scoped_ptr(new FakeOutputSurface(software_device.Pass()));
}
virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE;
virtual const struct Capabilities& Capabilities() const OVERRIDE;
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE;
virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE;
virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE;
private:
explicit FakeOutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
explicit FakeOutputSurface(
scoped_ptr<SoftwareOutputDevice> software_device);
scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
scoped_ptr<SoftwareOutputDevice> software_device_;
struct Capabilities capabilities_;
OutputSurfaceClient* client_;
};
static inline scoped_ptr<cc::OutputSurface> createFakeOutputSurface()
{
return WebKit::FakeWebCompositorOutputSurface::create(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<cc::OutputSurface>();
return FakeOutputSurface::Create3d(
WebKit::CompositorFakeWebGraphicsContext3D::create(
WebKit::WebGraphicsContext3D::Attributes())
.PassAs<WebKit::WebGraphicsContext3D>())
.PassAs<cc::OutputSurface>();
}
} // namespace WebKit
} // namespace cc
#endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_

@ -0,0 +1,33 @@
// 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.
#include "cc/test/fake_software_output_device.h"
namespace cc {
FakeSoftwareOutputDevice::FakeSoftwareOutputDevice() {}
FakeSoftwareOutputDevice::~FakeSoftwareOutputDevice() {}
WebKit::WebImage* FakeSoftwareOutputDevice::Lock(bool forWrite) {
DCHECK(device_);
image_ = device_->accessBitmap(forWrite);
return &image_;
}
void FakeSoftwareOutputDevice::Unlock() {
image_.reset();
}
void FakeSoftwareOutputDevice::DidChangeViewportSize(gfx::Size size) {
if (device_.get() &&
size.width() == device_->width() &&
size.height() == device_->height())
return;
device_ = skia::AdoptRef(new SkDevice(
SkBitmap::kARGB_8888_Config, size.width(), size.height(), true));
}
} // namespace cc

@ -0,0 +1,33 @@
// 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_SOFTWARE_OUTPUT_DEVICE_H_
#define CC_TEST_FAKE_SOFTWARE_OUTPUT_DEVICE_H_
#include "base/logging.h"
#include "cc/software_output_device.h"
#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h"
#include "third_party/skia/include/core/SkDevice.h"
namespace cc {
class FakeSoftwareOutputDevice : public SoftwareOutputDevice {
public:
FakeSoftwareOutputDevice();
virtual ~FakeSoftwareOutputDevice();
virtual WebKit::WebImage* Lock(bool forWrite) OVERRIDE;
virtual void Unlock() OVERRIDE;
virtual void DidChangeViewportSize(gfx::Size size) OVERRIDE;
private:
skia::RefPtr<SkDevice> device_;
WebKit::WebImage image_;
};
} // namespace cc
#endif // CC_TEST_FAKE_SOFTWARE_OUTPUT_DEVICE_H_

@ -1,76 +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_WEB_COMPOSITOR_OUTPUT_SURFACE_H_
#define CC_TEST_FAKE_WEB_COMPOSITOR_OUTPUT_SURFACE_H_
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/test/fake_web_compositor_software_output_device.h"
#include <public/WebCompositorOutputSurface.h>
#include <public/WebGraphicsContext3D.h>
namespace WebKit {
class FakeWebCompositorOutputSurface : public WebCompositorOutputSurface {
public:
static inline scoped_ptr<FakeWebCompositorOutputSurface> create(scoped_ptr<WebGraphicsContext3D> context3D)
{
return make_scoped_ptr(new FakeWebCompositorOutputSurface(context3D.Pass()));
}
static inline scoped_ptr<FakeWebCompositorOutputSurface> createSoftware(scoped_ptr<WebCompositorSoftwareOutputDevice> softwareDevice)
{
return make_scoped_ptr(new FakeWebCompositorOutputSurface(softwareDevice.Pass()));
}
virtual bool bindToClient(WebCompositorOutputSurfaceClient* client) OVERRIDE
{
if (!m_context3D)
return true;
DCHECK(client);
if (!m_context3D->makeContextCurrent())
return false;
m_client = client;
return true;
}
virtual const Capabilities& capabilities() const OVERRIDE
{
return m_capabilities;
}
virtual WebGraphicsContext3D* context3D() const OVERRIDE
{
return m_context3D.get();
}
virtual WebCompositorSoftwareOutputDevice* softwareDevice() const OVERRIDE
{
return m_softwareDevice.get();
}
virtual void sendFrameToParentCompositor(const WebCompositorFrame&) OVERRIDE
{
}
private:
explicit FakeWebCompositorOutputSurface(scoped_ptr<WebGraphicsContext3D> context3D)
{
m_context3D = context3D.Pass();
}
explicit FakeWebCompositorOutputSurface(scoped_ptr<WebCompositorSoftwareOutputDevice> softwareDevice)
{
m_softwareDevice = softwareDevice.Pass();
}
scoped_ptr<WebGraphicsContext3D> m_context3D;
scoped_ptr<WebCompositorSoftwareOutputDevice> m_softwareDevice;
Capabilities m_capabilities;
WebCompositorOutputSurfaceClient* m_client;
};
} // namespace WebKit
#endif // CC_TEST_FAKE_WEB_COMPOSITOR_OUTPUT_SURFACE_H_

@ -1,45 +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_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
#define CC_TEST_FAKE_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/skia/include/core/SkDevice.h"
#include <public/WebCompositorSoftwareOutputDevice.h>
#include <public/WebImage.h>
#include <public/WebSize.h>
namespace WebKit {
class FakeWebCompositorSoftwareOutputDevice : public WebCompositorSoftwareOutputDevice {
public:
virtual WebImage* lock(bool forWrite) OVERRIDE
{
DCHECK(m_device.get());
m_image = m_device->accessBitmap(forWrite);
return &m_image;
}
virtual void unlock() OVERRIDE
{
m_image.reset();
}
virtual void didChangeViewportSize(WebSize size) OVERRIDE
{
if (m_device.get() && size.width == m_device->width() && size.height == m_device->height())
return;
m_device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, size.width, size.height, true));
}
private:
scoped_ptr<SkDevice> m_device;
WebImage m_image;
};
} // namespace WebKit
#endif // CC_TEST_FAKE_WEB_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_

@ -17,7 +17,7 @@
#include "cc/single_thread_proxy.h"
#include "cc/thread_impl.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_web_graphics_context_3d.h"
#include "cc/test/occlusion_tracker_test_common.h"
#include "cc/test/tiled_layer_test_common.h"
@ -26,17 +26,9 @@
#include <public/WebFilterOperation.h>
#include <public/WebFilterOperations.h>
using cc::FontAtlas;
using cc::InputHandler;
using cc::Layer;
using cc::LayerTreeHostImplClient;
using cc::LayerTreeSettings;
using cc::Proxy;
using cc::ScopedThreadProxy;
using namespace WebKit;
namespace WebKitTests {
namespace cc {
scoped_ptr<CompositorFakeWebGraphicsContext3DWithTextureTracking> CompositorFakeWebGraphicsContext3DWithTextureTracking::create(Attributes attrs)
{
@ -87,9 +79,9 @@ bool TestHooks::prepareToDrawOnThread(cc::LayerTreeHostImpl*)
return true;
}
scoped_ptr<WebCompositorOutputSurface> TestHooks::createOutputSurface()
scoped_ptr<OutputSurface> TestHooks::createOutputSurface()
{
return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSurface>();
return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
}
scoped_ptr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
@ -227,7 +219,7 @@ public:
m_testHooks->applyScrollAndScale(scrollDelta, scale);
}
virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE
virtual scoped_ptr<OutputSurface> createOutputSurface() OVERRIDE
{
return m_testHooks->createOutputSurface();
}
@ -503,4 +495,4 @@ void ThreadedTest::runTest(bool threaded)
afterTest();
}
} // namespace WebKitTests
} // namespace cc

@ -23,7 +23,7 @@ class LayerTreeHostImpl;
class Thread;
}
namespace WebKitTests {
namespace cc {
// Used by test stubs to notify the test when something interesting happens.
class TestHooks : public WebKit::WebAnimationDelegate {
@ -48,7 +48,7 @@ public:
virtual void notifyAnimationStarted(double time) OVERRIDE { }
virtual void notifyAnimationFinished(double time) OVERRIDE { }
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface();
virtual scoped_ptr<OutputSurface> createOutputSurface();
};
class TimeoutTask;

@ -18,19 +18,22 @@ PixelTestOutputSurface::PixelTestOutputSurface() {
PixelTestOutputSurface::~PixelTestOutputSurface() {
}
bool PixelTestOutputSurface::bindToClient(
WebKit::WebCompositorOutputSurfaceClient*) {
bool PixelTestOutputSurface::BindToClient(OutputSurfaceClient*) {
return context_->makeContextCurrent();
}
const WebKit::WebCompositorOutputSurface::Capabilities&
PixelTestOutputSurface::capabilities() const {
static WebKit::WebCompositorOutputSurface::Capabilities capabilities;
const struct OutputSurface::Capabilities& PixelTestOutputSurface::Capabilities()
const {
static struct OutputSurface::Capabilities capabilities;
return capabilities;
}
WebKit::WebGraphicsContext3D* PixelTestOutputSurface::context3D() const {
WebKit::WebGraphicsContext3D* PixelTestOutputSurface::Context3D() const {
return context_.get();
}
SoftwareOutputDevice* PixelTestOutputSurface::SoftwareDevice() const {
return NULL;
}
} // namespace cc

@ -19,11 +19,12 @@ class PixelTestOutputSurface : public OutputSurface {
virtual ~PixelTestOutputSurface();
// OutputSurface overrides.
virtual bool bindToClient(WebKit::WebCompositorOutputSurfaceClient*) OVERRIDE;
virtual const WebKit::WebCompositorOutputSurface::Capabilities& capabilities() const OVERRIDE;
virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE;
virtual void sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) OVERRIDE { }
virtual bool BindToClient(OutputSurfaceClient*) OVERRIDE;
virtual const struct OutputSurface::Capabilities& Capabilities() const
OVERRIDE;
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE;
virtual SoftwareOutputDevice* SoftwareDevice() const OVERRIDE;
virtual void SendFrameToParentCompositor(const CompositorFrame&) OVERRIDE {}
private:
PixelTestOutputSurface();

@ -15,8 +15,6 @@
#include "cc/test/fake_proxy.h"
#include "testing/gtest/include/gtest/gtest.h"
using namespace WebKitTests;
namespace cc {
namespace {

@ -15,6 +15,7 @@
#include "cc/input_handler.h"
#include "cc/layer.h"
#include "cc/layer_tree_host.h"
#include "cc/output_surface.h"
#include "cc/thread_impl.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
@ -26,7 +27,6 @@
#include "content/public/common/content_switches.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "ui/gfx/android/java_bitmap.h"
#include "webkit/glue/webthread_impl.h"
@ -42,46 +42,43 @@ static bool g_initialized = false;
static webkit_glue::WebThreadImpl* g_impl_thread = NULL;
static bool g_use_direct_gl = false;
// Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface.
class WebGraphicsContextToOutputSurfaceAdapter :
public WebKit::WebCompositorOutputSurface {
public:
explicit WebGraphicsContextToOutputSurfaceAdapter(
WebKit::WebGraphicsContext3D* context)
: m_context3D(context)
, m_client(0)
{
}
// Adapts a pure WebGraphicsContext3D into a cc::OutputSurface.
class WebGraphicsContextToOutputSurfaceAdapter : public cc::OutputSurface {
public:
explicit WebGraphicsContextToOutputSurfaceAdapter(
WebKit::WebGraphicsContext3D* context)
: context3d_(context),
client_(0) {
}
virtual bool bindToClient(
WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE
{
DCHECK(client);
if (!m_context3D->makeContextCurrent())
return false;
m_client = client;
return true;
}
virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE {
DCHECK(client);
if (!context3d_->makeContextCurrent())
return false;
client_ = client;
return true;
}
virtual const Capabilities& capabilities() const OVERRIDE
{
return m_capabilities;
}
virtual const struct Capabilities& Capabilities() const OVERRIDE {
return capabilities_;
}
virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE
{
return m_context3D.get();
}
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
return context3d_.get();
}
virtual void sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) OVERRIDE
{
}
virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
return NULL;
}
private:
scoped_ptr<WebKit::WebGraphicsContext3D> m_context3D;
Capabilities m_capabilities;
WebKit::WebCompositorOutputSurfaceClient* m_client;
virtual void SendFrameToParentCompositor(
const cc::CompositorFrame&) OVERRIDE {
}
private:
scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
struct Capabilities capabilities_;
cc::OutputSurfaceClient* client_;
};
} // anonymous namespace
@ -278,8 +275,7 @@ void CompositorImpl::applyScrollAndScale(gfx::Vector2d scrollDelta,
float pageScale) {
}
scoped_ptr<WebKit::WebCompositorOutputSurface>
CompositorImpl::createOutputSurface() {
scoped_ptr<cc::OutputSurface> CompositorImpl::createOutputSurface() {
if (g_use_direct_gl) {
WebKit::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = false;
@ -289,7 +285,7 @@ scoped_ptr<WebKit::WebCompositorOutputSurface>
attrs,
window_,
NULL));
return scoped_ptr<WebKit::WebCompositorOutputSurface>(
return scoped_ptr<cc::OutputSurface>(
new WebGraphicsContextToOutputSurfaceAdapter(context.release()));
} else {
DCHECK(window_ && surface_id_);
@ -308,9 +304,9 @@ scoped_ptr<WebKit::WebCompositorOutputSurface>
false,
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) {
LOG(ERROR) << "Failed to create 3D context for compositor.";
return scoped_ptr<WebKit::WebCompositorOutputSurface>();
return scoped_ptr<cc::OutputSurface>();
}
return scoped_ptr<WebKit::WebCompositorOutputSurface>(
return scoped_ptr<cc::OutputSurface>(
new WebGraphicsContextToOutputSurfaceAdapter(context.release()));
}
}

@ -65,8 +65,7 @@ class CONTENT_EXPORT CompositorImpl
virtual void layout() OVERRIDE;
virtual void applyScrollAndScale(gfx::Vector2d scrollDelta,
float pageScale) OVERRIDE;
virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface()
OVERRIDE;
virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE;
virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE;
virtual void willCommit() OVERRIDE {}

@ -12,6 +12,8 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
#include "cc/output_surface.h"
#include "cc/output_surface_client.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
@ -24,8 +26,6 @@
#include "content/common/webkitplatformsupport_impl.h"
#include "content/public/common/content_switches.h"
#include "gpu/ipc/command_buffer_proxy.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurfaceClient.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_setup.h"
@ -270,10 +270,10 @@ class BrowserCompositorOutputSurfaceProxy :
// Adapts a WebGraphicsContext3DCommandBufferImpl into a
// WebCompositorOutputSurface that also handles vsync parameter updates
// cc::OutputSurface that also handles vsync parameter updates
// arriving from the GPU process.
class BrowserCompositorOutputSurface :
public WebKit::WebCompositorOutputSurface,
public cc::OutputSurface,
public base::NonThreadSafe {
public:
explicit BrowserCompositorOutputSurface(
@ -294,8 +294,8 @@ class BrowserCompositorOutputSurface :
output_surface_proxy_->RemoveSurface(surface_id_);
}
virtual bool bindToClient(
WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE {
virtual bool BindToClient(
cc::OutputSurfaceClient* client) OVERRIDE {
DCHECK(CalledOnValidThread());
DCHECK(client);
DCHECK(!client_);
@ -309,36 +309,37 @@ class BrowserCompositorOutputSurface :
return true;
}
virtual const Capabilities& capabilities() const OVERRIDE {
virtual const struct Capabilities& Capabilities() const OVERRIDE {
DCHECK(CalledOnValidThread());
return capabilities_;
}
virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE {
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
DCHECK(CalledOnValidThread());
return context3D_.get();
}
virtual void sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) OVERRIDE {
virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
DCHECK(CalledOnValidThread());
return NULL;
}
virtual void SendFrameToParentCompositor(
const cc::CompositorFrame&) OVERRIDE {
}
void OnUpdateVSyncParameters(
base::TimeTicks timebase, base::TimeDelta interval) {
DCHECK(CalledOnValidThread());
DCHECK(client_);
double monotonicTimebase = timebase.ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);
double intervalInSeconds = interval.ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);
client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);
client_->OnVSyncParametersChanged(timebase, interval);
}
private:
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3D_;
int surface_id_;
Capabilities capabilities_;
WebKit::WebCompositorOutputSurfaceClient* client_;
struct Capabilities capabilities_;
cc::OutputSurfaceClient* client_;
scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_;
};
@ -369,7 +370,7 @@ class GpuProcessTransportFactory :
return CreateContextCommon(swap_client, 0);
}
virtual WebKit::WebCompositorOutputSurface* CreateOutputSurface(
virtual cc::OutputSurface* CreateOutputSurface(
ui::Compositor* compositor) OVERRIDE {
PerCompositorData* data = per_compositor_data_[compositor];
if (!data)

@ -5,15 +5,15 @@
#include "content/renderer/gpu/compositor_output_surface.h"
#include "base/message_loop_proxy.h"
#include "cc/output_surface_client.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_thread_impl.h"
#include "ipc/ipc_forwarding_message_filter.h"
#include "ipc/ipc_sync_channel.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurfaceClient.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
using cc::SoftwareOutputDevice;
using WebKit::WebGraphicsContext3D;
using WebKit::WebCompositorSoftwareOutputDevice;
namespace content {
@ -32,7 +32,7 @@ IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter(
CompositorOutputSurface::CompositorOutputSurface(
int32 routing_id,
WebGraphicsContext3D* context3D,
WebCompositorSoftwareOutputDevice* software_device)
cc::SoftwareOutputDevice* software_device)
: output_surface_filter_(
RenderThreadImpl::current()->compositor_output_surface_filter()),
client_(NULL),
@ -40,7 +40,7 @@ CompositorOutputSurface::CompositorOutputSurface(
context3D_(context3D),
software_device_(software_device) {
DCHECK(output_surface_filter_);
capabilities_.hasParentCompositor = false;
capabilities_.has_parent_compositor = false;
DetachFromThread();
}
@ -52,14 +52,14 @@ CompositorOutputSurface::~CompositorOutputSurface() {
output_surface_filter_->RemoveRoute(routing_id_);
}
const WebKit::WebCompositorOutputSurface::Capabilities&
CompositorOutputSurface::capabilities() const {
const struct cc::OutputSurface::Capabilities&
CompositorOutputSurface::Capabilities() const {
DCHECK(CalledOnValidThread());
return capabilities_;
}
bool CompositorOutputSurface::bindToClient(
WebKit::WebCompositorOutputSurfaceClient* client) {
bool CompositorOutputSurface::BindToClient(
cc::OutputSurfaceClient* client) {
DCHECK(CalledOnValidThread());
DCHECK(!client_);
if (context3D_.get()) {
@ -78,18 +78,17 @@ bool CompositorOutputSurface::bindToClient(
return true;
}
WebGraphicsContext3D* CompositorOutputSurface::context3D() const {
WebGraphicsContext3D* CompositorOutputSurface::Context3D() const {
DCHECK(CalledOnValidThread());
return context3D_.get();
}
WebCompositorSoftwareOutputDevice* CompositorOutputSurface::softwareDevice()
const {
cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const {
return software_device_.get();
}
void CompositorOutputSurface::sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) {
void CompositorOutputSurface::SendFrameToParentCompositor(
const cc::CompositorFrame&) {
DCHECK(CalledOnValidThread());
NOTREACHED();
}
@ -104,15 +103,10 @@ void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
}
void CompositorOutputSurface::OnUpdateVSyncParameters(
base::TimeTicks timebase,
base::TimeDelta interval) {
base::TimeTicks timebase, base::TimeDelta interval) {
DCHECK(CalledOnValidThread());
DCHECK(client_);
double monotonicTimebase = timebase.ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);
double intervalInSeconds = interval.ToInternalValue() /
static_cast<double>(base::Time::kMicrosecondsPerSecond);
client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);
client_->OnVSyncParametersChanged(timebase, interval);
}
} // namespace content

@ -11,8 +11,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/time.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSoftwareOutputDevice.h"
#include "cc/output_surface.h"
#include "cc/software_output_device.h"
namespace base {
class TaskRunner;
@ -28,25 +28,24 @@ namespace content {
// This class can be created only on the main thread, but then becomes pinned
// to a fixed thread when bindToClient is called.
class CompositorOutputSurface
: NON_EXPORTED_BASE(public WebKit::WebCompositorOutputSurface),
NON_EXPORTED_BASE(public base::NonThreadSafe) {
: NON_EXPORTED_BASE(public cc::OutputSurface),
NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
static IPC::ForwardingMessageFilter* CreateFilter(
base::TaskRunner* target_task_runner);
CompositorOutputSurface(int32 routing_id,
WebKit::WebGraphicsContext3D* context3d,
WebKit::WebCompositorSoftwareOutputDevice* software);
cc::SoftwareOutputDevice* software);
virtual ~CompositorOutputSurface();
// WebCompositorOutputSurface implementation.
virtual bool bindToClient(
WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE;
virtual const Capabilities& capabilities() const OVERRIDE;
virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE;
virtual WebKit::WebCompositorSoftwareOutputDevice* softwareDevice() const;
virtual void sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) OVERRIDE;
// cc::OutputSurface implementation.
virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE;
virtual const struct Capabilities& Capabilities() const OVERRIDE;
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE;
virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE;
virtual void SendFrameToParentCompositor(
const cc::CompositorFrame&) OVERRIDE;
private:
class CompositorOutputSurfaceProxy :
@ -74,12 +73,12 @@ class CompositorOutputSurface
base::TimeTicks timebase, base::TimeDelta interval);
scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_;
WebKit::WebCompositorOutputSurfaceClient* client_;
cc::OutputSurfaceClient* client_;
scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_;
int routing_id_;
Capabilities capabilities_;
struct Capabilities capabilities_;
scoped_ptr<WebKit::WebGraphicsContext3D> context3D_;
scoped_ptr<WebKit::WebCompositorSoftwareOutputDevice> software_device_;
scoped_ptr<cc::SoftwareOutputDevice> software_device_;
};
} // namespace content

@ -39,20 +39,20 @@ CompositorSoftwareOutputDeviceGLAdapter::
Destroy();
}
WebImage* CompositorSoftwareOutputDeviceGLAdapter::lock(bool forWrite) {
WebImage* CompositorSoftwareOutputDeviceGLAdapter::Lock(bool forWrite) {
locked_for_write_ = forWrite;
image_ = device_->accessBitmap(forWrite);
return &image_;
}
void CompositorSoftwareOutputDeviceGLAdapter::unlock() {
void CompositorSoftwareOutputDeviceGLAdapter::Unlock() {
if (locked_for_write_)
Draw(device_->accessBitmap(false).pixelRef()->pixels());
image_.reset();
}
void CompositorSoftwareOutputDeviceGLAdapter::didChangeViewportSize(
WebSize size) {
void CompositorSoftwareOutputDeviceGLAdapter::DidChangeViewportSize(
gfx::Size size) {
if (!initialized_)
Initialize();

@ -10,9 +10,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/threading/non_thread_safe.h"
#include "cc/software_output_device.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSoftwareOutputDevice.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "ui/gfx/size.h"
@ -21,17 +21,17 @@ namespace content {
// This class can be created only on the main thread, but then becomes pinned
// to a fixed thread when bindToClient is called.
class CompositorSoftwareOutputDeviceGLAdapter
: NON_EXPORTED_BASE(public WebKit::WebCompositorSoftwareOutputDevice),
: NON_EXPORTED_BASE(public cc::SoftwareOutputDevice),
NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
CompositorSoftwareOutputDeviceGLAdapter(
WebKit::WebGraphicsContext3D* context3d);
virtual ~CompositorSoftwareOutputDeviceGLAdapter();
virtual WebKit::WebImage* lock(bool forWrite) OVERRIDE;
virtual void unlock() OVERRIDE;
virtual void didChangeViewportSize(WebKit::WebSize size) OVERRIDE;
// cc::SoftwareOutputDevice implementation
virtual WebKit::WebImage* Lock(bool forWrite) OVERRIDE;
virtual void Unlock() OVERRIDE;
virtual void DidChangeViewportSize(gfx::Size size) OVERRIDE;
private:
void Initialize();

@ -27,6 +27,7 @@
#include "base/sys_string_conversions.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "cc/output_surface.h"
#include "cc/switches.h"
#include "content/common/appcache/appcache_dispatcher.h"
#include "content/common/child_thread.h"
@ -121,7 +122,6 @@
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/http/http_util.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"

@ -16,9 +16,9 @@
#include "cc/input_handler.h"
#include "cc/layer.h"
#include "cc/layer_tree_host.h"
#include "cc/output_surface.h"
#include "cc/thread_impl.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/dip_util.h"
@ -52,9 +52,9 @@ ui::ContextFactory* g_context_factory = NULL;
const int kCompositorLockTimeoutMs = 67;
// Adapts a pure WebGraphicsContext3D into a WebCompositorOutputSurface.
// Adapts a pure WebGraphicsContext3D into a cc::OutputSurface.
class WebGraphicsContextToOutputSurfaceAdapter
: public WebKit::WebCompositorOutputSurface {
: public cc::OutputSurface {
public:
explicit WebGraphicsContextToOutputSurfaceAdapter(
WebKit::WebGraphicsContext3D* context)
@ -62,8 +62,8 @@ class WebGraphicsContextToOutputSurfaceAdapter
client_(NULL) {
}
virtual bool bindToClient(
WebKit::WebCompositorOutputSurfaceClient* client) OVERRIDE {
virtual bool BindToClient(
cc::OutputSurfaceClient* client) OVERRIDE {
DCHECK(client);
if (!context3D_->makeContextCurrent())
return false;
@ -71,22 +71,26 @@ class WebGraphicsContextToOutputSurfaceAdapter
return true;
}
virtual const Capabilities& capabilities() const OVERRIDE {
virtual const struct Capabilities& Capabilities() const OVERRIDE {
return capabilities_;
}
virtual WebKit::WebGraphicsContext3D* context3D() const OVERRIDE {
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE {
return context3D_.get();
}
virtual void sendFrameToParentCompositor(
const WebKit::WebCompositorFrame&) OVERRIDE {
virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE {
return NULL;
}
virtual void SendFrameToParentCompositor(
const cc::CompositorFrame&) OVERRIDE {
}
private:
scoped_ptr<WebKit::WebGraphicsContext3D> context3D_;
Capabilities capabilities_;
WebKit::WebCompositorOutputSurfaceClient* client_;
struct Capabilities capabilities_;
cc::OutputSurfaceClient* client_;
};
class PendingSwap {
@ -149,7 +153,7 @@ bool DefaultContextFactory::Initialize() {
return true;
}
WebKit::WebCompositorOutputSurface* DefaultContextFactory::CreateOutputSurface(
cc::OutputSurface* DefaultContextFactory::CreateOutputSurface(
Compositor* compositor) {
return new WebGraphicsContextToOutputSurfaceAdapter(
CreateContextCommon(compositor, false));
@ -497,16 +501,15 @@ void Compositor::applyScrollAndScale(gfx::Vector2d scrollDelta,
float pageScale) {
}
scoped_ptr<WebKit::WebCompositorOutputSurface>
Compositor::createOutputSurface() {
scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() {
if (test_compositor_enabled) {
ui::TestWebGraphicsContext3D* test_context =
new ui::TestWebGraphicsContext3D();
test_context->Initialize();
return scoped_ptr<WebKit::WebCompositorOutputSurface>(
return scoped_ptr<cc::OutputSurface>(
new WebGraphicsContextToOutputSurfaceAdapter(test_context));
} else {
return scoped_ptr<WebKit::WebCompositorOutputSurface>(
return scoped_ptr<cc::OutputSurface>(
ContextFactory::GetInstance()->CreateOutputSurface(this));
}
}

@ -60,7 +60,7 @@ class COMPOSITOR_EXPORT ContextFactory {
// Creates an output surface for the given compositor. The factory may keep
// per-compositor data (e.g. a shared context), that needs to be cleaned up
// by calling RemoveCompositor when the compositor gets destroyed.
virtual WebKit::WebCompositorOutputSurface* CreateOutputSurface(
virtual cc::OutputSurface* CreateOutputSurface(
Compositor* compositor) = 0;
// Creates a context used for offscreen rendering. This context can be shared
@ -78,7 +78,7 @@ class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
virtual ~DefaultContextFactory();
// ContextFactory implementation
virtual WebKit::WebCompositorOutputSurface* CreateOutputSurface(
virtual cc::OutputSurface* CreateOutputSurface(
Compositor* compositor) OVERRIDE;
virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE;
virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
@ -250,7 +250,7 @@ class COMPOSITOR_EXPORT Compositor
virtual void layout() OVERRIDE;
virtual void applyScrollAndScale(gfx::Vector2d scrollDelta,
float pageScale) OVERRIDE;
virtual scoped_ptr<WebKit::WebCompositorOutputSurface>
virtual scoped_ptr<cc::OutputSurface>
createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE;
virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;

@ -9,6 +9,10 @@
'web_animation_curve_common.h',
'web_animation_impl.cc',
'web_animation_impl.h',
'web_compositor_support_output_surface.cc',
'web_compositor_support_output_surface.h',
'web_compositor_support_software_output_device.cc',
'web_compositor_support_software_output_device.h',
'web_content_layer_impl.cc',
'web_content_layer_impl.h',
'web_delegated_renderer_layer_impl.cc',

@ -6,7 +6,7 @@
#define WebLayerTreeViewTestCommon_h
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "cc/test/fake_output_surface.h"
#include <gmock/gmock.h>
#include <public/WebLayerTreeViewClient.h>
@ -21,9 +21,9 @@ public:
virtual void layout() OVERRIDE { }
virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) OVERRIDE { }
virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE
virtual cc::OutputSurface* createOutputSurface() OVERRIDE
{
return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).release();
return cc::FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).PassAs<WebKit::WebGraphicsContext3D>()).release();
}
virtual void didRecreateOutputSurface(bool) OVERRIDE { }

@ -8,6 +8,8 @@
#include "base/message_loop_proxy.h"
#include "cc/thread_impl.h"
#include "webkit/compositor_bindings/web_animation_impl.h"
#include "webkit/compositor_bindings/web_compositor_support_output_surface.h"
#include "webkit/compositor_bindings/web_compositor_support_software_output_device.h"
#include "webkit/compositor_bindings/web_content_layer_impl.h"
#include "webkit/compositor_bindings/web_delegated_renderer_layer_impl.h"
#include "webkit/compositor_bindings/web_external_texture_layer_impl.h"
@ -21,6 +23,7 @@
#include "webkit/compositor_bindings/web_transform_animation_curve_impl.h"
#include "webkit/compositor_bindings/web_video_layer_impl.h"
#include "webkit/glue/webthread_impl.h"
#include "webkit/support/webkit_support.h"
using WebKit::WebAnimation;
using WebKit::WebAnimationCurve;
@ -92,6 +95,22 @@ WebLayerTreeView* WebCompositorSupportImpl::createLayerTreeView(
return layerTreeViewImpl.release();
}
WebKit::WebCompositorOutputSurface*
WebCompositorSupportImpl::createOutputSurfaceFor3D(
WebKit::WebGraphicsContext3D* context) {
scoped_ptr<WebKit::WebGraphicsContext3D> context3d = make_scoped_ptr(context);
return WebCompositorSupportOutputSurface::Create3d(
context3d.Pass()).release();
}
WebKit::WebCompositorOutputSurface*
WebCompositorSupportImpl::createOutputSurfaceForSoftware() {
scoped_ptr<WebCompositorSupportSoftwareOutputDevice> software_device =
make_scoped_ptr(new WebCompositorSupportSoftwareOutputDevice);
return WebCompositorSupportOutputSurface::CreateSoftware(
software_device.PassAs<cc::SoftwareOutputDevice>()).release();
}
WebLayer* WebCompositorSupportImpl::createLayer() {
return new WebKit::WebLayerImpl();
}

@ -13,6 +13,11 @@ namespace base {
class MessageLoopProxy;
}
namespace WebKit {
class WebCompositorOutputSurface;
class WebGraphicsContext3D;
}
namespace webkit {
class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
@ -26,6 +31,9 @@ class WebCompositorSupportImpl : public WebKit::WebCompositorSupport {
virtual WebKit::WebLayerTreeView* createLayerTreeView(
WebKit::WebLayerTreeViewClient* client, const WebKit::WebLayer& root,
const WebKit::WebLayerTreeView::Settings& settings);
virtual WebKit::WebCompositorOutputSurface* createOutputSurfaceFor3D(
WebKit::WebGraphicsContext3D* context);
virtual WebKit::WebCompositorOutputSurface* createOutputSurfaceForSoftware();
virtual WebKit::WebLayer* createLayer();
virtual WebKit::WebContentLayer* createContentLayer(
WebKit::WebContentLayerClient* client);

@ -0,0 +1,49 @@
// Copyright (c) 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.
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "webkit/compositor_bindings/web_compositor_support_output_surface.h"
namespace webkit {
WebCompositorSupportOutputSurface::WebCompositorSupportOutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
context3d_ = context3d.Pass();
}
WebCompositorSupportOutputSurface::WebCompositorSupportOutputSurface(
scoped_ptr<cc::SoftwareOutputDevice> software_device) {
software_device_ = software_device.Pass();
}
WebCompositorSupportOutputSurface::~WebCompositorSupportOutputSurface() {}
bool WebCompositorSupportOutputSurface::BindToClient(
cc::OutputSurfaceClient* client) {
if (!context3d_)
return true;
DCHECK(client);
return context3d_->makeContextCurrent();
}
const struct cc::OutputSurface::Capabilities&
WebCompositorSupportOutputSurface::Capabilities() const {
return capabilities_;
}
WebKit::WebGraphicsContext3D* WebCompositorSupportOutputSurface::Context3D() const {
return context3d_.get();
}
cc::SoftwareOutputDevice* WebCompositorSupportOutputSurface::SoftwareDevice() const {
return software_device_.get();
}
void WebCompositorSupportOutputSurface::SendFrameToParentCompositor(
const cc::CompositorFrame&) {
// No support for delegated renderers in DumpRenderTree.
NOTREACHED();
}
} // namespace webkit

@ -0,0 +1,53 @@
// Copyright (c) 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 WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE
#define WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE
#include "base/memory/scoped_ptr.h"
#include "cc/output_surface.h"
#include "webkit/compositor_bindings/web_compositor_support_software_output_device.h"
namespace webkit {
class WebCompositorSupportOutputSurface : public cc::OutputSurface {
public:
static inline scoped_ptr<WebCompositorSupportOutputSurface> Create3d(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
return make_scoped_ptr(
new WebCompositorSupportOutputSurface(context3d.Pass()));
}
static inline scoped_ptr<WebCompositorSupportOutputSurface> CreateSoftware(
scoped_ptr<cc::SoftwareOutputDevice> software_device) {
return make_scoped_ptr(
new WebCompositorSupportOutputSurface(software_device.Pass()));
}
virtual ~WebCompositorSupportOutputSurface();
virtual bool BindToClient(cc::OutputSurfaceClient*) OVERRIDE;
virtual const struct Capabilities& Capabilities() const OVERRIDE;
virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE;
virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE;
virtual void SendFrameToParentCompositor(const cc::CompositorFrame&) OVERRIDE;
private:
explicit WebCompositorSupportOutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context3d);
explicit WebCompositorSupportOutputSurface(
scoped_ptr<cc::SoftwareOutputDevice> software_device);
struct cc::OutputSurface::Capabilities capabilities_;
scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
scoped_ptr<cc::SoftwareOutputDevice> software_device_;
};
} // namespace webkit
#endif // WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_OUTPUT_SURFACE

@ -0,0 +1,37 @@
// 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.
#include "webkit/compositor_bindings/web_compositor_support_software_output_device.h"
namespace webkit {
WebCompositorSupportSoftwareOutputDevice::
WebCompositorSupportSoftwareOutputDevice() {}
WebCompositorSupportSoftwareOutputDevice::
~WebCompositorSupportSoftwareOutputDevice() {}
WebKit::WebImage* WebCompositorSupportSoftwareOutputDevice::Lock(
bool forWrite) {
DCHECK(device_);
image_ = device_->accessBitmap(forWrite);
return &image_;
}
void WebCompositorSupportSoftwareOutputDevice::Unlock() {
image_.reset();
}
void WebCompositorSupportSoftwareOutputDevice::DidChangeViewportSize(
gfx::Size size) {
if (device_.get() &&
size.width() == device_->width() &&
size.height() == device_->height())
return;
device_ = skia::AdoptRef(new SkDevice(
SkBitmap::kARGB_8888_Config, size.width(), size.height(), true));
}
} // namespace webkit

@ -0,0 +1,34 @@
// 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 WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_SOFTWARE_OUTPUT_DEVICE_H_
#define WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_SOFTWARE_OUTPUT_DEVICE_H_
#include "base/logging.h"
#include "cc/software_output_device.h"
#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebImage.h"
#include "third_party/skia/include/core/SkDevice.h"
namespace webkit {
class WebCompositorSupportSoftwareOutputDevice
: public cc::SoftwareOutputDevice {
public:
WebCompositorSupportSoftwareOutputDevice();
virtual ~WebCompositorSupportSoftwareOutputDevice();
virtual WebKit::WebImage* Lock(bool forWrite) OVERRIDE;
virtual void Unlock() OVERRIDE;
virtual void DidChangeViewportSize(gfx::Size size) OVERRIDE;
private:
skia::RefPtr<SkDevice> device_;
WebKit::WebImage image_;
};
} // namespace webkit
#endif // WEBKIT_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_SOFTWARE_OUTPUT_DEVICE_H_

@ -236,9 +236,10 @@ void WebLayerTreeViewImpl::applyScrollAndScale(gfx::Vector2d scrollDelta, float
m_client->applyScrollAndScale(scrollDelta, pageScale);
}
scoped_ptr<WebCompositorOutputSurface> WebLayerTreeViewImpl::createOutputSurface()
scoped_ptr<cc::OutputSurface> WebLayerTreeViewImpl::createOutputSurface()
{
return scoped_ptr<WebCompositorOutputSurface>(m_client->createOutputSurface());
WebKit::WebCompositorOutputSurface* web = m_client->createOutputSurface();
return make_scoped_ptr(static_cast<cc::OutputSurface*>(web));
}
void WebLayerTreeViewImpl::didRecreateOutputSurface(bool success)

@ -61,7 +61,7 @@ public:
virtual void animate(double monotonicFrameBeginTime) OVERRIDE;
virtual void layout() OVERRIDE;
virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, float pageScale) OVERRIDE;
virtual scoped_ptr<WebCompositorOutputSurface> createOutputSurface() OVERRIDE;
virtual scoped_ptr<cc::OutputSurface> createOutputSurface() OVERRIDE;
virtual void didRecreateOutputSurface(bool success) OVERRIDE;
virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;
virtual void willCommit() OVERRIDE;

@ -8,7 +8,6 @@
#include "cc/proxy.h"
#include "cc/thread_impl.h"
#include "cc/test/compositor_fake_web_graphics_context_3d.h"
#include "cc/test/fake_web_compositor_output_surface.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.h"