mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This caused us to lose our gn check certification. :( Turns out gn check was just ignoring all the header paths it didn't understand and so gn check passing for sky wasn't meaning much. I tried to straighten out some of the mess in this CL, but its going to take several more rounds of massaging before gn check passes again. On the bright side (almost) all of our headers are absolute now. Turns out my script (attached to the bug) didn't notice ../ includes but I'll fix that in the next patch. R=abarth@chromium.org BUG=435361 Review URL: https://codereview.chromium.org/746023002
97 lines
2.7 KiB
C++
97 lines
2.7 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/platform/graphics/gpu/Extensions3DUtil.h"
|
|
|
|
#include "sky/engine/public/platform/WebGraphicsContext3D.h"
|
|
#include "sky/engine/wtf/PassOwnPtr.h"
|
|
#include "sky/engine/wtf/text/CString.h"
|
|
#include "sky/engine/wtf/text/StringHash.h"
|
|
|
|
namespace blink {
|
|
|
|
namespace {
|
|
|
|
void splitStringHelper(const String& str, HashSet<String>& set)
|
|
{
|
|
Vector<String> substrings;
|
|
str.split(' ', substrings);
|
|
for (size_t i = 0; i < substrings.size(); ++i)
|
|
set.add(substrings[i]);
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
PassOwnPtr<Extensions3DUtil> Extensions3DUtil::create(WebGraphicsContext3D* context)
|
|
{
|
|
OwnPtr<Extensions3DUtil> out = adoptPtr(new Extensions3DUtil(context));
|
|
if (!out->initializeExtensions())
|
|
return nullptr;
|
|
return out.release();
|
|
}
|
|
|
|
Extensions3DUtil::Extensions3DUtil(WebGraphicsContext3D* context)
|
|
: m_context(context)
|
|
{
|
|
}
|
|
|
|
Extensions3DUtil::~Extensions3DUtil()
|
|
{
|
|
}
|
|
|
|
bool Extensions3DUtil::initializeExtensions()
|
|
{
|
|
if (m_context->isContextLost()) {
|
|
// Need to try to restore the context again later.
|
|
return false;
|
|
}
|
|
|
|
String extensionsString = m_context->getString(GL_EXTENSIONS);
|
|
splitStringHelper(extensionsString, m_enabledExtensions);
|
|
|
|
String requestableExtensionsString = m_context->getRequestableExtensionsCHROMIUM();
|
|
splitStringHelper(requestableExtensionsString, m_requestableExtensions);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
bool Extensions3DUtil::supportsExtension(const String& name)
|
|
{
|
|
return m_enabledExtensions.contains(name) || m_requestableExtensions.contains(name);
|
|
}
|
|
|
|
bool Extensions3DUtil::ensureExtensionEnabled(const String& name)
|
|
{
|
|
if (m_enabledExtensions.contains(name))
|
|
return true;
|
|
|
|
if (m_requestableExtensions.contains(name)) {
|
|
m_context->requestExtensionCHROMIUM(name.ascii().data());
|
|
m_enabledExtensions.clear();
|
|
m_requestableExtensions.clear();
|
|
initializeExtensions();
|
|
}
|
|
return m_enabledExtensions.contains(name);
|
|
}
|
|
|
|
bool Extensions3DUtil::isExtensionEnabled(const String& name)
|
|
{
|
|
return m_enabledExtensions.contains(name);
|
|
}
|
|
|
|
bool Extensions3DUtil::canUseCopyTextureCHROMIUM(GLenum destFormat, GLenum destType, GLint level)
|
|
{
|
|
// FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lifted when
|
|
// WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional.
|
|
if ((destFormat == GL_RGB || destFormat == GL_RGBA)
|
|
&& destType == GL_UNSIGNED_BYTE
|
|
&& !level)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
} // namespace blink
|