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 #include "config.h" | |
6 | |
7 #include "CCTiledLayerTestCommon.h" | |
8 | |
9 using namespace cc; | |
10 | |
11 namespace WebKitTests { | |
12 | |
13 FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, scoped
_ptr<CCPrioritizedTexture> texture) | |
14 : LayerTextureUpdater::Texture(texture.Pass()) | |
15 , m_layer(layer) | |
16 { | |
17 } | |
18 | |
19 FakeLayerTextureUpdater::Texture::~Texture() | |
20 { | |
21 } | |
22 | |
23 void FakeLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourcePr
ovider, const IntRect&, const IntSize&) | |
24 { | |
25 texture()->acquireBackingTexture(resourceProvider); | |
26 m_layer->updateRect(); | |
27 } | |
28 | |
29 void FakeLayerTextureUpdater::Texture::prepareRect(const IntRect&, cc::CCRenderi
ngStats&) | |
30 { | |
31 m_layer->prepareRect(); | |
32 } | |
33 | |
34 FakeLayerTextureUpdater::FakeLayerTextureUpdater() | |
35 : m_prepareCount(0) | |
36 , m_updateCount(0) | |
37 , m_prepareRectCount(0) | |
38 { | |
39 } | |
40 | |
41 FakeLayerTextureUpdater::~FakeLayerTextureUpdater() | |
42 { | |
43 } | |
44 | |
45 void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const
IntSize&, float, float, IntRect& resultingOpaqueRect, CCRenderingStats&) | |
46 { | |
47 m_prepareCount++; | |
48 m_lastUpdateRect = contentRect; | |
49 if (!m_rectToInvalidate.isEmpty()) { | |
50 m_layer->invalidateContentRect(m_rectToInvalidate); | |
51 m_rectToInvalidate = IntRect(); | |
52 m_layer = NULL; | |
53 } | |
54 resultingOpaqueRect = m_opaquePaintRect; | |
55 } | |
56 | |
57 void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiled
LayerChromium* layer) | |
58 { | |
59 m_rectToInvalidate = rect; | |
60 m_layer = layer; | |
61 } | |
62 | |
63 PassOwnPtr<LayerTextureUpdater::Texture> FakeLayerTextureUpdater::createTexture(
CCPrioritizedTextureManager* manager) | |
64 { | |
65 return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager))); | |
66 } | |
67 | |
68 LayerTextureUpdater::SampledTexelFormat FakeLayerTextureUpdater::sampledTexelFor
mat(GC3Denum) | |
69 { | |
70 return SampledTexelFormatRGBA; | |
71 } | |
72 | |
73 FakeCCTiledLayerImpl::FakeCCTiledLayerImpl(int id) | |
74 : CCTiledLayerImpl(id) | |
75 { | |
76 } | |
77 | |
78 FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl() | |
79 { | |
80 } | |
81 | |
82 FakeTiledLayerChromium::FakeTiledLayerChromium(CCPrioritizedTextureManager* text
ureManager) | |
83 : TiledLayerChromium() | |
84 , m_fakeTextureUpdater(adoptRef(new FakeLayerTextureUpdater)) | |
85 , m_textureManager(textureManager) | |
86 { | |
87 setTileSize(tileSize()); | |
88 setTextureFormat(GraphicsContext3D::RGBA); | |
89 setBorderTexelOption(CCLayerTilingData::NoBorderTexels); | |
90 setIsDrawable(true); // So that we don't get false positives if any of these
tests expect to return false from drawsContent() for other reasons. | |
91 } | |
92 | |
93 FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(CCPrioritizedText
ureManager* textureManager) | |
94 : FakeTiledLayerChromium(textureManager) | |
95 { | |
96 } | |
97 | |
98 FakeTiledLayerWithScaledBounds::~FakeTiledLayerWithScaledBounds() | |
99 { | |
100 } | |
101 | |
102 FakeTiledLayerChromium::~FakeTiledLayerChromium() | |
103 { | |
104 } | |
105 | |
106 void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect) | |
107 { | |
108 m_lastNeedsDisplayRect = rect; | |
109 TiledLayerChromium::setNeedsDisplayRect(rect); | |
110 } | |
111 | |
112 void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& ca
lculator) | |
113 { | |
114 // Ensure there is always a target render surface available. If none has bee
n | |
115 // set (the layer is an orphan for the test), then just set a surface on its
elf. | |
116 bool missingTargetRenderSurface = !renderTarget(); | |
117 | |
118 if (missingTargetRenderSurface) | |
119 createRenderSurface(); | |
120 | |
121 TiledLayerChromium::setTexturePriorities(calculator); | |
122 | |
123 if (missingTargetRenderSurface) { | |
124 clearRenderSurface(); | |
125 setRenderTarget(0); | |
126 } | |
127 } | |
128 | |
129 cc::CCPrioritizedTextureManager* FakeTiledLayerChromium::textureManager() const | |
130 { | |
131 return m_textureManager; | |
132 } | |
133 | |
134 cc::LayerTextureUpdater* FakeTiledLayerChromium::textureUpdater() const | |
135 { | |
136 return m_fakeTextureUpdater.get(); | |
137 } | |
138 | |
139 cc::IntSize FakeTiledLayerWithScaledBounds::contentBounds() const | |
140 { | |
141 return m_forcedContentBounds; | |
142 } | |
143 | |
144 size_t FakeTextureUploader::numBlockingUploads() | |
145 { | |
146 return 0; | |
147 } | |
148 | |
149 void FakeTextureUploader::markPendingUploadsAsNonBlocking() | |
150 { | |
151 } | |
152 | |
153 void FakeTextureUploader::uploadTexture(cc::CCResourceProvider* resourceProvider
, Parameters upload) | |
154 { | |
155 upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destO
ffset); | |
156 } | |
157 | |
158 double FakeTextureUploader::estimatedTexturesPerSecond() | |
159 { | |
160 return std::numeric_limits<double>::max(); | |
161 } | |
162 | |
163 } // namespace | |
OLD | NEW |