1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/aura/no_transport_image_transport_factory.h"
7 #include "cc/output/context_provider.h"
8 #include "content/common/gpu/client/gl_helper.h"
9 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
10 #include "ui/compositor/compositor.h"
16 class FakeTexture : public ui::Texture {
18 FakeTexture(scoped_refptr<cc::ContextProvider> context_provider,
19 float device_scale_factor)
20 : ui::Texture(false, gfx::Size(), device_scale_factor),
21 context_provider_(context_provider),
22 texture_(context_provider_->Context3d()->createTexture()) {}
24 virtual unsigned int PrepareTexture() OVERRIDE { return texture_; }
25 virtual WebKit::WebGraphicsContext3D* HostContext3D() OVERRIDE {
26 return context_provider_->Context3d();
29 virtual void Consume(const std::string& mailbox_name,
30 const gfx::Size& new_size) OVERRIDE {
35 virtual ~FakeTexture() {
36 context_provider_->Context3d()->deleteTexture(texture_);
39 scoped_refptr<cc::ContextProvider> context_provider_;
41 DISALLOW_COPY_AND_ASSIGN(FakeTexture);
44 } // anonymous namespace
46 NoTransportImageTransportFactory::NoTransportImageTransportFactory(
47 scoped_ptr<ui::ContextFactory> context_factory)
48 : context_factory_(context_factory.Pass()) {}
50 NoTransportImageTransportFactory::~NoTransportImageTransportFactory() {}
52 ui::ContextFactory* NoTransportImageTransportFactory::AsContextFactory() {
53 return context_factory_.get();
57 NoTransportImageTransportFactory::CreateSharedSurfaceHandle() {
58 return gfx::GLSurfaceHandle();
61 void NoTransportImageTransportFactory::DestroySharedSurfaceHandle(
62 gfx::GLSurfaceHandle surface) {}
64 scoped_refptr<ui::Texture>
65 NoTransportImageTransportFactory::CreateTransportClient(
66 float device_scale_factor) {
67 return new FakeTexture(context_factory_->SharedMainThreadContextProvider(),
71 scoped_refptr<ui::Texture> NoTransportImageTransportFactory::CreateOwnedTexture(
72 const gfx::Size& size,
73 float device_scale_factor,
74 unsigned int texture_id) {
78 GLHelper* NoTransportImageTransportFactory::GetGLHelper() {
80 context_provider_ = context_factory_->SharedMainThreadContextProvider();
81 gl_helper_.reset(new GLHelper(context_provider_->Context3d(),
82 context_provider_->ContextSupport()));
84 return gl_helper_.get();
87 uint32 NoTransportImageTransportFactory::InsertSyncPoint() { return 0; }
89 void NoTransportImageTransportFactory::WaitSyncPoint(uint32 sync_point) {}
91 // We don't generate lost context events, so we don't need to keep track of
93 void NoTransportImageTransportFactory::AddObserver(
94 ImageTransportFactoryObserver* observer) {}
96 void NoTransportImageTransportFactory::RemoveObserver(
97 ImageTransportFactoryObserver* observer) {}
99 } // namespace content