IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / aura / no_transport_image_transport_factory.cc
blobd9cee1831c726fa190cddfb3bb63ba00e5b58ccc
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 "gpu/command_buffer/client/gles2_interface.h"
10 #include "ui/compositor/compositor.h"
12 namespace content {
14 namespace {
16 class FakeTexture : public ui::Texture {
17 public:
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_(0u) {
23 context_provider_->ContextGL()->GenTextures(1, &texture_);
26 virtual unsigned int PrepareTexture() OVERRIDE { return texture_; }
28 virtual void Consume(const std::string& mailbox_name,
29 const gfx::Size& new_size) OVERRIDE {
30 size_ = new_size;
33 private:
34 virtual ~FakeTexture() {
35 context_provider_->ContextGL()->DeleteTextures(1, &texture_);
38 scoped_refptr<cc::ContextProvider> context_provider_;
39 unsigned texture_;
40 DISALLOW_COPY_AND_ASSIGN(FakeTexture);
43 } // anonymous namespace
45 NoTransportImageTransportFactory::NoTransportImageTransportFactory(
46 scoped_ptr<ui::ContextFactory> context_factory)
47 : context_factory_(context_factory.Pass()) {}
49 NoTransportImageTransportFactory::~NoTransportImageTransportFactory() {}
51 ui::ContextFactory* NoTransportImageTransportFactory::AsContextFactory() {
52 return context_factory_.get();
55 gfx::GLSurfaceHandle
56 NoTransportImageTransportFactory::CreateSharedSurfaceHandle() {
57 return gfx::GLSurfaceHandle();
60 void NoTransportImageTransportFactory::DestroySharedSurfaceHandle(
61 gfx::GLSurfaceHandle surface) {}
63 scoped_refptr<ui::Texture>
64 NoTransportImageTransportFactory::CreateTransportClient(
65 float device_scale_factor) {
66 return new FakeTexture(context_factory_->SharedMainThreadContextProvider(),
67 device_scale_factor);
70 scoped_refptr<ui::Texture> NoTransportImageTransportFactory::CreateOwnedTexture(
71 const gfx::Size& size,
72 float device_scale_factor,
73 unsigned int texture_id) {
74 return NULL;
77 GLHelper* NoTransportImageTransportFactory::GetGLHelper() {
78 if (!gl_helper_) {
79 context_provider_ = context_factory_->SharedMainThreadContextProvider();
80 gl_helper_.reset(new GLHelper(context_provider_->ContextGL(),
81 context_provider_->ContextSupport()));
83 return gl_helper_.get();
86 // We don't generate lost context events, so we don't need to keep track of
87 // observers
88 void NoTransportImageTransportFactory::AddObserver(
89 ImageTransportFactoryObserver* observer) {}
91 void NoTransportImageTransportFactory::RemoveObserver(
92 ImageTransportFactoryObserver* observer) {}
94 } // namespace content