OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "content/browser/renderer_host/image_transport_client.h" |
| 9 #include "ui/gfx/gl/gl_bindings.h" |
| 10 #include "ui/gfx/gl/scoped_make_current.h" |
| 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/gfx/transform.h" |
| 13 |
| 14 AcceleratedSurfaceContainerLinux::AcceleratedSurfaceContainerLinux( |
| 15 const gfx::Size& size) |
| 16 : acquired_(false) { |
| 17 size_ = size; |
| 18 } |
| 19 |
| 20 AcceleratedSurfaceContainerLinux::~AcceleratedSurfaceContainerLinux() { |
| 21 if (texture_id_) { |
| 22 ui::SharedResources* instance = ui::SharedResources::GetInstance(); |
| 23 DCHECK(instance); |
| 24 scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); |
| 25 glDeleteTextures(1, &texture_id_); |
| 26 } |
| 27 |
| 28 if (image_transport_client_.get()) |
| 29 image_transport_client_->Release(); |
| 30 } |
| 31 |
| 32 bool AcceleratedSurfaceContainerLinux::Initialize(uint64* surface_handle) { |
| 33 ui::SharedResources* instance = ui::SharedResources::GetInstance(); |
| 34 DCHECK(instance); |
| 35 image_transport_client_.reset( |
| 36 ImageTransportClient::Create(instance, size_)); |
| 37 if (!image_transport_client_.get()) |
| 38 return false; |
| 39 |
| 40 texture_id_ = image_transport_client_->Initialize(surface_handle); |
| 41 if (!texture_id_) { |
| 42 image_transport_client_.reset(); |
| 43 return false; |
| 44 } |
| 45 flipped_ = image_transport_client_->Flipped(); |
| 46 return true; |
| 47 } |
| 48 |
| 49 // Texture implementation |
| 50 void AcceleratedSurfaceContainerLinux::Update() { |
| 51 ui::SharedResources* instance = ui::SharedResources::GetInstance(); |
| 52 DCHECK(instance); |
| 53 scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); |
| 54 if (acquired_) |
| 55 image_transport_client_->Release(); |
| 56 else |
| 57 acquired_ = true; |
| 58 image_transport_client_->Acquire(); |
| 59 } |
| 60 |
| 61 TransportDIB::Handle AcceleratedSurfaceContainerLinux::Handle() const { |
| 62 return image_transport_client_->Handle(); |
| 63 } |
OLD | NEW |