// Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CC_TEST_FAKE_OUTPUT_SURFACE_H_ #define CC_TEST_FAKE_OUTPUT_SURFACE_H_ #include "base/time.h" #include "cc/output/compositor_frame.h" #include "cc/output/output_surface.h" #include "cc/output/software_output_device.h" #include "cc/test/test_web_graphics_context_3d.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" namespace cc { class FakeOutputSurface : public OutputSurface { public: virtual ~FakeOutputSurface(); static scoped_ptr Create3d( scoped_ptr context3d) { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); } static scoped_ptr Create3d() { scoped_ptr context3d = TestWebGraphicsContext3D::Create( WebKit::WebGraphicsContext3D::Attributes()) .PassAs(); return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), false)); } static scoped_ptr CreateSoftware( scoped_ptr software_device) { return make_scoped_ptr( new FakeOutputSurface(software_device.Pass(), false)); } static scoped_ptr CreateDelegating3d( scoped_ptr context3d) { return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); } static scoped_ptr CreateDelegating3d() { scoped_ptr context3d = TestWebGraphicsContext3D::Create( WebKit::WebGraphicsContext3D::Attributes()) .PassAs(); return make_scoped_ptr(new FakeOutputSurface(context3d.Pass(), true)); } static scoped_ptr CreateDelegatingSoftware( scoped_ptr software_device) { return make_scoped_ptr( new FakeOutputSurface(software_device.Pass(), true)); } virtual bool BindToClient(OutputSurfaceClient* client) OVERRIDE; virtual void SendFrameToParentCompositor(CompositorFrame* frame) OVERRIDE; CompositorFrame& last_sent_frame() { return last_sent_frame_; } size_t num_sent_frames() { return num_sent_frames_; } virtual void EnableVSyncNotification(bool enable) OVERRIDE; bool vsync_notification_enabled() const { return vsync_notification_enabled_; } void DidVSync(base::TimeTicks frame_time); private: FakeOutputSurface( scoped_ptr context3d, bool has_parent); FakeOutputSurface( scoped_ptr software_device, bool has_parent); CompositorFrame last_sent_frame_; size_t num_sent_frames_; bool vsync_notification_enabled_; }; static inline scoped_ptr CreateFakeOutputSurface() { return FakeOutputSurface::Create3d( TestWebGraphicsContext3D::Create( WebKit::WebGraphicsContext3D::Attributes()) .PassAs()).PassAs(); } } // namespace cc #endif // CC_TEST_FAKE_OUTPUT_SURFACE_H_