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

Unified Diff: content/common/gpu/image_transport_surface_android.cc

Issue 59973010: Android: Don't instantiate TextureImageTransportSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/image_transport_surface_android.cc
diff --git a/content/common/gpu/image_transport_surface_android.cc b/content/common/gpu/image_transport_surface_android.cc
index 5ba2d17c2a89b18e0b7a9e30fb03cd65a0f0b483..0c64fa11414f8580ab32e5ef689e149b9d7d4d3f 100644
--- a/content/common/gpu/image_transport_surface_android.cc
+++ b/content/common/gpu/image_transport_surface_android.cc
@@ -4,18 +4,106 @@
#include "content/common/gpu/image_transport_surface.h"
+#include "base/command_line.h"
#include "base/logging.h"
+#include "content/common/gpu/gpu_channel.h"
+#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/gpu_surface_lookup.h"
+#include "content/common/gpu/image_transport_surface.h"
+#include "content/public/common/content_switches.h"
#include "ui/gl/gl_surface_egl.h"
namespace content {
+namespace {
+
+class ImageTransportSurfaceAndroid : public PassThroughImageTransportSurface {
+ public:
+ ImageTransportSurfaceAndroid(GpuChannelManager* manager,
+ GpuCommandBufferStub* stub,
+ gfx::GLSurface* surface,
+ uint32 parent_client_id);
+
+ // gfx::GLSurface implementation.
+ virtual bool Initialize() OVERRIDE;
+ virtual bool SwapBuffers() OVERRIDE;
+ virtual std::string GetExtensions() OVERRIDE;
+ virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
+
+ protected:
+ virtual ~ImageTransportSurfaceAndroid();
+
+ private:
+ uint32 parent_client_id_;
+ bool frontbuffer_suggested_allocation_;
+};
+
+ImageTransportSurfaceAndroid::ImageTransportSurfaceAndroid(
+ GpuChannelManager* manager,
+ GpuCommandBufferStub* stub,
+ gfx::GLSurface* surface,
+ uint32 parent_client_id)
+ : PassThroughImageTransportSurface(manager, stub, surface, true),
+ parent_client_id_(parent_client_id),
+ frontbuffer_suggested_allocation_(true) {}
+
+ImageTransportSurfaceAndroid::~ImageTransportSurfaceAndroid() {}
+
+bool ImageTransportSurfaceAndroid::Initialize() {
+ if (!surface())
+ return false;
+
+ if (!PassThroughImageTransportSurface::Initialize())
+ return false;
+
+ GpuChannel* parent_channel =
+ GetHelper()->manager()->LookupChannel(parent_client_id_);
+ if (parent_channel) {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
+ GetHelper()->SetPreemptByFlag(parent_channel->GetPreemptionFlag());
+ }
+
+ return true;
+}
+
+std::string ImageTransportSurfaceAndroid::GetExtensions() {
+ std::string extensions = gfx::GLSurface::GetExtensions();
+ extensions += extensions.empty() ? "" : " ";
+ extensions += "GL_CHROMIUM_front_buffer_cached ";
+ return extensions;
+}
+
+void ImageTransportSurfaceAndroid::SetFrontbufferAllocation(bool allocation) {
+ if (frontbuffer_suggested_allocation_ == allocation)
+ return;
+ frontbuffer_suggested_allocation_ = allocation;
+ // TODO(sievers): This races with CompositorFrame messages.
+ if (!allocation)
+ GetHelper()->SendAcceleratedSurfaceRelease();
+}
+
+bool ImageTransportSurfaceAndroid::SwapBuffers() {
+ NOTREACHED();
+ return false;
+}
+
+} // anonymous namespace
+
// static
scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
GpuChannelManager* manager,
GpuCommandBufferStub* stub,
const gfx::GLSurfaceHandle& handle) {
+ if (handle.transport_type == gfx::NATIVE_TRANSPORT) {
+ return scoped_refptr<gfx::GLSurface>(
+ new ImageTransportSurfaceAndroid(manager,
+ stub,
+ manager->GetDefaultOffscreenSurface(),
+ handle.parent_client_id));
+ }
+
DCHECK(GpuSurfaceLookup::GetInstance());
DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT);
ANativeWindow* window =
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698