1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_
6 #define CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h"
11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkSurface.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/geometry/vector2d.h"
26 // This is a "tear-off" class providing software drawing support to
27 // OutputSurface, such as to a platform-provided window framebuffer.
28 class CC_EXPORT SoftwareOutputDevice
{
30 SoftwareOutputDevice();
31 virtual ~SoftwareOutputDevice();
33 // Discards any pre-existing backing buffers and allocates memory for a
34 // software device of |size|. This must be called before the
35 // |SoftwareOutputDevice| can be used in other ways.
36 virtual void Resize(const gfx::Size
& pixel_size
, float scale_factor
);
38 // Called on BeginDrawingFrame. The compositor will draw into the returned
39 // SkCanvas. The |SoftwareOutputDevice| implementation needs to provide a
40 // valid SkCanvas of at least size |damage_rect|. This class retains ownership
42 virtual SkCanvas
* BeginPaint(const gfx::Rect
& damage_rect
);
44 // Called on FinishDrawingFrame. The compositor will no longer mutate the the
45 // SkCanvas instance returned by |BeginPaint| and should discard any reference
46 // that it holds to it.
47 virtual void EndPaint();
49 // Discard the backing buffer in the surface provided by this instance.
50 virtual void DiscardBackbuffer() {}
52 // Ensures that there is a backing buffer available on this instance.
53 virtual void EnsureBackbuffer() {}
55 // VSyncProvider used to update the timer used to schedule draws with the
56 // hardware vsync. Return NULL if a provider doesn't exist.
57 virtual gfx::VSyncProvider
* GetVSyncProvider();
60 gfx::Size viewport_pixel_size_
;
62 gfx::Rect damage_rect_
;
63 skia::RefPtr
<SkSurface
> surface_
;
64 scoped_ptr
<gfx::VSyncProvider
> vsync_provider_
;
67 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDevice
);
72 #endif // CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_