Move DidStartLoading, DidStopLoading, DidChangeLoadProgress IPCs to RFHI.
[chromium-blink-merge.git] / cc / output / software_output_device.h
blob89ab00524c5d65fe809c307387c7b402eb99ab30
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"
17 class SkBitmap;
18 class SkCanvas;
20 namespace gfx {
21 class VSyncProvider;
24 namespace cc {
26 class SoftwareFrameData;
28 // This is a "tear-off" class providing software drawing support to
29 // OutputSurface, such as to a platform-provided window framebuffer.
30 class CC_EXPORT SoftwareOutputDevice {
31 public:
32 SoftwareOutputDevice();
33 virtual ~SoftwareOutputDevice();
35 // Discards any pre-existing backing buffers and allocates memory for a
36 // software device of |size|. This must be called before the
37 // |SoftwareOutputDevice| can be used in other ways.
38 virtual void Resize(const gfx::Size& pixel_size, float scale_factor);
40 // Called on BeginDrawingFrame. The compositor will draw into the returned
41 // SkCanvas. The |SoftwareOutputDevice| implementation needs to provide a
42 // valid SkCanvas of at least size |damage_rect|. This class retains ownership
43 // of the SkCanvas.
44 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect);
46 // Called on FinishDrawingFrame. The compositor will no longer mutate the the
47 // SkCanvas instance returned by |BeginPaint| and should discard any reference
48 // that it holds to it.
49 virtual void EndPaint(SoftwareFrameData* frame_data);
51 // Copies pixels inside |rect| from the current software framebuffer to
52 // |pixels|. Fails if there is no current softwareframebuffer.
53 virtual void CopyToPixels(const gfx::Rect& rect, void* pixels);
55 // Blit the pixel content of the SoftwareOutputDevice by |delta| with the
56 // write clipped to |clip_rect|.
57 virtual void Scroll(const gfx::Vector2d& delta, const gfx::Rect& clip_rect);
59 // Discard the backing buffer in the surface provided by this instance.
60 virtual void DiscardBackbuffer() {}
62 // Ensures that there is a backing buffer available on this instance.
63 virtual void EnsureBackbuffer() {}
65 // TODO(skaslev) Remove this after UberCompositor lands.
66 // Called in response to receiving a SwapBuffersAck. At this point, software
67 // frame identified by id can be reused or discarded as it is no longer being
68 // displayed.
69 virtual void ReclaimSoftwareFrame(unsigned id);
71 // VSyncProvider used to update the timer used to schedule draws with the
72 // hardware vsync. Return NULL if a provider doesn't exist.
73 virtual gfx::VSyncProvider* GetVSyncProvider();
75 protected:
76 gfx::Size viewport_pixel_size_;
77 float scale_factor_;
78 gfx::Rect damage_rect_;
79 skia::RefPtr<SkSurface> surface_;
80 scoped_ptr<gfx::VSyncProvider> vsync_provider_;
82 private:
83 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDevice);
86 } // namespace cc
88 #endif // CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_