Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLSharedObject.cpp

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "modules/webgl/WebGLSharedObject.h" 26 #include "modules/webgl/WebGLSharedObject.h"
27 27
28 #include "modules/webgl/WebGLContextGroup.h" 28 #include "modules/webgl/WebGLContextGroup.h"
29 #include "modules/webgl/WebGLRenderingContextBase.h" 29 #include "modules/webgl/WebGLRenderingContextBase.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 WebGLSharedObject::WebGLSharedObject(WebGLRenderingContextBase* context) 33 WebGLSharedObject::WebGLSharedObject(WebGLRenderingContextBase* context)
34 : WebGLObject(context), m_contextGroup(context->contextGroup()) {} 34 : WebGLObject(context), m_contextGroup(this, context->contextGroup()) {}
35 35
36 WebGLSharedObject::~WebGLSharedObject() { 36 bool WebGLSharedObject::validate(const WebGLContextGroup* contextGroup,
37 if (m_contextGroup) 37 const WebGLRenderingContextBase*) const {
38 m_contextGroup->removeObject(this); 38 // The contexts and context groups no longer maintain references to all
39 // the objects they ever created, so there's no way to invalidate them
40 // eagerly during context loss. The invalidation is discovered lazily.
41 return contextGroup == m_contextGroup &&
42 cachedNumberOfContextLosses() == contextGroup->numberOfContextLosses();
Zhenyao Mo 2016/12/02 18:58:40 Can you add a comment here saying for WebGL, there
Ken Russell (switch to Gerrit) 2016/12/02 20:38:49 There's actually no such assumption in this code,
39 } 43 }
40 44
41 void WebGLSharedObject::detachContextGroup() { 45 uint32_t WebGLSharedObject::currentNumberOfContextLosses() const {
42 detach(); 46 return m_contextGroup->numberOfContextLosses();
43 if (m_contextGroup) {
44 deleteObject(nullptr);
45 m_contextGroup->removeObject(this);
46 m_contextGroup = nullptr;
47 }
48 } 47 }
49 48
50 gpu::gles2::GLES2Interface* WebGLSharedObject::getAGLInterface() const { 49 gpu::gles2::GLES2Interface* WebGLSharedObject::getAGLInterface() const {
51 return m_contextGroup ? m_contextGroup->getAGLInterface() : nullptr; 50 return m_contextGroup ? m_contextGroup->getAGLInterface() : nullptr;
52 } 51 }
53 52
53 DEFINE_TRACE(WebGLSharedObject) {
54 visitor->trace(m_contextGroup);
55 WebGLObject::trace(visitor);
56 }
57
58 DEFINE_TRACE_WRAPPERS(WebGLSharedObject) {
59 visitor->traceWrappers(m_contextGroup);
60 WebGLObject::traceWrappers(visitor);
61 }
62
54 } // namespace blink 63 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698