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

Unified Diff: content/common/gpu/image_transport_surface_fbo_mac.h

Issue 334173006: Clean up GLSurfaceCGL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 6 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/common/gpu/image_transport_surface_fbo_mac.h
diff --git a/content/common/gpu/texture_image_transport_surface.h b/content/common/gpu/image_transport_surface_fbo_mac.h
similarity index 38%
copy from content/common/gpu/texture_image_transport_surface.h
copy to content/common/gpu/image_transport_surface_fbo_mac.h
index dec6b35e9829657e7ba312e48b61bd0b3f2e6315..1302cfe51bc1d39cefc82bc7dc69038b246349f3 100644
--- a/content/common/gpu/texture_image_transport_surface.h
+++ b/content/common/gpu/image_transport_surface_fbo_mac.h
@@ -1,110 +1,110 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 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.
-#ifndef CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_
-#define CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_
+#ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_FBO_MAC_H_
+#define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_FBO_MAC_H_
-#include <string>
-
-#include "base/basictypes.h"
+#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/image_transport_surface.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "gpu/command_buffer/service/texture_manager.h"
-#include "ui/gl/gl_context.h"
-#include "ui/gl/gl_surface.h"
+#include "ui/gl/gl_bindings.h"
namespace content {
-class GpuChannelManager;
-class TextureImageTransportSurface
- : public ImageTransportSurface,
- public GpuCommandBufferStub::DestructionObserver,
- public gfx::GLSurface {
+// We are backed by an offscreen surface for the purposes of creating
+// a context, but use FBOs to render to texture. The texture may be backed by
+// an IOSurface, or it may be presented to the screen via a CALayer, depending
+// on the StorageProvider class specified.
+class ImageTransportSurfaceFBO
+ : public gfx::GLSurface,
+ public ImageTransportSurface,
+ public GpuCommandBufferStub::DestructionObserver {
public:
- TextureImageTransportSurface(GpuChannelManager* manager,
- GpuCommandBufferStub* stub,
- const gfx::GLSurfaceHandle& handle);
-
- // gfx::GLSurface implementation.
+ // The interface through which storage for the color buffer of the FBO is
+ // allocated.
+ class StorageProvider {
+ public:
+ virtual ~StorageProvider() {}
+ // IOSurfaces cause too much address space fragmentation if they are
+ // allocated on every resize. This gets a rounded size for allocation.
+ virtual gfx::Size GetRoundedSize(gfx::Size size) = 0;
+
+ // Allocate the storage for the color buffer. The specified context is
+ // current, and there is a texture bound to GL_TEXTURE_RECTANGLE_ARB.
+ virtual bool AllocateColorBufferStorage(
+ CGLContextObj context, gfx::Size size) = 0;
+
+ // Free the storage allocated in the AllocateColorBufferStorage call. The
+ // GL texture that was bound has already been deleted by the caller.
+ virtual void FreeColorBufferStorage() = 0;
+
+ // Retrieve the handle for the surface to send to the browser process to
+ // display.
+ virtual uint64 GetSurfaceHandle() const = 0;
+ };
+
+ ImageTransportSurfaceFBO(StorageProvider* storage_provider,
+ GpuChannelManager* manager,
+ GpuCommandBufferStub* stub,
+ gfx::PluginWindowHandle handle);
+
+ // GLSurface implementation
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool DeferDraws() OVERRIDE;
virtual bool IsOffscreen() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
+ virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
+ virtual bool SupportsPostSubBuffer() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual void* GetHandle() OVERRIDE;
- virtual unsigned GetFormat() OVERRIDE;
- virtual bool SupportsPostSubBuffer() OVERRIDE;
+ virtual void* GetDisplay() OVERRIDE;
+ virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
- virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE;
virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
- virtual void* GetShareHandle() OVERRIDE;
- virtual void* GetDisplay() OVERRIDE;
- virtual void* GetConfig() OVERRIDE;
protected:
- // ImageTransportSurface implementation.
+ // ImageTransportSurface implementation
virtual void OnBufferPresented(
const AcceleratedSurfaceMsg_BufferPresented_Params& params) OVERRIDE;
virtual void OnResize(gfx::Size size, float scale_factor) OVERRIDE;
virtual void SetLatencyInfo(
- const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
+ const std::vector<ui::LatencyInfo>&) OVERRIDE;
virtual void WakeUpGpu() OVERRIDE;
// GpuCommandBufferStub::DestructionObserver implementation.
virtual void OnWillDestroyStub() OVERRIDE;
private:
+ virtual ~ImageTransportSurfaceFBO() OVERRIDE;
- gfx::Size backbuffer_size() const {
- DCHECK(backbuffer_.get());
- GLsizei width = 0;
- GLsizei height = 0;
- backbuffer_->texture()->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height);
- return gfx::Size(width, height);
- }
-
- virtual ~TextureImageTransportSurface();
- void CreateBackTexture();
- void AttachBackTextureToFBO();
- void ReleaseBackTexture();
- void ReleaseFrontTexture();
- void BufferPresentedImpl(const gpu::Mailbox& mailbox_name);
-
- // The framebuffer that represents this surface (service id). Allocated lazily
- // in OnMakeCurrent.
- uint32 fbo_id_;
-
- // The current backbuffer.
- scoped_refptr<gpu::gles2::TextureRef> backbuffer_;
- scoped_refptr<gpu::gles2::TextureRef> frontbuffer_;
-
- // The mailbox name for the current backbuffer texture. Needs to be unique per
- // GL texture and is invalid while service_id is zero.
- gpu::Mailbox back_mailbox_;
- gpu::Mailbox front_mailbox_;
+ void AdjustBufferAllocation();
+ void DestroyFramebuffer();
+ void CreateFramebuffer();
- // The current size of the GLSurface. Used to disambiguate from the current
- // texture size which might be outdated (since we use two buffers).
- gfx::Size current_size_;
- float scale_factor_;
-
- // Whether or not the command buffer stub has been destroyed.
- bool stub_destroyed_;
+ scoped_ptr<StorageProvider> storage_provider_;
+ // Tracks the current buffer allocation state.
bool backbuffer_suggested_allocation_;
bool frontbuffer_suggested_allocation_;
- scoped_ptr<ImageTransportHelper> helper_;
- gfx::GLSurfaceHandle handle_;
+ uint32 fbo_id_;
+ GLuint texture_id_;
+ GLuint depth_stencil_renderbuffer_id_;
+ bool has_complete_framebuffer_;
+
+ // Weak pointer to the context that this was last made current to.
+ gfx::GLContext* context_;
- // The offscreen surface used to make the context current. However note that
- // the actual rendering is always redirected to an FBO.
- scoped_refptr<gfx::GLSurface> surface_;
+ gfx::Size size_;
+ gfx::Size rounded_size_;
+ float scale_factor_;
+
+ // Whether or not we've successfully made the surface current once.
+ bool made_current_;
// Whether a SwapBuffers is pending.
bool is_swap_buffers_pending_;
@@ -112,13 +112,13 @@ class TextureImageTransportSurface
// Whether we unscheduled command buffer because of pending SwapBuffers.
bool did_unschedule_;
- // Holds a reference to the mailbox manager for cleanup.
- scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
-
std::vector<ui::LatencyInfo> latency_info_;
- DISALLOW_COPY_AND_ASSIGN(TextureImageTransportSurface);
+
+ scoped_ptr<ImageTransportHelper> helper_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageTransportSurfaceFBO);
};
} // namespace content
-#endif // CONTENT_COMMON_GPU_TEXTURE_IMAGE_TRANSPORT_SURFACE_H_
+#endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_MAC_H_
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/common/gpu/image_transport_surface_fbo_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698