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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp

Issue 1542283002: Adding null pointer checks to SharedContextRateLimiter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/graphics/gpu/SharedContextRateLimiter.h" 5 #include "platform/graphics/gpu/SharedContextRateLimiter.h"
6 6
7 #include "platform/graphics/gpu/Extensions3DUtil.h" 7 #include "platform/graphics/gpu/Extensions3DUtil.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "public/platform/WebGraphicsContext3D.h" 9 #include "public/platform/WebGraphicsContext3D.h"
10 #include "public/platform/WebGraphicsContext3DProvider.h" 10 #include "public/platform/WebGraphicsContext3DProvider.h"
11 11
12 #ifndef GL_COMMANDS_COMPLETED_CHROMIUM 12 #ifndef GL_COMMANDS_COMPLETED_CHROMIUM
13 #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7 13 #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7
14 #endif 14 #endif
15 15
16 namespace blink { 16 namespace blink {
17 17
18 PassOwnPtr<SharedContextRateLimiter> SharedContextRateLimiter::create(unsigned m axPendingTicks) 18 PassOwnPtr<SharedContextRateLimiter> SharedContextRateLimiter::create(unsigned m axPendingTicks)
19 { 19 {
20 return adoptPtr(new SharedContextRateLimiter(maxPendingTicks)); 20 return adoptPtr(new SharedContextRateLimiter(maxPendingTicks));
21 } 21 }
22 22
23 SharedContextRateLimiter::SharedContextRateLimiter(unsigned maxPendingTicks) 23 SharedContextRateLimiter::SharedContextRateLimiter(unsigned maxPendingTicks)
24 : m_maxPendingTicks(maxPendingTicks) 24 : m_maxPendingTicks(maxPendingTicks)
25 , m_canUseSyncQueries(false)
25 { 26 {
26 m_contextProvider = adoptPtr(Platform::current()->createSharedOffscreenGraph icsContext3DProvider()); 27 m_contextProvider = adoptPtr(Platform::current()->createSharedOffscreenGraph icsContext3DProvider());
28 if (!m_contextProvider)
29 return;
30
27 WebGraphicsContext3D* context = m_contextProvider->context3d(); 31 WebGraphicsContext3D* context = m_contextProvider->context3d();
28 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context); 32 if (context && !context->isContextLost()) {
29 // TODO(junov): when the GLES 3.0 command buffer is ready, we could use fenc eSync instead 33 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(conte xt);
30 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_sync_qu ery"); 34 // TODO(junov): when the GLES 3.0 command buffer is ready, we could use fenceSync instead
35 m_canUseSyncQueries = extensionsUtil->supportsExtension("GL_CHROMIUM_syn c_query");
36 }
31 } 37 }
32 38
33 void SharedContextRateLimiter::tick() 39 void SharedContextRateLimiter::tick()
34 { 40 {
41 if (!m_contextProvider)
42 return;
43
35 WebGraphicsContext3D* context = m_contextProvider->context3d(); 44 WebGraphicsContext3D* context = m_contextProvider->context3d();
36 if (context && !context->isContextLost()) { 45
37 m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0); 46 if (!context || context->isContextLost())
47 return;
48
49 m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0);
50 if (m_canUseSyncQueries) {
51 context->beginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last()) ;
52 context->endQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
53 }
54 if (m_queries.size() > m_maxPendingTicks) {
38 if (m_canUseSyncQueries) { 55 if (m_canUseSyncQueries) {
39 context->beginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.las t()); 56 WGC3Duint result;
40 context->endQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 57 context->getQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT , &result);
41 } 58 context->deleteQueryEXT(m_queries.first());
42 if (m_queries.size() > m_maxPendingTicks) { 59 m_queries.removeFirst();
43 if (m_canUseSyncQueries) { 60 } else {
44 WGC3Duint result; 61 context->finish();
45 context->getQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT _EXT, &result); 62 reset();
46 context->deleteQueryEXT(m_queries.first());
47 m_queries.removeFirst();
48 } else {
49 context->finish();
50 reset();
51 }
52 } 63 }
53 } 64 }
54 } 65 }
55 66
56 void SharedContextRateLimiter::reset() 67 void SharedContextRateLimiter::reset()
57 { 68 {
69 if (!m_contextProvider)
70 return;
71
58 WebGraphicsContext3D* context = m_contextProvider->context3d(); 72 WebGraphicsContext3D* context = m_contextProvider->context3d();
59 if (context && !context->isContextLost()) { 73 if (context && !context->isContextLost()) {
60 while (m_queries.size() > 0) { 74 while (m_queries.size() > 0) {
61 context->deleteQueryEXT(m_queries.first()); 75 context->deleteQueryEXT(m_queries.first());
62 m_queries.removeFirst(); 76 m_queries.removeFirst();
63 } 77 }
64 } else { 78 } else {
65 m_queries.clear(); 79 m_queries.clear();
66 } 80 }
67 } 81 }
68 82
69 } // blink 83 } // blink
70 84
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698