| OLD | NEW |
| 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 "platform/graphics/gpu/Extensions3DUtil.h" | 5 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 7 #include "public/platform/WebGraphicsContext3D.h" | 8 #include "public/platform/WebGraphicsContext3D.h" |
| 8 #include "wtf/text/CString.h" | 9 #include "wtf/text/CString.h" |
| 9 #include "wtf/text/StringHash.h" | 10 #include "wtf/text/StringHash.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 void splitStringHelper(const String& str, HashSet<String>& set) | 16 void splitStringHelper(const String& str, HashSet<String>& set) |
| 16 { | 17 { |
| 17 Vector<String> substrings; | 18 Vector<String> substrings; |
| 18 str.split(' ', substrings); | 19 str.split(' ', substrings); |
| 19 for (size_t i = 0; i < substrings.size(); ++i) | 20 for (size_t i = 0; i < substrings.size(); ++i) |
| 20 set.add(substrings[i]); | 21 set.add(substrings[i]); |
| 21 } | 22 } |
| 22 | 23 |
| 23 } // anonymous namespace | 24 } // anonymous namespace |
| 24 | 25 |
| 25 PassOwnPtr<Extensions3DUtil> Extensions3DUtil::create(WebGraphicsContext3D* cont
ext) | 26 PassOwnPtr<Extensions3DUtil> Extensions3DUtil::create(WebGraphicsContext3D* cont
ext, gpu::gles2::GLES2Interface* gl) |
| 26 { | 27 { |
| 27 OwnPtr<Extensions3DUtil> out = adoptPtr(new Extensions3DUtil(context)); | 28 OwnPtr<Extensions3DUtil> out = adoptPtr(new Extensions3DUtil(context, gl)); |
| 28 out->initializeExtensions(); | 29 out->initializeExtensions(); |
| 29 return out.release(); | 30 return out.release(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 Extensions3DUtil::Extensions3DUtil(WebGraphicsContext3D* context) | 33 Extensions3DUtil::Extensions3DUtil(WebGraphicsContext3D* context, gpu::gles2::GL
ES2Interface* gl) |
| 33 : m_context(context) | 34 : m_context(context) |
| 35 , m_gl(gl) |
| 34 , m_isValid(true) | 36 , m_isValid(true) |
| 35 { | 37 { |
| 36 } | 38 } |
| 37 | 39 |
| 38 Extensions3DUtil::~Extensions3DUtil() | 40 Extensions3DUtil::~Extensions3DUtil() |
| 39 { | 41 { |
| 40 } | 42 } |
| 41 | 43 |
| 42 void Extensions3DUtil::initializeExtensions() | 44 void Extensions3DUtil::initializeExtensions() |
| 43 { | 45 { |
| 44 if (m_context->isContextLost()) { | 46 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 45 // If the context is lost don't initialize the extension strings. | 47 // If the context is lost don't initialize the extension strings. |
| 46 // This will cause supportsExtension, ensureExtensionEnabled, and isExte
nsionEnabled to always return false. | 48 // This will cause supportsExtension, ensureExtensionEnabled, and isExte
nsionEnabled to always return false. |
| 47 m_isValid = false; | 49 m_isValid = false; |
| 48 return; | 50 return; |
| 49 } | 51 } |
| 50 | 52 |
| 51 String extensionsString = m_context->getString(GL_EXTENSIONS); | 53 String extensionsString = m_context->getString(GL_EXTENSIONS); |
| 52 splitStringHelper(extensionsString, m_enabledExtensions); | 54 splitStringHelper(extensionsString, m_enabledExtensions); |
| 53 | 55 |
| 54 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO
MIUM(); | 56 String requestableExtensionsString = m_context->getRequestableExtensionsCHRO
MIUM(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 85 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif
ted when | 87 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif
ted when |
| 86 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional. | 88 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional. |
| 87 if (destTarget == GL_TEXTURE_2D && (destFormat == GL_RGB || destFormat == GL
_RGBA) | 89 if (destTarget == GL_TEXTURE_2D && (destFormat == GL_RGB || destFormat == GL
_RGBA) |
| 88 && destType == GL_UNSIGNED_BYTE | 90 && destType == GL_UNSIGNED_BYTE |
| 89 && !level) | 91 && !level) |
| 90 return true; | 92 return true; |
| 91 return false; | 93 return false; |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |