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

Side by Side Diff: Source/platform/graphics/gpu/Extensions3DUtil.cpp

Issue 254453002: Fix WebGL context restoration logic. The retry mechanism was broken when the ownership of the WebGr… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added more safety checks upon context restoration. Created 6 years, 8 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 | « Source/platform/graphics/gpu/Extensions3DUtil.h ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "platform/graphics/gpu/Extensions3DUtil.h" 6 #include "platform/graphics/gpu/Extensions3DUtil.h"
7 7
8 #include "public/platform/WebGraphicsContext3D.h" 8 #include "public/platform/WebGraphicsContext3D.h"
9 #include "wtf/text/CString.h" 9 #include "wtf/text/CString.h"
10 #include "wtf/text/StringHash.h" 10 #include "wtf/text/StringHash.h"
11 11
12 namespace WebCore { 12 namespace WebCore {
13 13
14 namespace { 14 namespace {
15 15
16 void splitStringHelper(const String& str, HashSet<String>& set) 16 void splitStringHelper(const String& str, HashSet<String>& set)
17 { 17 {
18 Vector<String> substrings; 18 Vector<String> substrings;
19 str.split(" ", substrings); 19 str.split(" ", substrings);
20 for (size_t i = 0; i < substrings.size(); ++i) 20 for (size_t i = 0; i < substrings.size(); ++i)
21 set.add(substrings[i]); 21 set.add(substrings[i]);
22 } 22 }
23 23
24 } // anonymous namespace 24 } // anonymous namespace
25 25
26 PassOwnPtr<Extensions3DUtil> Extensions3DUtil::create(blink::WebGraphicsContext3 D* context)
27 {
28 OwnPtr<Extensions3DUtil> out = adoptPtr(new Extensions3DUtil(context));
29 if (!out->initializeExtensions())
30 return nullptr;
31 return out.release();
32 }
33
26 Extensions3DUtil::Extensions3DUtil(blink::WebGraphicsContext3D* context) 34 Extensions3DUtil::Extensions3DUtil(blink::WebGraphicsContext3D* context)
27 : m_context(context) 35 : m_context(context)
28 { 36 {
29 initializeExtensions();
30 } 37 }
31 38
32 Extensions3DUtil::~Extensions3DUtil() 39 Extensions3DUtil::~Extensions3DUtil()
33 { 40 {
34 } 41 }
35 42
36 void Extensions3DUtil::initializeExtensions() 43 bool Extensions3DUtil::initializeExtensions()
37 { 44 {
38 bool success = m_context->makeContextCurrent(); 45 if (!m_context->makeContextCurrent()) {
39 ASSERT(success); 46 // Most likely the GPU process exited and the attempt to reconnect to it failed.
40 if (!success) 47 // Need to try to restore the context again later.
41 return; 48 return false;
49 }
50
51 if (m_context->isContextLost()) {
52 // Need to try to restore the context again later.
53 return false;
54 }
42 55
43 String extensionsString = m_context->getString(GL_EXTENSIONS); 56 String extensionsString = m_context->getString(GL_EXTENSIONS);
44 splitStringHelper(extensionsString, m_enabledExtensions); 57 splitStringHelper(extensionsString, m_enabledExtensions);
45 58
46 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO MIUM(); 59 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO MIUM();
47 splitStringHelper(requestableExtensionsString, m_requestableExtensions); 60 splitStringHelper(requestableExtensionsString, m_requestableExtensions);
61
62 return true;
48 } 63 }
49 64
50 65
51 bool Extensions3DUtil::supportsExtension(const String& name) 66 bool Extensions3DUtil::supportsExtension(const String& name)
52 { 67 {
53 return m_enabledExtensions.contains(name) || m_requestableExtensions.contain s(name); 68 return m_enabledExtensions.contains(name) || m_requestableExtensions.contain s(name);
54 } 69 }
55 70
56 bool Extensions3DUtil::ensureExtensionEnabled(const String& name) 71 bool Extensions3DUtil::ensureExtensionEnabled(const String& name)
57 { 72 {
(...skipping 19 matching lines...) Expand all
77 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif ted when 92 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif ted when
78 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional. 93 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional.
79 if ((destFormat == GL_RGB || destFormat == GL_RGBA) 94 if ((destFormat == GL_RGB || destFormat == GL_RGBA)
80 && destType == GL_UNSIGNED_BYTE 95 && destType == GL_UNSIGNED_BYTE
81 && !level) 96 && !level)
82 return true; 97 return true;
83 return false; 98 return false;
84 } 99 }
85 100
86 } // namespace WebCore 101 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/Extensions3DUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698