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

Unified Diff: content/browser/compositor/buffer_queue.h

Issue 1423843003: Make content::BufferQueue use scoped ptrs for AllocatedSurfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@surfaceless_only
Patch Set: Incorporate review foodback Created 5 years 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/compositor/buffer_queue.h
diff --git a/content/browser/compositor/buffer_queue.h b/content/browser/compositor/buffer_queue.h
index ad985b0f127bb38fd5236c3ce9e39d1cfbd0a21a..c6d5235fec0372508eaadc970e23cfe14f91a34c 100644
--- a/content/browser/compositor/buffer_queue.h
+++ b/content/browser/compositor/buffer_queue.h
@@ -5,10 +5,9 @@
#ifndef CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_
#define CONTENT_BROWSER_COMPOSITOR_BUFFER_QUEUE_H_
-#include <queue>
+#include <deque>
#include <vector>
-#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"
@@ -51,30 +50,30 @@ class CONTENT_EXPORT BufferQueue {
void RecreateBuffers();
- unsigned int current_texture_id() const { return current_surface_.texture; }
+ unsigned int current_texture_id() const { return current_surface_->texture; }
danakj 2015/12/10 01:36:02 do callers need to worry about null here? can they
ccameron 2015/12/10 07:39:27 Callers should worry. I'll preserve the old behavi
unsigned int fbo() const { return fbo_; }
private:
friend class BufferQueueTest;
+ friend class AllocatedSurface;
struct CONTENT_EXPORT AllocatedSurface {
- AllocatedSurface();
- AllocatedSurface(scoped_ptr<gfx::GpuMemoryBuffer> buffer,
+ AllocatedSurface(BufferQueue* buffer_queue,
+ scoped_ptr<gfx::GpuMemoryBuffer> buffer,
unsigned int texture,
unsigned int image,
const gfx::Rect& rect);
~AllocatedSurface();
- // TODO(ccameron): Change this to be a scoped_ptr, and change all use of
- // AllocatedSurface to use scoped_ptr as well.
- linked_ptr<gfx::GpuMemoryBuffer> buffer;
- unsigned int texture;
- unsigned int image;
+ BufferQueue* const buffer_queue;
+ scoped_ptr<gfx::GpuMemoryBuffer> buffer;
+ const unsigned int texture;
+ const unsigned int image;
gfx::Rect damage; // This is the damage for this frame from the previous.
};
void FreeAllSurfaces();
- void FreeSurface(AllocatedSurface* surface);
+ void FreeSurfaceResources(AllocatedSurface* surface);
// Copy everything that is in |copy_rect|, except for what is in
// |exclude_rect| from |source_texture| to |texture|.
@@ -86,9 +85,10 @@ class CONTENT_EXPORT BufferQueue {
void UpdateBufferDamage(const gfx::Rect& damage);
// Return a surface, available to be drawn into.
- AllocatedSurface GetNextSurface();
+ scoped_ptr<AllocatedSurface> GetNextSurface();
- AllocatedSurface RecreateBuffer(AllocatedSurface* surface);
+ scoped_ptr<AllocatedSurface> RecreateBuffer(
+ scoped_ptr<AllocatedSurface> surface);
gfx::Size size_;
scoped_refptr<cc::ContextProvider> context_provider_;
@@ -96,10 +96,16 @@ class CONTENT_EXPORT BufferQueue {
size_t allocated_count_;
unsigned int texture_target_;
unsigned int internal_format_;
- AllocatedSurface current_surface_; // This surface is currently bound.
- AllocatedSurface displayed_surface_; // The surface currently on the screen.
- std::vector<AllocatedSurface> available_surfaces_; // These are free for use.
- std::deque<AllocatedSurface> in_flight_surfaces_;
+ // This surface is currently bound. This may be nullptr if no surface has
+ // been bound, or if allocation failed at bind.
+ scoped_ptr<AllocatedSurface> current_surface_;
+ // The surface currently on the screen, if any.
+ scoped_ptr<AllocatedSurface> displayed_surface_;
+ // These are free for use, and are not nullptr.
+ std::vector<scoped_ptr<AllocatedSurface>> available_surfaces_;
+ // These have been swapped but are not displayed yet. Entries of this deque
+ // may be nullptr, if they represent frames that have been destroyed.
+ std::deque<scoped_ptr<AllocatedSurface>> in_flight_surfaces_;
GLHelper* gl_helper_;
BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager_;
int surface_id_;
« no previous file with comments | « no previous file | content/browser/compositor/buffer_queue.cc » ('j') | content/browser/compositor/buffer_queue.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698