#ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
#define CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "ipc/ipc_listener.h"
#include "ui/gl/android/surface_texture.h"
#include "ui/gl/gl_image.h"
namespace gfx {
class Size;
}
namespace content {
class StreamTexture : public gfx::GLImage,
public IPC::Listener,
public GpuCommandBufferStub::DestructionObserver {
public:
static int32 Create(GpuCommandBufferStub* owner_stub,
uint32 client_texture_id);
private:
StreamTexture(GpuCommandBufferStub* owner_stub,
int32 route_id,
uint32 texture_id);
virtual ~StreamTexture();
virtual void Destroy() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual bool BindTexImage(unsigned target) OVERRIDE;
virtual void ReleaseTexImage(unsigned target) OVERRIDE;
virtual void WillUseTexImage() OVERRIDE;
virtual void DidUseTexImage() OVERRIDE {}
virtual void WillModifyTexImage() OVERRIDE {}
virtual void DidModifyTexImage() OVERRIDE {}
virtual void OnWillDestroyStub() OVERRIDE;
void OnFrameAvailable();
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void OnStartListening();
void OnEstablishPeer(int32 primary_id, int32 secondary_id);
void OnSetSize(const gfx::Size& size) { size_ = size; }
scoped_refptr<gfx::SurfaceTexture> surface_texture_;
float current_matrix_[16];
gfx::Size size_;
bool has_valid_frame_;
bool has_pending_frame_;
GpuCommandBufferStub* owner_stub_;
int32 route_id_;
bool has_listener_;
base::WeakPtrFactory<StreamTexture> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(StreamTexture);
};
}
#endif