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

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

Issue 8307001: Enable accelerated compositing of web pages when using webkit compositor (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 9 years, 1 month 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) 2011 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/compositor/compositor_gl.h"
10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/transform.h"
12
13 namespace {
14
15 class AcceleratedSurfaceContainerLinuxGL
16 : public AcceleratedSurfaceContainerLinux, public ui::TextureGL {
17 public:
18 explicit AcceleratedSurfaceContainerLinuxGL(const gfx::Size& size)
19 : ui::TextureGL(size) {
20 }
21
22 virtual ~AcceleratedSurfaceContainerLinuxGL() { }
23 virtual void AddRef() { ui::TextureGL::AddRef(); }
24 virtual void Release() { ui::TextureGL::Release(); }
25
26 virtual bool Initialize(uint64* surface_id) OVERRIDE {
27 ui::SharedResourcesGL* instance = ui::SharedResourcesGL::GetInstance();
28 DCHECK(instance);
29 image_transport_client_.reset(
30 ImageTransportClient::Create(instance, size_));
31 if (!image_transport_client_.get())
32 return false;
33
34 texture_id_ = image_transport_client_->Initialize(surface_id);
35 if (!texture_id_) {
36 image_transport_client_.reset();
37 return false;
38 }
39 return true;
40 }
41
42 // TextureGL implementation
43 virtual void SetCanvas(const SkCanvas& canvas,
44 const gfx::Point& origin,
45 const gfx::Size& overall_size) OVERRIDE {
46 NOTREACHED();
47 }
48
49 virtual void Draw(const ui::TextureDrawParams& params,
50 const gfx::Rect& clip_bounds_in_texture) OVERRIDE {
51 image_transport_client_->Acquire();
52
53 ui::TextureDrawParams modified_params = params;
54 if (image_transport_client_->Flipped())
55 modified_params.vertically_flipped = true;
56
57 ui::SharedResourcesGL* instance = ui::SharedResourcesGL::GetInstance();
58 DrawInternal(*instance->program_no_swizzle(),
59 modified_params,
60 clip_bounds_in_texture);
61
62 image_transport_client_->Release();
63 }
64
65 virtual TransportDIB::Handle Handle() const {
66 return image_transport_client_->Handle();
67 }
68
69 virtual ui::Texture* GetTexture() { return this; }
70
71 private:
72 scoped_ptr<ImageTransportClient> image_transport_client_;
73 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerLinuxGL);
74 };
75
76 } // namespace
77
78 // static
79 AcceleratedSurfaceContainerLinux*
80 AcceleratedSurfaceContainerLinux::Create(const gfx::Size& size) {
81 return new AcceleratedSurfaceContainerLinuxGL(size);
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698