Add a base for GL essential data.
The data holds the GL state, caps, extensions, texture caps, and
current client version.
BUG=angle:789
Change-Id: Icd15d806e14490f39041dea663ab2461a6a76090
Reviewed-on: https://chromium-review.googlesource.com/226060
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libGLESv2.gypi b/src/libGLESv2.gypi
index e23016b..8196e0e 100644
--- a/src/libGLESv2.gypi
+++ b/src/libGLESv2.gypi
@@ -49,6 +49,8 @@
'libGLESv2/Constants.h',
'libGLESv2/Context.cpp',
'libGLESv2/Context.h',
+ 'libGLESv2/Data.cpp',
+ 'libGLESv2/Data.h',
'libGLESv2/Error.cpp',
'libGLESv2/Error.h',
'libGLESv2/Fence.cpp',
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index c823ed5..f9b3d3b 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -179,7 +179,10 @@
}
mZeroTextures.clear();
- mResourceManager->release();
+ if (mResourceManager)
+ {
+ mResourceManager->release();
+ }
}
void Context::makeCurrent(egl::Surface *surface)
@@ -2418,6 +2421,11 @@
mExtensions.maxSamples = maxSamples;
}
+Data Context::getData() const
+{
+ return Data(mClientVersion, mState, mCaps, mTextureCaps, mExtensions, mResourceManager);
+}
+
}
extern "C"
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index 44ee0cf..8344931 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -13,12 +13,12 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/Caps.h"
+#include "libGLESv2/Constants.h"
+#include "libGLESv2/Data.h"
#include "libGLESv2/Error.h"
#include "libGLESv2/HandleAllocator.h"
-#include "libGLESv2/angletypes.h"
-#include "libGLESv2/Constants.h"
#include "libGLESv2/VertexAttribute.h"
-#include "libGLESv2/State.h"
+#include "libGLESv2/angletypes.h"
#include "angle_gl.h"
@@ -216,6 +216,8 @@
State &getState() { return mState; }
const State &getState() const { return mState; }
+ Data getData() const;
+
void releaseShaderCompiler();
private:
diff --git a/src/libGLESv2/Data.cpp b/src/libGLESv2/Data.cpp
new file mode 100644
index 0000000..3ddf591
--- /dev/null
+++ b/src/libGLESv2/Data.cpp
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// Data.cpp: Container class for all GL relevant state, caps and objects
+
+#include "libGLESv2/Data.h"
+#include "libGLESv2/ResourceManager.h"
+
+namespace gl
+{
+
+Data::Data(GLint clientVersionIn, const State &stateIn, const Caps &capsIn,
+ const TextureCapsMap &textureCapsIn, const Extensions &extensionsIn,
+ const ResourceManager *resourceManagerIn)
+ : clientVersion(clientVersionIn),
+ state(&stateIn),
+ caps(&capsIn),
+ textureCaps(&textureCapsIn),
+ extensions(&extensionsIn),
+ resourceManager(resourceManagerIn)
+{}
+
+Data::~Data()
+{
+}
+
+Data::Data(const Data &other)
+ : clientVersion(other.clientVersion),
+ state(other.state),
+ caps(other.caps),
+ textureCaps(other.textureCaps),
+ extensions(other.extensions),
+ resourceManager(other.resourceManager)
+{
+}
+
+Data &Data::operator=(const Data &other)
+{
+ clientVersion = other.clientVersion;
+ state = other.state;
+ caps = other.caps;
+ textureCaps = other.textureCaps;
+ extensions = other.extensions;
+ resourceManager = other.resourceManager;
+ return *this;
+}
+
+}
diff --git a/src/libGLESv2/Data.h b/src/libGLESv2/Data.h
new file mode 100644
index 0000000..cff872a
--- /dev/null
+++ b/src/libGLESv2/Data.h
@@ -0,0 +1,38 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// Data.h: Container class for all GL relevant state, caps and objects
+
+#ifndef LIBGLESV2_DATA_H_
+#define LIBGLESV2_DATA_H_
+
+#include "libGLESv2/State.h"
+
+namespace gl
+{
+
+struct Data final
+{
+ public:
+ Data(GLint clientVersion, const State &state, const Caps &caps,
+ const TextureCapsMap &textureCaps, const Extensions &extensions,
+ const ResourceManager *resourceManager);
+ ~Data();
+
+ Data(const Data &other);
+ Data &operator=(const Data &other);
+
+ GLint clientVersion;
+ const State *state;
+ const Caps *caps;
+ const TextureCapsMap *textureCaps;
+ const Extensions *extensions;
+ const ResourceManager *resourceManager;
+};
+
+}
+
+#endif // LIBGLESV2_DATA_H_
diff --git a/src/libGLESv2/State.cpp b/src/libGLESv2/State.cpp
index 4d28187..ddbdef0 100644
--- a/src/libGLESv2/State.cpp
+++ b/src/libGLESv2/State.cpp
@@ -10,12 +10,12 @@
#include "libGLESv2/Context.h"
#include "libGLESv2/Caps.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/Query.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/renderer/RenderTarget.h"
+#include "libGLESv2/Query.h"
+#include "libGLESv2/VertexArray.h"
#include "libGLESv2/formatutils.h"
+#include "libGLESv2/renderer/RenderTarget.h"
namespace gl
{