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

Side by Side Diff: components/exo/buffer.h

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix deps Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_EXO_BUFFER_H_ 5 #ifndef COMPONENTS_EXO_BUFFER_H_
6 #define COMPONENTS_EXO_BUFFER_H_ 6 #define COMPONENTS_EXO_BUFFER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 // This function can be used to acquire a texture mailbox for the contents of 56 // This function can be used to acquire a texture mailbox for the contents of
57 // buffer. Returns a release callback on success. The release callback should 57 // buffer. Returns a release callback on success. The release callback should
58 // be called before a new texture mailbox can be acquired unless 58 // be called before a new texture mailbox can be acquired unless
59 // |non_client_usage| is true. 59 // |non_client_usage| is true.
60 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox( 60 std::unique_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox(
61 cc::TextureMailbox* mailbox, 61 cc::TextureMailbox* mailbox,
62 bool secure_output_only, 62 bool secure_output_only,
63 bool client_usage); 63 bool client_usage);
64 64
65 // This should be called when the buffer is attached to a Surface.
66 void OnAttach() { ++attach_count_; }
reveman 2016/06/23 00:44:38 Can you move this to .cc file and add a DLOG(WARNI
67
68 // This should be called when the buffer is detached from a surface.
69 void OnDetach();
70
65 // Returns the size of the buffer. 71 // Returns the size of the buffer.
66 gfx::Size GetSize() const; 72 gfx::Size GetSize() const;
67 73
68 // Returns a trace value representing the state of the buffer. 74 // Returns a trace value representing the state of the buffer.
69 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 75 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
70 76
71 private: 77 private:
72 class Texture; 78 class Texture;
73 79
74 // Decrements the use count of buffer and notifies the client that buffer 80 // Decrements the use count of buffer and notifies the client that buffer
75 // as been released if it reached 0. 81 // as been released if it reached 0.
76 void Release(); 82 void Release();
77 83
84 // Runs the release callback if the buffer isn't attached or in use.
85 void CheckReleaseCallback();
86
78 // This is used by ProduceTextureMailbox() to produce a release callback 87 // This is used by ProduceTextureMailbox() to produce a release callback
79 // that releases a texture so it can be destroyed or reused. 88 // that releases a texture so it can be destroyed or reused.
80 void ReleaseTexture(std::unique_ptr<Texture> texture); 89 void ReleaseTexture(std::unique_ptr<Texture> texture);
81 90
82 // This is used by ProduceTextureMailbox() to produce a release callback 91 // This is used by ProduceTextureMailbox() to produce a release callback
83 // that releases the buffer contents referenced by a texture before the 92 // that releases the buffer contents referenced by a texture before the
84 // texture is destroyed or reused. 93 // texture is destroyed or reused.
85 void ReleaseContentsTexture(std::unique_ptr<Texture> texture); 94 void ReleaseContentsTexture(std::unique_ptr<Texture> texture);
86 95
87 // The GPU memory buffer that contains the contents of this buffer. 96 // The GPU memory buffer that contains the contents of this buffer.
88 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; 97 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
89 98
90 // Texture target that must be used when creating a texture for buffer. 99 // Texture target that must be used when creating a texture for buffer.
91 const unsigned texture_target_; 100 const unsigned texture_target_;
92 101
93 // Query type that must be used when releasing buffer from a texture. 102 // Query type that must be used when releasing buffer from a texture.
94 const unsigned query_type_; 103 const unsigned query_type_;
95 104
96 // True if zero copy is used when producing a texture mailbox for buffer. 105 // True if zero copy is used when producing a texture mailbox for buffer.
97 const bool use_zero_copy_; 106 const bool use_zero_copy_;
98 107
99 // True if this buffer is an overlay candidate. 108 // True if this buffer is an overlay candidate.
100 const bool is_overlay_candidate_; 109 const bool is_overlay_candidate_;
101 110
102 // This is incremented when a texture mailbox is produced and decremented 111 // This is incremented when a texture mailbox is produced and decremented
103 // when a texture mailbox is released. It is used to determine when we should 112 // when a texture mailbox is released. It is used to determine when we should
104 // notify the client that buffer has been released. 113 // notify the client that buffer has been released.
105 unsigned use_count_; 114 unsigned use_count_;
106 115
116 // This keeps track of how many Surfaces the buffer is attached to.
117 unsigned attach_count_ = 0;
118
107 // The last used texture. ProduceTextureMailbox() will use this 119 // The last used texture. ProduceTextureMailbox() will use this
108 // instead of creating a new texture when possible. 120 // instead of creating a new texture when possible.
109 std::unique_ptr<Texture> texture_; 121 std::unique_ptr<Texture> texture_;
110 122
111 // The last used contents texture. ProduceTextureMailbox() will use this 123 // The last used contents texture. ProduceTextureMailbox() will use this
112 // instead of creating a new texture when possible. 124 // instead of creating a new texture when possible.
113 std::unique_ptr<Texture> contents_texture_; 125 std::unique_ptr<Texture> contents_texture_;
114 126
115 // The client release callback. 127 // The client release callback.
116 base::Closure release_callback_; 128 base::Closure release_callback_;
117 129
118 DISALLOW_COPY_AND_ASSIGN(Buffer); 130 DISALLOW_COPY_AND_ASSIGN(Buffer);
119 }; 131 };
120 132
121 } // namespace exo 133 } // namespace exo
122 134
123 #endif // COMPONENTS_EXO_BUFFER_H_ 135 #endif // COMPONENTS_EXO_BUFFER_H_
OLDNEW
« no previous file with comments | « components/exo/BUILD.gn ('k') | components/exo/buffer.cc » ('j') | components/exo/surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698