#include "content/common/gpu/client/gl_helper.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/android/device_display_info.h"
g_factory_observers = LAZY_INSTANCE_INITIALIZER;
class GLContextLostListener
- : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
+ : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
public:
// WebGraphicsContextLostCallback implementation.
virtual void onContextLost() OVERRIDE;
CmdBufferImageTransportFactory();
virtual ~CmdBufferImageTransportFactory();
- virtual uint32_t InsertSyncPoint() OVERRIDE;
- virtual void WaitSyncPoint(uint32_t sync_point) OVERRIDE;
- virtual uint32_t CreateTexture() OVERRIDE;
- virtual void DeleteTexture(uint32_t id) OVERRIDE;
- virtual void AcquireTexture(
- uint32 texture_id, const signed char* mailbox_name) OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* GetContext3D() OVERRIDE {
- return context_.get();
- }
virtual GLHelper* GetGLHelper() OVERRIDE;
+ virtual uint32 GetChannelID() OVERRIDE {
+ return BrowserGpuChannelHostFactory::instance()->GetGpuChannelId();
+ }
private:
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context_;
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
DCHECK(gpu_channel_host);
- WebKit::WebGraphicsContext3D::Attributes attrs;
+ blink::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true;
GURL url("chrome://gpu/ImageTransportFactoryAndroid");
- base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client;
static const size_t kBytesPerPixel = 4;
gfx::DeviceDisplayInfo display_info;
size_t full_screen_texture_size_in_bytes = display_info.GetDisplayHeight() *
3 * full_screen_texture_size_in_bytes, kDefaultMaxTransferBufferSize);
limits.mapped_memory_reclaim_limit =
WebGraphicsContext3DCommandBufferImpl::kNoLimit;
+ bool lose_context_when_out_of_memory = false;
context_.reset(
new WebGraphicsContext3DCommandBufferImpl(0, // offscreen
url,
gpu_channel_host.get(),
- swap_client,
attrs,
- false,
+ lose_context_when_out_of_memory,
limits,
- true));
+ NULL));
context_->setContextLostCallback(context_lost_listener_.get());
- if (context_->makeContextCurrent())
+ if (context_->InitializeOnCurrentThread())
context_->pushGroupMarkerEXT(
base::StringPrintf("CmdBufferImageTransportFactory-%p",
context_.get()).c_str());
context_->setContextLostCallback(NULL);
}
-uint32_t CmdBufferImageTransportFactory::InsertSyncPoint() {
- if (!context_->makeContextCurrent()) {
- LOG(ERROR) << "Failed to make helper context current.";
- return 0;
- }
- return context_->insertSyncPoint();
-}
-
-void CmdBufferImageTransportFactory::WaitSyncPoint(uint32_t sync_point) {
- if (!context_->makeContextCurrent()) {
- LOG(ERROR) << "Failed to make helper context current.";
- return;
- }
- context_->waitSyncPoint(sync_point);
-}
-
-uint32_t CmdBufferImageTransportFactory::CreateTexture() {
- if (!context_->makeContextCurrent()) {
- LOG(ERROR) << "Failed to make helper context current.";
- return false;
- }
- return context_->createTexture();
-}
-
-void CmdBufferImageTransportFactory::DeleteTexture(uint32_t id) {
- if (!context_->makeContextCurrent()) {
- LOG(ERROR) << "Failed to make helper context current.";
- return;
- }
- context_->deleteTexture(id);
-}
-
-void CmdBufferImageTransportFactory::AcquireTexture(
- uint32 texture_id, const signed char* mailbox_name) {
- if (!context_->makeContextCurrent()) {
- LOG(ERROR) << "Failed to make helper context current.";
- return;
- }
- context_->bindTexture(GL_TEXTURE_2D, texture_id);
- context_->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_name);
- context_->flush();
-}
-
GLHelper* CmdBufferImageTransportFactory::GetGLHelper() {
if (!gl_helper_)
- gl_helper_.reset(new GLHelper(context_.get(),
+ gl_helper_.reset(new GLHelper(context_->GetImplementation(),
context_->GetContextSupport()));
return gl_helper_.get();
} // anonymous namespace
// static
+void ImageTransportFactoryAndroid::InitializeForUnitTests(
+ scoped_ptr<ImageTransportFactoryAndroid> test_factory) {
+ DCHECK(!g_factory);
+ g_factory = test_factory.release();
+}
+
+// static
+void ImageTransportFactoryAndroid::TerminateForUnitTests() {
+ DCHECK(g_factory);
+ delete g_factory;
+ g_factory = NULL;
+}
+
+// static
ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() {
if (!g_factory)
g_factory = new CmdBufferImageTransportFactory();