OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/test/fake_web_graphics_context_3d.h" | 5 #include "cc/test/test_web_graphics_context_3d.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "gpu/GLES2/gl2extchromium.h" | 11 #include "gpu/GLES2/gl2extchromium.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/khronos/GLES2/gl2ext.h" | 13 #include "third_party/khronos/GLES2/gl2ext.h" |
14 | 14 |
15 using WebKit::WGC3Dboolean; | 15 using WebKit::WGC3Dboolean; |
16 using WebKit::WGC3Denum; | 16 using WebKit::WGC3Denum; |
17 using WebKit::WebGLId; | 17 using WebKit::WebGLId; |
18 using WebKit::WebGraphicsContext3D; | 18 using WebKit::WebGraphicsContext3D; |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
22 static const WebGLId kBufferId = 1; | 22 static const WebGLId kBufferId = 1; |
23 static const WebGLId kFramebufferId = 2; | 23 static const WebGLId kFramebufferId = 2; |
24 static const WebGLId kProgramId = 3; | 24 static const WebGLId kProgramId = 3; |
25 static const WebGLId kRenderbufferId = 4; | 25 static const WebGLId kRenderbufferId = 4; |
26 static const WebGLId kShaderId = 5; | 26 static const WebGLId kShaderId = 5; |
27 | 27 |
28 static unsigned s_context_id = 1; | 28 static unsigned s_context_id = 1; |
29 | 29 |
30 const WebGLId FakeWebGraphicsContext3D::kExternalTextureId = 1337; | 30 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; |
31 | 31 |
32 FakeWebGraphicsContext3D::FakeWebGraphicsContext3D() | 32 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
33 : context_id_(s_context_id++), | 33 : FakeWebGraphicsContext3D(), |
| 34 context_id_(s_context_id++), |
34 next_texture_id_(1), | 35 next_texture_id_(1), |
35 have_extension_io_surface_(false), | 36 have_extension_io_surface_(false), |
36 have_extension_egl_image_(false), | 37 have_extension_egl_image_(false), |
37 times_make_current_succeeds_(-1), | 38 times_make_current_succeeds_(-1), |
38 times_bind_texture_succeeds_(-1), | 39 times_bind_texture_succeeds_(-1), |
39 times_end_query_succeeds_(-1), | 40 times_end_query_succeeds_(-1), |
40 context_lost_(false), | 41 context_lost_(false), |
41 context_lost_callback_(NULL), | 42 context_lost_callback_(NULL), |
42 width_(0), | 43 width_(0), |
43 height_(0) { | 44 height_(0) { |
44 } | 45 } |
45 | 46 |
46 FakeWebGraphicsContext3D::FakeWebGraphicsContext3D( | 47 TestWebGraphicsContext3D::TestWebGraphicsContext3D( |
47 const WebGraphicsContext3D::Attributes& attributes) | 48 const WebGraphicsContext3D::Attributes& attributes) |
48 : context_id_(s_context_id++), | 49 : FakeWebGraphicsContext3D(), |
| 50 context_id_(s_context_id++), |
49 next_texture_id_(1), | 51 next_texture_id_(1), |
50 attributes_(attributes), | 52 attributes_(attributes), |
51 have_extension_io_surface_(false), | 53 have_extension_io_surface_(false), |
52 have_extension_egl_image_(false), | 54 have_extension_egl_image_(false), |
53 times_make_current_succeeds_(-1), | 55 times_make_current_succeeds_(-1), |
54 times_bind_texture_succeeds_(-1), | 56 times_bind_texture_succeeds_(-1), |
55 times_end_query_succeeds_(-1), | 57 times_end_query_succeeds_(-1), |
56 context_lost_(false), | 58 context_lost_(false), |
57 context_lost_callback_(NULL), | 59 context_lost_callback_(NULL), |
58 width_(0), | 60 width_(0), |
59 height_(0) { | 61 height_(0) { |
60 } | 62 } |
61 | 63 |
62 FakeWebGraphicsContext3D::~FakeWebGraphicsContext3D() { | 64 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
63 } | 65 } |
64 | 66 |
65 bool FakeWebGraphicsContext3D::makeContextCurrent() { | 67 bool TestWebGraphicsContext3D::makeContextCurrent() { |
66 if (times_make_current_succeeds_ >= 0) { | 68 if (times_make_current_succeeds_ >= 0) { |
67 if (!times_make_current_succeeds_) { | 69 if (!times_make_current_succeeds_) { |
68 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 70 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
69 GL_INNOCENT_CONTEXT_RESET_ARB); | 71 GL_INNOCENT_CONTEXT_RESET_ARB); |
70 } | 72 } |
71 --times_make_current_succeeds_; | 73 --times_make_current_succeeds_; |
72 } | 74 } |
73 return !context_lost_; | 75 return !context_lost_; |
74 } | 76 } |
75 | 77 |
76 int FakeWebGraphicsContext3D::width() { | 78 int TestWebGraphicsContext3D::width() { |
77 return width_; | 79 return width_; |
78 } | 80 } |
79 | 81 |
80 int FakeWebGraphicsContext3D::height() { | 82 int TestWebGraphicsContext3D::height() { |
81 return height_; | 83 return height_; |
82 } | 84 } |
83 | 85 |
84 void FakeWebGraphicsContext3D::reshape(int width, int height) { | 86 void TestWebGraphicsContext3D::reshape(int width, int height) { |
85 width_ = width; | 87 width_ = width; |
86 height_ = height; | 88 height_ = height; |
87 } | 89 } |
88 | 90 |
89 bool FakeWebGraphicsContext3D::isGLES2Compliant() { | 91 bool TestWebGraphicsContext3D::isContextLost() { |
90 return false; | |
91 } | |
92 | |
93 bool FakeWebGraphicsContext3D::readBackFramebuffer( | |
94 unsigned char* pixels, | |
95 size_t bufferSize, | |
96 WebGLId framebuffer, | |
97 int width, | |
98 int height) { | |
99 return false; | |
100 } | |
101 | |
102 WebGLId FakeWebGraphicsContext3D::getPlatformTextureId() { | |
103 return 0; | |
104 } | |
105 | |
106 bool FakeWebGraphicsContext3D::isContextLost() { | |
107 return context_lost_; | 92 return context_lost_; |
108 } | 93 } |
109 | 94 |
110 WGC3Denum FakeWebGraphicsContext3D::getGraphicsResetStatusARB() { | 95 WGC3Denum TestWebGraphicsContext3D::getGraphicsResetStatusARB() { |
111 return context_lost_ ? GL_UNKNOWN_CONTEXT_RESET_ARB : GL_NO_ERROR; | 96 return context_lost_ ? GL_UNKNOWN_CONTEXT_RESET_ARB : GL_NO_ERROR; |
112 } | 97 } |
113 | 98 |
114 void* FakeWebGraphicsContext3D::mapBufferSubDataCHROMIUM( | 99 WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( |
115 WGC3Denum target, | |
116 WebKit::WGC3Dintptr offset, | |
117 WebKit::WGC3Dsizeiptr size, | |
118 WGC3Denum access) { | |
119 return 0; | |
120 } | |
121 | |
122 void* FakeWebGraphicsContext3D::mapTexSubImage2DCHROMIUM( | |
123 WGC3Denum target, | |
124 WebKit::WGC3Dint level, | |
125 WebKit::WGC3Dint xoffset, | |
126 WebKit::WGC3Dint yoffset, | |
127 WebKit::WGC3Dsizei width, | |
128 WebKit::WGC3Dsizei height, | |
129 WGC3Denum format, | |
130 WGC3Denum type, | |
131 WGC3Denum access) { | |
132 return 0; | |
133 } | |
134 | |
135 WebKit::WebString FakeWebGraphicsContext3D::getRequestableExtensionsCHROMIUM() { | |
136 return WebKit::WebString(); | |
137 } | |
138 | |
139 WGC3Denum FakeWebGraphicsContext3D::checkFramebufferStatus( | |
140 WGC3Denum target) { | 100 WGC3Denum target) { |
141 if (context_lost_) | 101 if (context_lost_) |
142 return GL_FRAMEBUFFER_UNDEFINED_OES; | 102 return GL_FRAMEBUFFER_UNDEFINED_OES; |
143 return GL_FRAMEBUFFER_COMPLETE; | 103 return GL_FRAMEBUFFER_COMPLETE; |
144 } | 104 } |
145 | 105 |
146 bool FakeWebGraphicsContext3D::getActiveAttrib( | |
147 WebGLId program, | |
148 WebKit::WGC3Duint index, | |
149 ActiveInfo&) { | |
150 return false; | |
151 } | |
152 | |
153 bool FakeWebGraphicsContext3D::getActiveUniform( | |
154 WebGLId program, | |
155 WebKit::WGC3Duint index, | |
156 ActiveInfo&) { | |
157 return false; | |
158 } | |
159 | |
160 WebKit::WGC3Dint FakeWebGraphicsContext3D::getAttribLocation( | |
161 WebGLId program, | |
162 const WebKit::WGC3Dchar* name) { | |
163 return 0; | |
164 } | |
165 | |
166 WebGraphicsContext3D::Attributes | 106 WebGraphicsContext3D::Attributes |
167 FakeWebGraphicsContext3D::getContextAttributes() { | 107 TestWebGraphicsContext3D::getContextAttributes() { |
168 return attributes_; | 108 return attributes_; |
169 } | 109 } |
170 | 110 |
171 WGC3Denum FakeWebGraphicsContext3D::getError() { | 111 WebKit::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { |
172 return 0; | |
173 } | |
174 | |
175 void FakeWebGraphicsContext3D::getIntegerv( | |
176 WGC3Denum pname, | |
177 WebKit::WGC3Dint* value) { | |
178 if (pname == GL_MAX_TEXTURE_SIZE) | |
179 *value = 1024; | |
180 } | |
181 | |
182 void FakeWebGraphicsContext3D::getProgramiv( | |
183 WebGLId program, | |
184 WGC3Denum pname, | |
185 WebKit::WGC3Dint* value) { | |
186 if (pname == GL_LINK_STATUS) | |
187 *value = 1; | |
188 } | |
189 | |
190 WebKit::WebString FakeWebGraphicsContext3D::getProgramInfoLog( | |
191 WebGLId program) { | |
192 return WebKit::WebString(); | |
193 } | |
194 | |
195 void FakeWebGraphicsContext3D::getShaderiv( | |
196 WebGLId shader, | |
197 WGC3Denum pname, | |
198 WebKit::WGC3Dint* value) { | |
199 if (pname == GL_COMPILE_STATUS) | |
200 *value = 1; | |
201 } | |
202 | |
203 WebKit::WebString FakeWebGraphicsContext3D::getShaderInfoLog( | |
204 WebGLId shader) { | |
205 return WebKit::WebString(); | |
206 } | |
207 | |
208 WebKit::WebString FakeWebGraphicsContext3D::getShaderSource( | |
209 WebGLId shader) { | |
210 return WebKit::WebString(); | |
211 } | |
212 | |
213 WebKit::WebString FakeWebGraphicsContext3D::getString(WGC3Denum name) { | |
214 std::string string; | 112 std::string string; |
215 | 113 |
216 if (name == GL_EXTENSIONS) { | 114 if (name == GL_EXTENSIONS) { |
217 if (have_extension_io_surface_) | 115 if (have_extension_io_surface_) |
218 string += "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle "; | 116 string += "GL_CHROMIUM_iosurface GL_ARB_texture_rectangle "; |
219 if (have_extension_egl_image_) | 117 if (have_extension_egl_image_) |
220 string += "GL_OES_EGL_image_external"; | 118 string += "GL_OES_EGL_image_external"; |
221 } | 119 } |
222 | 120 |
223 return WebKit::WebString::fromUTF8(string.c_str()); | 121 return WebKit::WebString::fromUTF8(string.c_str()); |
224 } | 122 } |
225 | 123 |
226 WebKit::WGC3Dint FakeWebGraphicsContext3D::getUniformLocation( | 124 WebKit::WGC3Dint TestWebGraphicsContext3D::getUniformLocation( |
227 WebGLId program, | 125 WebGLId program, |
228 const WebKit::WGC3Dchar* name) { | 126 const WebKit::WGC3Dchar* name) { |
229 return 0; | 127 return 0; |
230 } | 128 } |
231 | 129 |
232 WebKit::WGC3Dsizeiptr FakeWebGraphicsContext3D::getVertexAttribOffset( | 130 WebKit::WGC3Dsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset( |
233 WebKit::WGC3Duint index, | 131 WebKit::WGC3Duint index, |
234 WGC3Denum pname) { | 132 WGC3Denum pname) { |
235 return 0; | 133 return 0; |
236 } | 134 } |
237 | 135 |
238 WGC3Dboolean FakeWebGraphicsContext3D::isBuffer( | 136 WGC3Dboolean TestWebGraphicsContext3D::isBuffer( |
239 WebGLId buffer) { | 137 WebGLId buffer) { |
240 return false; | 138 return false; |
241 } | 139 } |
242 | 140 |
243 WGC3Dboolean FakeWebGraphicsContext3D::isEnabled( | 141 WGC3Dboolean TestWebGraphicsContext3D::isEnabled( |
244 WGC3Denum cap) { | 142 WGC3Denum cap) { |
245 return false; | 143 return false; |
246 } | 144 } |
247 | 145 |
248 WGC3Dboolean FakeWebGraphicsContext3D::isFramebuffer( | 146 WGC3Dboolean TestWebGraphicsContext3D::isFramebuffer( |
249 WebGLId framebuffer) { | 147 WebGLId framebuffer) { |
250 return false; | 148 return false; |
251 } | 149 } |
252 | 150 |
253 WGC3Dboolean FakeWebGraphicsContext3D::isProgram( | 151 WGC3Dboolean TestWebGraphicsContext3D::isProgram( |
254 WebGLId program) { | 152 WebGLId program) { |
255 return false; | 153 return false; |
256 } | 154 } |
257 | 155 |
258 WGC3Dboolean FakeWebGraphicsContext3D::isRenderbuffer( | 156 WGC3Dboolean TestWebGraphicsContext3D::isRenderbuffer( |
259 WebGLId renderbuffer) { | 157 WebGLId renderbuffer) { |
260 return false; | 158 return false; |
261 } | 159 } |
262 | 160 |
263 WGC3Dboolean FakeWebGraphicsContext3D::isShader( | 161 WGC3Dboolean TestWebGraphicsContext3D::isShader( |
264 WebGLId shader) { | 162 WebGLId shader) { |
265 return false; | 163 return false; |
266 } | 164 } |
267 | 165 |
268 WGC3Dboolean FakeWebGraphicsContext3D::isTexture( | 166 WGC3Dboolean TestWebGraphicsContext3D::isTexture( |
269 WebGLId texture) { | 167 WebGLId texture) { |
270 return false; | 168 return false; |
271 } | 169 } |
272 | 170 |
273 WebGLId FakeWebGraphicsContext3D::createBuffer() { | 171 WebGLId TestWebGraphicsContext3D::createBuffer() { |
274 return kBufferId | context_id_ << 16; | 172 return kBufferId | context_id_ << 16; |
275 } | 173 } |
276 | 174 |
277 void FakeWebGraphicsContext3D::deleteBuffer(WebKit::WebGLId id) { | 175 void TestWebGraphicsContext3D::deleteBuffer(WebKit::WebGLId id) { |
278 EXPECT_EQ(kBufferId | context_id_ << 16, id); | 176 EXPECT_EQ(kBufferId | context_id_ << 16, id); |
279 } | 177 } |
280 | 178 |
281 WebGLId FakeWebGraphicsContext3D::createFramebuffer() { | 179 WebGLId TestWebGraphicsContext3D::createFramebuffer() { |
282 return kFramebufferId | context_id_ << 16; | 180 return kFramebufferId | context_id_ << 16; |
283 } | 181 } |
284 | 182 |
285 void FakeWebGraphicsContext3D::deleteFramebuffer(WebKit::WebGLId id) { | 183 void TestWebGraphicsContext3D::deleteFramebuffer(WebKit::WebGLId id) { |
286 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); | 184 EXPECT_EQ(kFramebufferId | context_id_ << 16, id); |
287 } | 185 } |
288 | 186 |
289 WebGLId FakeWebGraphicsContext3D::createProgram() { | 187 WebGLId TestWebGraphicsContext3D::createProgram() { |
290 return kProgramId | context_id_ << 16; | 188 return kProgramId | context_id_ << 16; |
291 } | 189 } |
292 | 190 |
293 void FakeWebGraphicsContext3D::deleteProgram(WebKit::WebGLId id) { | 191 void TestWebGraphicsContext3D::deleteProgram(WebKit::WebGLId id) { |
294 EXPECT_EQ(kProgramId | context_id_ << 16, id); | 192 EXPECT_EQ(kProgramId | context_id_ << 16, id); |
295 } | 193 } |
296 | 194 |
297 WebGLId FakeWebGraphicsContext3D::createRenderbuffer() { | 195 WebGLId TestWebGraphicsContext3D::createRenderbuffer() { |
298 return kRenderbufferId | context_id_ << 16; | 196 return kRenderbufferId | context_id_ << 16; |
299 } | 197 } |
300 | 198 |
301 void FakeWebGraphicsContext3D::deleteRenderbuffer(WebKit::WebGLId id) { | 199 void TestWebGraphicsContext3D::deleteRenderbuffer(WebKit::WebGLId id) { |
302 EXPECT_EQ(kRenderbufferId | context_id_ << 16, id); | 200 EXPECT_EQ(kRenderbufferId | context_id_ << 16, id); |
303 } | 201 } |
304 | 202 |
305 WebGLId FakeWebGraphicsContext3D::createShader(WGC3Denum) { | 203 WebGLId TestWebGraphicsContext3D::createShader(WGC3Denum) { |
306 return kShaderId | context_id_ << 16; | 204 return kShaderId | context_id_ << 16; |
307 } | 205 } |
308 | 206 |
309 void FakeWebGraphicsContext3D::deleteShader(WebKit::WebGLId id) { | 207 void TestWebGraphicsContext3D::deleteShader(WebKit::WebGLId id) { |
310 EXPECT_EQ(kShaderId | context_id_ << 16, id); | 208 EXPECT_EQ(kShaderId | context_id_ << 16, id); |
311 } | 209 } |
312 | 210 |
313 WebGLId FakeWebGraphicsContext3D::createTexture() { | 211 WebGLId TestWebGraphicsContext3D::createTexture() { |
314 WebGLId texture_id = NextTextureId(); | 212 WebGLId texture_id = NextTextureId(); |
315 DCHECK_NE(texture_id, kExternalTextureId); | 213 DCHECK_NE(texture_id, kExternalTextureId); |
316 textures_.push_back(texture_id); | 214 textures_.push_back(texture_id); |
317 return texture_id; | 215 return texture_id; |
318 } | 216 } |
319 | 217 |
320 void FakeWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { | 218 void TestWebGraphicsContext3D::deleteTexture(WebGLId texture_id) { |
321 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 219 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != |
322 textures_.end()); | 220 textures_.end()); |
323 textures_.erase(std::find(textures_.begin(), textures_.end(), texture_id)); | 221 textures_.erase(std::find(textures_.begin(), textures_.end(), texture_id)); |
324 } | 222 } |
325 | 223 |
326 void FakeWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { | 224 void TestWebGraphicsContext3D::attachShader(WebGLId program, WebGLId shader) { |
327 EXPECT_EQ(kProgramId | context_id_ << 16, program); | 225 EXPECT_EQ(kProgramId | context_id_ << 16, program); |
328 EXPECT_EQ(kShaderId | context_id_ << 16, shader); | 226 EXPECT_EQ(kShaderId | context_id_ << 16, shader); |
329 } | 227 } |
330 | 228 |
331 void FakeWebGraphicsContext3D::useProgram(WebGLId program) { | 229 void TestWebGraphicsContext3D::useProgram(WebGLId program) { |
332 if (!program) | 230 if (!program) |
333 return; | 231 return; |
334 EXPECT_EQ(kProgramId | context_id_ << 16, program); | 232 EXPECT_EQ(kProgramId | context_id_ << 16, program); |
335 } | 233 } |
336 | 234 |
337 void FakeWebGraphicsContext3D::bindBuffer(WGC3Denum target, WebGLId buffer) { | 235 void TestWebGraphicsContext3D::bindBuffer(WGC3Denum target, WebGLId buffer) { |
338 if (!buffer) | 236 if (!buffer) |
339 return; | 237 return; |
340 EXPECT_EQ(kBufferId | context_id_ << 16, buffer); | 238 EXPECT_EQ(kBufferId | context_id_ << 16, buffer); |
341 } | 239 } |
342 | 240 |
343 void FakeWebGraphicsContext3D::bindFramebuffer( | 241 void TestWebGraphicsContext3D::bindFramebuffer( |
344 WGC3Denum target, WebGLId framebuffer) { | 242 WGC3Denum target, WebGLId framebuffer) { |
345 if (!framebuffer) | 243 if (!framebuffer) |
346 return; | 244 return; |
347 EXPECT_EQ(kFramebufferId | context_id_ << 16, framebuffer); | 245 EXPECT_EQ(kFramebufferId | context_id_ << 16, framebuffer); |
348 } | 246 } |
349 | 247 |
350 void FakeWebGraphicsContext3D::bindRenderbuffer( | 248 void TestWebGraphicsContext3D::bindRenderbuffer( |
351 WGC3Denum target, WebGLId renderbuffer) { | 249 WGC3Denum target, WebGLId renderbuffer) { |
352 if (!renderbuffer) | 250 if (!renderbuffer) |
353 return; | 251 return; |
354 EXPECT_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); | 252 EXPECT_EQ(kRenderbufferId | context_id_ << 16, renderbuffer); |
355 } | 253 } |
356 | 254 |
357 void FakeWebGraphicsContext3D::bindTexture( | 255 void TestWebGraphicsContext3D::bindTexture( |
358 WGC3Denum target, WebGLId texture_id) { | 256 WGC3Denum target, WebGLId texture_id) { |
359 if (times_bind_texture_succeeds_ >= 0) { | 257 if (times_bind_texture_succeeds_ >= 0) { |
360 if (!times_bind_texture_succeeds_) { | 258 if (!times_bind_texture_succeeds_) { |
361 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 259 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
362 GL_INNOCENT_CONTEXT_RESET_ARB); | 260 GL_INNOCENT_CONTEXT_RESET_ARB); |
363 } | 261 } |
364 --times_bind_texture_succeeds_; | 262 --times_bind_texture_succeeds_; |
365 } | 263 } |
366 | 264 |
367 if (!texture_id) | 265 if (!texture_id) |
368 return; | 266 return; |
369 if (texture_id == kExternalTextureId) | 267 if (texture_id == kExternalTextureId) |
370 return; | 268 return; |
371 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != | 269 DCHECK(std::find(textures_.begin(), textures_.end(), texture_id) != |
372 textures_.end()); | 270 textures_.end()); |
373 used_textures_.insert(texture_id); | 271 used_textures_.insert(texture_id); |
374 } | 272 } |
375 | 273 |
376 WebGLId FakeWebGraphicsContext3D::createQueryEXT() { | 274 void TestWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) { |
377 return 1; | |
378 } | |
379 | |
380 WGC3Dboolean FakeWebGraphicsContext3D::isQueryEXT(WebGLId query) { | |
381 return true; | |
382 } | |
383 | |
384 void FakeWebGraphicsContext3D::endQueryEXT(WebKit::WGC3Denum target) { | |
385 if (times_end_query_succeeds_ >= 0) { | 275 if (times_end_query_succeeds_ >= 0) { |
386 if (!times_end_query_succeeds_) { | 276 if (!times_end_query_succeeds_) { |
387 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 277 loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
388 GL_INNOCENT_CONTEXT_RESET_ARB); | 278 GL_INNOCENT_CONTEXT_RESET_ARB); |
389 } | 279 } |
390 --times_end_query_succeeds_; | 280 --times_end_query_succeeds_; |
391 } | 281 } |
392 } | 282 } |
393 | 283 |
394 void FakeWebGraphicsContext3D::getQueryObjectuivEXT( | 284 void TestWebGraphicsContext3D::getQueryObjectuivEXT( |
395 WebKit::WebGLId query, | 285 WebKit::WebGLId query, |
396 WebKit::WGC3Denum pname, | 286 WebKit::WGC3Denum pname, |
397 WebKit::WGC3Duint* params) { | 287 WebKit::WGC3Duint* params) { |
398 // If the context is lost, behave as if result is available. | 288 // If the context is lost, behave as if result is available. |
399 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) | 289 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) |
400 *params = 1; | 290 *params = 1; |
401 } | 291 } |
402 | 292 |
403 void FakeWebGraphicsContext3D::setContextLostCallback( | 293 void TestWebGraphicsContext3D::setContextLostCallback( |
404 WebGraphicsContextLostCallback* callback) { | 294 WebGraphicsContextLostCallback* callback) { |
405 context_lost_callback_ = callback; | 295 context_lost_callback_ = callback; |
406 } | 296 } |
407 | 297 |
408 void FakeWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, | 298 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, |
409 WGC3Denum other) { | 299 WGC3Denum other) { |
410 if (context_lost_) | 300 if (context_lost_) |
411 return; | 301 return; |
412 context_lost_ = true; | 302 context_lost_ = true; |
413 if (context_lost_callback_) | 303 if (context_lost_callback_) |
414 context_lost_callback_->onContextLost(); | 304 context_lost_callback_->onContextLost(); |
415 } | 305 } |
416 | 306 |
417 WebKit::WebGLId FakeWebGraphicsContext3D::NextTextureId() { | 307 WebKit::WebGLId TestWebGraphicsContext3D::NextTextureId() { |
418 WebGLId texture_id = next_texture_id_++; | 308 WebGLId texture_id = next_texture_id_++; |
419 DCHECK(texture_id < (1 << 16)); | 309 DCHECK(texture_id < (1 << 16)); |
420 texture_id |= context_id_ << 16; | 310 texture_id |= context_id_ << 16; |
421 return texture_id; | 311 return texture_id; |
422 } | 312 } |
423 | 313 |
424 } // namespace cc | 314 } // namespace cc |
OLD | NEW |