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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/accelerated_surface_container_linux_gl.cc
diff --git a/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc b/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..61c75acc07c50d5ebe6e96b58f25130bf8605e0c
--- /dev/null
+++ b/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/accelerated_surface_container_linux.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/renderer_host/image_transport_client.h"
+#include "ui/gfx/compositor/compositor_gl.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
+
+namespace {
+
+class AcceleratedSurfaceContainerLinuxGL
+ : public AcceleratedSurfaceContainerLinux, public ui::TextureGL {
+ public:
+ explicit AcceleratedSurfaceContainerLinuxGL(const gfx::Size& size)
+ : ui::TextureGL(size) {
+ }
+
+ virtual ~AcceleratedSurfaceContainerLinuxGL() { }
+ virtual void AddRef() { ui::TextureGL::AddRef(); }
+ virtual void Release() { ui::TextureGL::Release(); }
+
+ virtual bool Initialize(uint64* surface_id) OVERRIDE {
+ ui::SharedResourcesGL* instance = ui::SharedResourcesGL::GetInstance();
+ DCHECK(instance);
+ image_transport_client_.reset(
+ ImageTransportClient::Create(instance, size_));
+ if (!image_transport_client_.get())
+ return false;
+
+ texture_id_ = image_transport_client_->Initialize(surface_id);
+ if (!texture_id_) {
+ image_transport_client_.reset();
+ return false;
+ }
+ return true;
+ }
+
+ // TextureGL implementation
+ virtual void SetCanvas(const SkCanvas& canvas,
+ const gfx::Point& origin,
+ const gfx::Size& overall_size) OVERRIDE {
+ NOTREACHED();
+ }
+
+ virtual void Draw(const ui::TextureDrawParams& params,
+ const gfx::Rect& clip_bounds_in_texture) OVERRIDE {
+ image_transport_client_->Acquire();
+
+ ui::TextureDrawParams modified_params = params;
+ if (image_transport_client_->Flipped())
+ modified_params.vertically_flipped = true;
+
+ ui::SharedResourcesGL* instance = ui::SharedResourcesGL::GetInstance();
+ DrawInternal(*instance->program_no_swizzle(),
+ modified_params,
+ clip_bounds_in_texture);
+
+ image_transport_client_->Release();
+ }
+
+ virtual TransportDIB::Handle Handle() const {
+ return image_transport_client_->Handle();
+ }
+
+ virtual ui::Texture* GetTexture() { return this; }
+
+ private:
+ scoped_ptr<ImageTransportClient> image_transport_client_;
+ DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerLinuxGL);
+};
+
+} // namespace
+
+// static
+AcceleratedSurfaceContainerLinux*
+AcceleratedSurfaceContainerLinux::Create(const gfx::Size& size) {
+ return new AcceleratedSurfaceContainerLinuxGL(size);
+}

Powered by Google App Engine
This is Rietveld 408576698