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

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: 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
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 return false;
40 if (!success)
41 return;
42 47
43 String extensionsString = m_context->getString(GL_EXTENSIONS); 48 String extensionsString = m_context->getString(GL_EXTENSIONS);
44 splitStringHelper(extensionsString, m_enabledExtensions); 49 splitStringHelper(extensionsString, m_enabledExtensions);
45 50
46 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO MIUM(); 51 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO MIUM();
47 splitStringHelper(requestableExtensionsString, m_requestableExtensions); 52 splitStringHelper(requestableExtensionsString, m_requestableExtensions);
53
54 return true;
48 } 55 }
49 56
50 57
51 bool Extensions3DUtil::supportsExtension(const String& name) 58 bool Extensions3DUtil::supportsExtension(const String& name)
52 { 59 {
53 return m_enabledExtensions.contains(name) || m_requestableExtensions.contain s(name); 60 return m_enabledExtensions.contains(name) || m_requestableExtensions.contain s(name);
54 } 61 }
55 62
56 bool Extensions3DUtil::ensureExtensionEnabled(const String& name) 63 bool Extensions3DUtil::ensureExtensionEnabled(const String& name)
57 { 64 {
(...skipping 19 matching lines...) Expand all
77 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif ted when 84 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif ted when
78 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional. 85 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional.
79 if ((destFormat == GL_RGB || destFormat == GL_RGBA) 86 if ((destFormat == GL_RGB || destFormat == GL_RGBA)
80 && destType == GL_UNSIGNED_BYTE 87 && destType == GL_UNSIGNED_BYTE
81 && !level) 88 && !level)
82 return true; 89 return true;
83 return false; 90 return false;
84 } 91 }
85 92
86 } // namespace WebCore 93 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698