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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CCRenderer_h
#define CCRenderer_h
#include "FloatQuad.h"
#include "IntRect.h"
#include "cc/CCLayerTreeHost.h"
#include "cc/CCRenderPass.h"
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class CCScopedTexture;
class TextureCopier;
class TextureUploader;
enum TextureUploaderOption { ThrottledUploader, UnthrottledUploader };
class CCRendererClient {
public:
virtual const IntSize& deviceViewportSize() const = 0;
virtual const CCLayerTreeSettings& settings() const = 0;
virtual void didLoseContext() = 0;
virtual void onSwapBuffersComplete() = 0;
virtual void releaseContentsTextures() = 0;
virtual void setFullRootLayerDamage() = 0;
virtual void setMemoryAllocationLimitBytes(size_t) = 0;
protected:
virtual ~CCRendererClient() { }
};
class CCRenderer {
WTF_MAKE_NONCOPYABLE(CCRenderer);
public:
// This enum defines the various resource pools for the CCResourceProvider
// where textures get allocated.
enum ResourcePool {
ImplPool = 1, // This pool is for textures that get allocated on the impl thread (e.g. RenderSurfaces).
ContentPool // This pool is for textures that get allocated on the main thread (e.g. tiles).
};
virtual ~CCRenderer() { }
virtual const LayerRendererCapabilities& capabilities() const = 0;
const CCLayerTreeSettings& settings() const { return m_client->settings(); }
const IntSize& viewportSize() { return m_client->deviceViewportSize(); }
int viewportWidth() { return viewportSize().width(); }
int viewportHeight() { return viewportSize().height(); }
virtual void viewportChanged() { }
virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) { }
virtual bool haveCachedResourcesForRenderPassId(int) const { return false; }
virtual void drawFrame(const CCRenderPassList&, const CCRenderPassIdHashMap&) = 0;
// waits for rendering to finish
virtual void finish() = 0;
virtual void doNoOp() { }
// puts backbuffer onscreen
virtual bool swapBuffers() = 0;
virtual void getFramebufferPixels(void *pixels, const IntRect&) = 0;
virtual TextureCopier* textureCopier() const = 0;
virtual TextureUploader* textureUploader() const = 0;
virtual bool isContextLost() { return false; }
virtual void setVisible(bool) = 0;
protected:
explicit CCRenderer(CCRendererClient* client)
: m_client(client)
{
}
CCRendererClient* m_client;
};
}
#endif // CCRenderer_h
|