#pragma once
#if ENABLE(WEBGL)
#include "ContextDestructionObserver.h"
#include "WebGLSharedObject.h"
#include <wtf/HashMap.h>
#include <wtf/HashFunctions.h>
#include <wtf/Lock.h>
#include <wtf/Vector.h>
namespace JSC {
class SlotVisitor;
}
namespace WTF {
class AbstractLocker;
};
namespace WebCore {
class ScriptExecutionContext;
class WebGLRenderingContextBase;
class WebGLShader;
class WebGLProgram final : public WebGLSharedObject, public ContextDestructionObserver {
public:
static Ref<WebGLProgram> create(WebGLRenderingContextBase&);
virtual ~WebGLProgram();
static HashMap<WebGLProgram*, WebGLRenderingContextBase*>& instances(const WTF::LockHolder&);
static Lock& instancesMutex();
void contextDestroyed() final;
unsigned numActiveAttribLocations();
GCGLint getActiveAttribLocation(GCGLuint index);
bool isUsingVertexAttrib0();
bool getLinkStatus();
void setLinkStatus(bool);
unsigned getLinkCount() const { return m_linkCount; }
void increaseLinkCount();
WebGLShader* getAttachedShader(GCGLenum);
bool attachShader(const WTF::AbstractLocker&, WebGLShader*);
bool detachShader(const WTF::AbstractLocker&, WebGLShader*);
void setRequiredTransformFeedbackBufferCount(int count)
{
m_requiredTransformFeedbackBufferCountAfterNextLink = count;
}
int requiredTransformFeedbackBufferCount()
{
cacheInfoIfNeeded();
return m_requiredTransformFeedbackBufferCount;
}
void addMembersToOpaqueRoots(const WTF::AbstractLocker&, JSC::SlotVisitor&);
private:
WebGLProgram(WebGLRenderingContextBase&);
void deleteObjectImpl(const WTF::AbstractLocker&, GraphicsContextGL*, PlatformGLObject) override;
void cacheActiveAttribLocations(GraphicsContextGL*);
void cacheInfoIfNeeded();
Vector<GCGLint> m_activeAttribLocations;
GCGLint m_linkStatus { 0 };
unsigned m_linkCount { 0 };
RefPtr<WebGLShader> m_vertexShader;
RefPtr<WebGLShader> m_fragmentShader;
bool m_infoValid { true };
int m_requiredTransformFeedbackBufferCountAfterNextLink { 0 };
int m_requiredTransformFeedbackBufferCount { 0 };
};
}
#endif