#ifndef GPU_COMMAND_BUFFER_SERVICE_SURFACE_TEXTURE_GL_OWNER_H_
#define GPU_COMMAND_BUFFER_SERVICE_SURFACE_TEXTURE_GL_OWNER_H_
#include "base/threading/thread_checker.h"
#include "gpu/command_buffer/service/texture_owner.h"
#include "gpu/gpu_export.h"
#include "ui/gl/android/surface_texture.h"
namespace base {
namespace android {
class ScopedHardwareBufferFenceSync;
}
}
namespace gpu {
class GPU_GLES2_EXPORT SurfaceTextureGLOwner : public TextureOwner {
public:
SurfaceTextureGLOwner(const SurfaceTextureGLOwner&) = delete;
SurfaceTextureGLOwner& operator=(const SurfaceTextureGLOwner&) = delete;
gl::GLContext* GetContext() const override;
gl::GLSurface* GetSurface() const override;
void SetFrameAvailableCallback(
const base::RepeatingClosure& frame_available_cb) override;
gl::ScopedJavaSurface CreateJavaSurface() const override;
void UpdateTexImage() override;
void EnsureTexImageBound(GLuint service_id) override;
void ReleaseBackBuffers() override;
std::unique_ptr<base::android::ScopedHardwareBufferFenceSync>
GetAHardwareBuffer() override;
bool GetCodedSizeAndVisibleRect(gfx::Size rotated_visible_size,
gfx::Size* coded_size,
gfx::Rect* visible_rect) override;
void RunWhenBufferIsAvailable(base::OnceClosure callback) override;
protected:
void ReleaseResources() override;
private:
friend class TextureOwner;
friend class SurfaceTextureGLOwnerTest;
friend class SurfaceTextureTransformTest;
SurfaceTextureGLOwner(std::unique_ptr<AbstractTextureAndroid> texture,
scoped_refptr<SharedContextState> context_state);
~SurfaceTextureGLOwner() override;
static bool DecomposeTransform(float matrix[16],
gfx::Size rotated_visible_size,
gfx::Size* coded_size,
gfx::Rect* visible_rect);
scoped_refptr<gl::SurfaceTexture> surface_texture_;
scoped_refptr<gl::GLContext> context_;
scoped_refptr<gl::GLSurface> surface_;
bool is_frame_available_callback_set_ = false;
THREAD_CHECKER(thread_checker_);
};
}
#endif