summaryrefslogtreecommitdiffstats
path: root/cc/output/software_output_device.h
blob: fbada745a0aa1b7bd9ceed2fd4c628fc717fe8de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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_SOFTWARE_OUTPUT_DEVICE_H_
#define CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_

#include "base/basictypes.h"
#include "cc/base/cc_export.h"
#include "skia/ext/refptr.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/gfx/vector2d.h"

class SkBitmap;
class SkDevice;
class SkCanvas;

namespace cc {

class SoftwareFrameData;

// This is a "tear-off" class providing software drawing support to
// OutputSurface, such as to a platform-provided window framebuffer.
class CC_EXPORT SoftwareOutputDevice {
 public:
  SoftwareOutputDevice();
  virtual ~SoftwareOutputDevice();

  // SoftwareOutputDevice implementation.
  virtual void Resize(gfx::Size size);

  virtual SkCanvas* BeginPaint(gfx::Rect damage_rect);
  virtual void EndPaint(SoftwareFrameData* frame_data);

  virtual void CopyToBitmap(gfx::Rect rect, SkBitmap* output);
  virtual void Scroll(gfx::Vector2d delta,
                      gfx::Rect clip_rect);

  // TODO(skaslev) Remove this after UberCompositor lands.
  virtual void ReclaimSoftwareFrame(unsigned id);

 protected:
  gfx::Size viewport_size_;
  gfx::Rect damage_rect_;
  skia::RefPtr<SkDevice> device_;
  skia::RefPtr<SkCanvas> canvas_;

 private:
  DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDevice);
};

}  // namespace cc

#endif  // CC_OUTPUT_SOFTWARE_OUTPUT_DEVICE_H_