1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_TRANSFORM_FEEDBACK_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_TRANSFORM_FEEDBACK_H_
#include "third_party/blink/renderer/modules/webgl/webgl_object.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
namespace blink {
class WebGLBuffer;
class WebGLProgram;
class WebGLTransformFeedback : public WebGLObject {
DEFINE_WRAPPERTYPEINFO();
public:
enum class TFType {
kDefault,
kUser,
};
explicit WebGLTransformFeedback(
WebGLContextObjectSupport*,
TFType,
GLint max_transform_feedback_separate_attribs);
~WebGLTransformFeedback() override;
bool IsDefaultObject() const { return type_ == TFType::kDefault; }
GLenum GetTarget() const { return target_; }
void SetTarget(GLenum);
bool HasEverBeenBound() const { return HasObject() && target_; }
WebGLProgram* GetProgram() const { return program_.Get(); }
void SetProgram(WebGLProgram*);
// These are the indexed bind points for transform feedback buffers.
// Returns false if index is out of range and the caller should
// synthesize a GL error.
bool SetBoundIndexedTransformFeedbackBuffer(GLuint index, WebGLBuffer*);
bool GetBoundIndexedTransformFeedbackBuffer(GLuint index,
WebGLBuffer** outBuffer) const;
bool HasBoundIndexedTransformFeedbackBuffer(const WebGLBuffer* buffer) {
return bound_indexed_transform_feedback_buffers_.Contains(buffer);
}
bool HasEnoughBuffers(GLuint num_required) const;
bool UsesBuffer(WebGLBuffer*);
void UnbindBuffer(WebGLBuffer*);
void Trace(Visitor*) const override;
bool active() const { return active_; }
bool paused() const { return paused_; }
const HeapVector<Member<WebGLBuffer>>&
bound_indexed_transform_feedback_buffers() const {
return bound_indexed_transform_feedback_buffers_;
}
void SetActive(bool active) {
active_ = active;
DCHECK(active_ || !paused_);
}
void SetPaused(bool paused) {
paused_ = paused;
DCHECK(active_ || !paused_);
}
bool ValidateProgramForResume(WebGLProgram*) const;
private:
void DispatchDetached(gpu::gles2::GLES2Interface*);
void DeleteObjectImpl(gpu::gles2::GLES2Interface*) override;
TFType type_;
GLenum target_;
HeapVector<Member<WebGLBuffer>> bound_indexed_transform_feedback_buffers_;
Member<WebGLProgram> program_;
unsigned program_link_count_;
bool active_;
bool paused_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_TRANSFORM_FEEDBACK_H_
|