Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: content/browser/renderer_host/accelerated_surface_container_linux.cc

Issue 9297041: Merge Compositor and CompositorCC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698