blob: 203f8de7b6f8f8b5318add743936f1da34cd3a5f (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_H_
#define CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "content/common/content_export.h"
#include "ui/gfx/size.h"
#include "ui/gfx/surface/transport_dib.h"
class RenderProcessHost;
namespace gfx {
class Rect;
}
namespace content {
class RenderProcessHost;
class RenderWidgetHost;
}
namespace skia {
class PlatformCanvas;
}
// Represents a backing store for the pixels in a RenderWidgetHost.
class CONTENT_EXPORT BackingStore {
public:
virtual ~BackingStore();
content::RenderWidgetHost* render_widget_host() const {
return render_widget_host_;
}
const gfx::Size& size() { return size_; }
// The number of bytes that this backing store consumes. The default
// implementation just assumes there's 32 bits per pixel over the current
// size of the screen. Implementations may override this if they have more
// information about the color depth.
virtual size_t MemorySize();
// Paints the bitmap from the renderer onto the backing store. bitmap_rect
// gives the location of bitmap, and copy_rects specifies the subregion(s) of
// the backingstore to be painted from the bitmap.
//
// PaintToBackingStore does not need to guarantee that this has happened by
// the time it returns, in which case it will set |scheduled_callback| to
// true and will call |callback| when completed.
virtual void PaintToBackingStore(
content::RenderProcessHost* process,
TransportDIB::Id bitmap,
const gfx::Rect& bitmap_rect,
const std::vector<gfx::Rect>& copy_rects,
const base::Closure& completion_callback,
bool* scheduled_completion_callback) = 0;
// Extracts the gives subset of the backing store and copies it to the given
// PlatformCanvas. The PlatformCanvas should not be initialized. This function
// will call initialize() with the correct size. The return value indicates
// success.
virtual bool CopyFromBackingStore(const gfx::Rect& rect,
skia::PlatformCanvas* output) = 0;
// Scrolls the contents of clip_rect in the backing store by dx or dy (but dx
// and dy cannot both be non-zero).
virtual void ScrollBackingStore(int dx, int dy,
const gfx::Rect& clip_rect,
const gfx::Size& view_size) = 0;
protected:
// Can only be constructed via subclasses.
BackingStore(content::RenderWidgetHost* widget, const gfx::Size& size);
private:
// The owner of this backing store.
content::RenderWidgetHost* render_widget_host_;
// The size of the backing store.
gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(BackingStore);
};
#endif // CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_H_
|