| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_ | |
| 6 #define CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "skia/ext/refptr.h" | |
| 11 #include "third_party/skia/include/core/SkSurface.h" | |
| 12 #include "ui/gfx/geometry/rect.h" | |
| 13 #include "ui/gfx/geometry/size.h" | |
| 14 #include "ui/gfx/geometry/vector2d.h" | |
| 15 | |
| 16 class SkBitmap; | |
| 17 class SkCanvas; | |
| 18 | |
| 19 namespace gfx { | |
| 20 class VSyncProvider; | |
| 21 } | |
| 22 | |
| 23 namespace cc { | |
| 24 | |
| 25 class SoftwareFrameData; | |
| 26 | |
| 27 // This is a "tear-off" class providing software drawing support to | |
| 28 // OutputSurface, such as to a platform-provided window framebuffer. | |
| 29 class SoftwareOutputDevice { | |
| 30 public: | |
| 31 SoftwareOutputDevice(); | |
| 32 virtual ~SoftwareOutputDevice(); | |
| 33 | |
| 34 // Discards any pre-existing backing buffers and allocates memory for a | |
| 35 // software device of |size|. This must be called before the | |
| 36 // |SoftwareOutputDevice| can be used in other ways. | |
| 37 virtual void Resize(const gfx::Size& pixel_size, float scale_factor); | |
| 38 | |
| 39 // Called on BeginDrawingFrame. The compositor will draw into the returned | |
| 40 // SkCanvas. The |SoftwareOutputDevice| implementation needs to provide a | |
| 41 // valid SkCanvas of at least size |damage_rect|. This class retains ownership | |
| 42 // of the SkCanvas. | |
| 43 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect); | |
| 44 | |
| 45 // Called on FinishDrawingFrame. The compositor will no longer mutate the the | |
| 46 // SkCanvas instance returned by |BeginPaint| and should discard any reference | |
| 47 // that it holds to it. | |
| 48 virtual void EndPaint(SoftwareFrameData* frame_data); | |
| 49 | |
| 50 // Copies pixels inside |rect| from the current software framebuffer to | |
| 51 // |pixels|. Fails if there is no current softwareframebuffer. | |
| 52 virtual void CopyToPixels(const gfx::Rect& rect, void* pixels); | |
| 53 | |
| 54 // Blit the pixel content of the SoftwareOutputDevice by |delta| with the | |
| 55 // write clipped to |clip_rect|. | |
| 56 virtual void Scroll(const gfx::Vector2d& delta, const gfx::Rect& clip_rect); | |
| 57 | |
| 58 // Discard the backing buffer in the surface provided by this instance. | |
| 59 virtual void DiscardBackbuffer() {} | |
| 60 | |
| 61 // Ensures that there is a backing buffer available on this instance. | |
| 62 virtual void EnsureBackbuffer() {} | |
| 63 | |
| 64 // TODO(skaslev) Remove this after UberCompositor lands. | |
| 65 // Called in response to receiving a SwapBuffersAck. At this point, software | |
| 66 // frame identified by id can be reused or discarded as it is no longer being | |
| 67 // displayed. | |
| 68 virtual void ReclaimSoftwareFrame(unsigned id); | |
| 69 | |
| 70 // VSyncProvider used to update the timer used to schedule draws with the | |
| 71 // hardware vsync. Return NULL if a provider doesn't exist. | |
| 72 virtual gfx::VSyncProvider* GetVSyncProvider(); | |
| 73 | |
| 74 protected: | |
| 75 gfx::Size viewport_pixel_size_; | |
| 76 float scale_factor_; | |
| 77 gfx::Rect damage_rect_; | |
| 78 skia::RefPtr<SkSurface> surface_; | |
| 79 scoped_ptr<gfx::VSyncProvider> vsync_provider_; | |
| 80 | |
| 81 private: | |
| 82 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDevice); | |
| 83 }; | |
| 84 | |
| 85 } // namespace cc | |
| 86 | |
| 87 #endif // CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_ | |
| OLD | NEW |