OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 void WebGLRenderingContextBase::addToEvictedList( | 234 void WebGLRenderingContextBase::addToEvictedList( |
235 WebGLRenderingContextBase* context) { | 235 WebGLRenderingContextBase* context) { |
236 static int generation = 0; | 236 static int generation = 0; |
237 forciblyEvictedContexts().set(context, generation++); | 237 forciblyEvictedContexts().set(context, generation++); |
238 } | 238 } |
239 | 239 |
240 void WebGLRenderingContextBase::removeFromEvictedList( | 240 void WebGLRenderingContextBase::removeFromEvictedList( |
241 WebGLRenderingContextBase* context) { | 241 WebGLRenderingContextBase* context) { |
242 forciblyEvictedContexts().remove(context); | 242 forciblyEvictedContexts().erase(context); |
243 } | 243 } |
244 | 244 |
245 void WebGLRenderingContextBase::restoreEvictedContext( | 245 void WebGLRenderingContextBase::restoreEvictedContext( |
246 WebGLRenderingContextBase* context) { | 246 WebGLRenderingContextBase* context) { |
247 // These two sets keep weak references to their contexts; | 247 // These two sets keep weak references to their contexts; |
248 // verify that the GC already removed the |context| entries. | 248 // verify that the GC already removed the |context| entries. |
249 ASSERT(!forciblyEvictedContexts().contains(context)); | 249 ASSERT(!forciblyEvictedContexts().contains(context)); |
250 ASSERT(!activeContexts().contains(context)); | 250 ASSERT(!activeContexts().contains(context)); |
251 | 251 |
252 unsigned maxGLContexts = currentMaxGLContexts(); | 252 unsigned maxGLContexts = currentMaxGLContexts(); |
253 // Try to re-enable the oldest inactive contexts. | 253 // Try to re-enable the oldest inactive contexts. |
254 while (activeContexts().size() < maxGLContexts && | 254 while (activeContexts().size() < maxGLContexts && |
255 forciblyEvictedContexts().size()) { | 255 forciblyEvictedContexts().size()) { |
256 WebGLRenderingContextBase* evictedContext = oldestEvictedContext(); | 256 WebGLRenderingContextBase* evictedContext = oldestEvictedContext(); |
257 if (!evictedContext->m_restoreAllowed) { | 257 if (!evictedContext->m_restoreAllowed) { |
258 forciblyEvictedContexts().remove(evictedContext); | 258 forciblyEvictedContexts().erase(evictedContext); |
259 continue; | 259 continue; |
260 } | 260 } |
261 | 261 |
262 IntSize desiredSize = | 262 IntSize desiredSize = |
263 DrawingBuffer::adjustSize(evictedContext->clampedCanvasSize(), | 263 DrawingBuffer::adjustSize(evictedContext->clampedCanvasSize(), |
264 IntSize(), evictedContext->m_maxTextureSize); | 264 IntSize(), evictedContext->m_maxTextureSize); |
265 | 265 |
266 // If there's room in the pixel budget for this context, restore it. | 266 // If there's room in the pixel budget for this context, restore it. |
267 if (!desiredSize.isEmpty()) { | 267 if (!desiredSize.isEmpty()) { |
268 forciblyEvictedContexts().remove(evictedContext); | 268 forciblyEvictedContexts().erase(evictedContext); |
269 evictedContext->forceRestoreContext(); | 269 evictedContext->forceRestoreContext(); |
270 } | 270 } |
271 break; | 271 break; |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 namespace { | 275 namespace { |
276 | 276 |
277 GLint clamp(GLint value, GLint min, GLint max) { | 277 GLint clamp(GLint value, GLint min, GLint max) { |
278 if (value < min) | 278 if (value < min) |
(...skipping 7559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7838 | 7838 |
7839 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7839 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7840 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7840 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7841 if (canvas()) | 7841 if (canvas()) |
7842 result.setHTMLCanvasElement(canvas()); | 7842 result.setHTMLCanvasElement(canvas()); |
7843 else | 7843 else |
7844 result.setOffscreenCanvas(offscreenCanvas()); | 7844 result.setOffscreenCanvas(offscreenCanvas()); |
7845 } | 7845 } |
7846 | 7846 |
7847 } // namespace blink | 7847 } // namespace blink |
OLD | NEW |