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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
/*
* 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 INC. 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 INC. 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 CCTiledLayerTestCommon_h
#define CCTiledLayerTestCommon_h
#include "CCGraphicsContext.h"
#include "CCPrioritizedTexture.h"
#include "CCResourceProvider.h"
#include "CCTextureUpdateQueue.h"
#include "CCTiledLayerImpl.h"
#include "IntRect.h"
#include "IntSize.h"
#include "LayerTextureUpdater.h"
#include "Region.h"
#include "TextureCopier.h"
#include "TextureUploader.h"
#include "TiledLayerChromium.h"
namespace WebKitTests {
class FakeTiledLayerChromium;
class FakeLayerTextureUpdater : public WebCore::LayerTextureUpdater {
public:
class Texture : public WebCore::LayerTextureUpdater::Texture {
public:
Texture(FakeLayerTextureUpdater*, PassOwnPtr<WebCore::CCPrioritizedTexture>);
virtual ~Texture();
virtual void updateRect(WebCore::CCResourceProvider* , const WebCore::IntRect&, const WebCore::IntSize&) OVERRIDE;
virtual void prepareRect(const WebCore::IntRect&, WebCore::CCRenderingStats&) OVERRIDE;
private:
FakeLayerTextureUpdater* m_layer;
};
FakeLayerTextureUpdater();
virtual ~FakeLayerTextureUpdater();
virtual PassOwnPtr<WebCore::LayerTextureUpdater::Texture> createTexture(WebCore::CCPrioritizedTextureManager*) OVERRIDE;
virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE;
virtual void prepareToUpdate(const WebCore::IntRect& contentRect, const WebCore::IntSize&, float, float, WebCore::IntRect& resultingOpaqueRect, WebCore::CCRenderingStats&) OVERRIDE;
// Sets the rect to invalidate during the next call to prepareToUpdate(). After the next
// call to prepareToUpdate() the rect is reset.
void setRectToInvalidate(const WebCore::IntRect&, FakeTiledLayerChromium*);
// Last rect passed to prepareToUpdate().
const WebCore::IntRect& lastUpdateRect() const { return m_lastUpdateRect; }
// Number of times prepareToUpdate has been invoked.
int prepareCount() const { return m_prepareCount; }
void clearPrepareCount() { m_prepareCount = 0; }
// Number of times updateRect has been invoked.
int updateCount() const { return m_updateCount; }
void clearUpdateCount() { m_updateCount = 0; }
void updateRect() { m_updateCount++; }
// Number of times prepareRect() has been invoked on a texture.
int prepareRectCount() const { return m_prepareRectCount; }
void clearPrepareRectCount() { m_prepareRectCount = 0; }
void prepareRect() { m_prepareRectCount++; }
void setOpaquePaintRect(const WebCore::IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; }
private:
int m_prepareCount;
int m_updateCount;
int m_prepareRectCount;
WebCore::IntRect m_rectToInvalidate;
WebCore::IntRect m_lastUpdateRect;
WebCore::IntRect m_opaquePaintRect;
RefPtr<FakeTiledLayerChromium> m_layer;
};
class FakeCCTiledLayerImpl : public WebCore::CCTiledLayerImpl {
public:
explicit FakeCCTiledLayerImpl(int id);
virtual ~FakeCCTiledLayerImpl();
using WebCore::CCTiledLayerImpl::hasTileAt;
using WebCore::CCTiledLayerImpl::hasTextureIdForTileAt;
};
class FakeTiledLayerChromium : public WebCore::TiledLayerChromium {
public:
explicit FakeTiledLayerChromium(WebCore::CCPrioritizedTextureManager*);
virtual ~FakeTiledLayerChromium();
static WebCore::IntSize tileSize() { return WebCore::IntSize(100, 100); }
using WebCore::TiledLayerChromium::invalidateContentRect;
using WebCore::TiledLayerChromium::needsIdlePaint;
using WebCore::TiledLayerChromium::skipsDraw;
using WebCore::TiledLayerChromium::numPaintedTiles;
using WebCore::TiledLayerChromium::idlePaintRect;
virtual void setNeedsDisplayRect(const WebCore::FloatRect&) OVERRIDE;
const WebCore::FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; }
virtual void setTexturePriorities(const WebCore::CCPriorityCalculator&) OVERRIDE;
virtual WebCore::CCPrioritizedTextureManager* textureManager() const OVERRIDE;
FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); }
WebCore::FloatRect updateRect() { return m_updateRect; }
protected:
virtual WebCore::LayerTextureUpdater* textureUpdater() const OVERRIDE;
virtual void createTextureUpdaterIfNeeded() OVERRIDE { }
private:
RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater;
WebCore::CCPrioritizedTextureManager* m_textureManager;
WebCore::FloatRect m_lastNeedsDisplayRect;
};
class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium {
public:
explicit FakeTiledLayerWithScaledBounds(WebCore::CCPrioritizedTextureManager*);
void setContentBounds(const WebCore::IntSize& contentBounds) { m_forcedContentBounds = contentBounds; }
virtual WebCore::IntSize contentBounds() const OVERRIDE;
protected:
WebCore::IntSize m_forcedContentBounds;
};
class FakeTextureCopier : public WebCore::TextureCopier {
public:
virtual void copyTexture(Parameters) OVERRIDE { }
virtual void flush() OVERRIDE { }
};
class FakeTextureUploader : public WebCore::TextureUploader {
public:
virtual bool isBusy() OVERRIDE;
virtual void beginUploads() OVERRIDE { }
virtual void endUploads() OVERRIDE { }
virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters upload) OVERRIDE;
};
}
#endif // CCTiledLayerTestCommon_h
|