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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.h

Issue 2257533006: Free worker context resources on idle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-cleanup2
Patch Set: fixes Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <queue> 14 #include <queue>
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <utility> 17 #include <utility>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/cancelable_callback.h"
20 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
21 #include "base/macros.h" 22 #include "base/macros.h"
22 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
23 #include "base/trace_event/memory_dump_provider.h" 24 #include "base/trace_event/memory_dump_provider.h"
24 #include "gpu/command_buffer/client/buffer_tracker.h" 25 #include "gpu/command_buffer/client/buffer_tracker.h"
25 #include "gpu/command_buffer/client/client_context_state.h" 26 #include "gpu/command_buffer/client/client_context_state.h"
26 #include "gpu/command_buffer/client/context_support.h" 27 #include "gpu/command_buffer/client/context_support.h"
27 #include "gpu/command_buffer/client/gles2_impl_export.h" 28 #include "gpu/command_buffer/client/gles2_impl_export.h"
28 #include "gpu/command_buffer/client/gles2_interface.h" 29 #include "gpu/command_buffer/client/gles2_interface.h"
29 #include "gpu/command_buffer/client/gpu_control_client.h" 30 #include "gpu/command_buffer/client/gpu_control_client.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const gfx::Rect& display_bounds, 205 const gfx::Rect& display_bounds,
205 const gfx::RectF& uv_rect) override; 206 const gfx::RectF& uv_rect) override;
206 uint64_t ShareGroupTracingGUID() const override; 207 uint64_t ShareGroupTracingGUID() const override;
207 void SetErrorMessageCallback( 208 void SetErrorMessageCallback(
208 const base::Callback<void(const char*, int32_t)>& callback) override; 209 const base::Callback<void(const char*, int32_t)>& callback) override;
209 std::unique_ptr<ScopedVisibility> ClientBecameVisible() override; 210 std::unique_ptr<ScopedVisibility> ClientBecameVisible() override;
210 void ClientBecameNotVisible( 211 void ClientBecameNotVisible(
211 std::unique_ptr<ScopedVisibility> visibility) override; 212 std::unique_ptr<ScopedVisibility> visibility) override;
212 bool AnyClientsVisible() const override; 213 bool AnyClientsVisible() const override;
213 214
215 std::unique_ptr<ScopedBusy> ClientBecameBusy() override;
216 void ClientBecameNotBusy(std::unique_ptr<ScopedBusy> busy) override;
217 void SetIdleCallback(const base::Closure& callback,
218 scoped_refptr<base::SingleThreadTaskRunner>
219 callback_task_runner) override;
220
214 // TODO(danakj): Move to ContextSupport once ContextProvider doesn't need to 221 // TODO(danakj): Move to ContextSupport once ContextProvider doesn't need to
215 // intercept it. 222 // intercept it.
216 void SetLostContextCallback(const base::Closure& callback); 223 void SetLostContextCallback(const base::Closure& callback);
217 224
218 void GetProgramInfoCHROMIUMHelper(GLuint program, 225 void GetProgramInfoCHROMIUMHelper(GLuint program,
219 std::vector<int8_t>* result); 226 std::vector<int8_t>* result);
220 GLint GetAttribLocationHelper(GLuint program, const char* name); 227 GLint GetAttribLocationHelper(GLuint program, const char* name);
221 GLint GetUniformLocationHelper(GLuint program, const char* name); 228 GLint GetUniformLocationHelper(GLuint program, const char* name);
222 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name); 229 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name);
223 GLint GetFragDataLocationHelper(GLuint program, const char* name); 230 GLint GetFragDataLocationHelper(GLuint program, const char* name);
(...skipping 30 matching lines...) Expand all
254 const char* function_name, GLuint id, GLenum pname, GLuint64* params); 261 const char* function_name, GLuint id, GLenum pname, GLuint64* params);
255 262
256 void FreeUnusedSharedMemory(); 263 void FreeUnusedSharedMemory();
257 void FreeEverything(); 264 void FreeEverything();
258 265
259 // ContextSupport implementation. 266 // ContextSupport implementation.
260 void SignalSyncToken(const gpu::SyncToken& sync_token, 267 void SignalSyncToken(const gpu::SyncToken& sync_token,
261 const base::Closure& callback) override; 268 const base::Closure& callback) override;
262 void SignalQuery(uint32_t query, const base::Closure& callback) override; 269 void SignalQuery(uint32_t query, const base::Closure& callback) override;
263 void SetAggressivelyFreeResources(bool aggressively_free_resources) override; 270 void SetAggressivelyFreeResources(bool aggressively_free_resources) override;
271 void TrimResources() override;
264 272
265 // base::trace_event::MemoryDumpProvider implementation. 273 // base::trace_event::MemoryDumpProvider implementation.
266 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 274 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
267 base::trace_event::ProcessMemoryDump* pmd) override; 275 base::trace_event::ProcessMemoryDump* pmd) override;
268 276
269 const scoped_refptr<ShareGroup>& share_group() const { return share_group_; } 277 const scoped_refptr<ShareGroup>& share_group() const { return share_group_; }
270 278
271 const Capabilities& capabilities() const { 279 const Capabilities& capabilities() const {
272 return capabilities_; 280 return capabilities_;
273 } 281 }
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 void RemoveMappedBufferRangeById(GLuint buffer); 696 void RemoveMappedBufferRangeById(GLuint buffer);
689 void ClearMappedBufferRangeMap(); 697 void ClearMappedBufferRangeMap();
690 698
691 void DrawElementsImpl(GLenum mode, GLsizei count, GLenum type, 699 void DrawElementsImpl(GLenum mode, GLsizei count, GLenum type,
692 const void* indices, const char* func_name); 700 const void* indices, const char* func_name);
693 void UpdateCachedExtensionsIfNeeded(); 701 void UpdateCachedExtensionsIfNeeded();
694 void InvalidateCachedExtensions(); 702 void InvalidateCachedExtensions();
695 703
696 PixelStoreParams GetUnpackParameters(Dimension dimension); 704 PixelStoreParams GetUnpackParameters(Dimension dimension);
697 705
706 void ScheduleIdleCallback();
707 void CancelIdleCallback();
708
698 GLES2Util util_; 709 GLES2Util util_;
699 GLES2CmdHelper* helper_; 710 GLES2CmdHelper* helper_;
700 TransferBufferInterface* transfer_buffer_; 711 TransferBufferInterface* transfer_buffer_;
701 std::string last_error_; 712 std::string last_error_;
702 DebugMarkerManager debug_marker_manager_; 713 DebugMarkerManager debug_marker_manager_;
703 std::string this_in_hex_; 714 std::string this_in_hex_;
704 715
705 std::queue<int32_t> swap_buffers_tokens_; 716 std::queue<int32_t> swap_buffers_tokens_;
706 std::queue<int32_t> rate_limit_tokens_; 717 std::queue<int32_t> rate_limit_tokens_;
707 718
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 826
816 std::unique_ptr<QueryTracker> query_tracker_; 827 std::unique_ptr<QueryTracker> query_tracker_;
817 std::unique_ptr<IdAllocator> query_id_allocator_; 828 std::unique_ptr<IdAllocator> query_id_allocator_;
818 829
819 std::unique_ptr<BufferTracker> buffer_tracker_; 830 std::unique_ptr<BufferTracker> buffer_tracker_;
820 831
821 base::Callback<void(const char*, int32_t)> error_message_callback_; 832 base::Callback<void(const char*, int32_t)> error_message_callback_;
822 base::Closure lost_context_callback_; 833 base::Closure lost_context_callback_;
823 bool lost_context_callback_run_ = false; 834 bool lost_context_callback_run_ = false;
824 835
836 base::Closure idle_callback_;
837 std::unique_ptr<base::CancelableClosure> pending_idle_callback_;
danakj 2016/08/23 01:26:25 why unique_ptr it?
ericrk 2016/08/24 18:32:21 You must create a CancelableClosure on the same th
838 scoped_refptr<base::SingleThreadTaskRunner> idle_callback_task_runner_;
839 bool is_idle_ = true;
840
825 int current_trace_stack_; 841 int current_trace_stack_;
826 842
827 GpuControl* gpu_control_; 843 GpuControl* gpu_control_;
828 844
829 Capabilities capabilities_; 845 Capabilities capabilities_;
830 846
831 // Flag to indicate whether the implementation can retain resources, or 847 // Flag to indicate whether the implementation can retain resources, or
832 // whether it should aggressively free them. 848 // whether it should aggressively free them.
833 bool aggressively_free_resources_ = false; 849 bool aggressively_free_resources_ = false;
834 850
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 900
885 inline bool GLES2Implementation::GetTexParameterivHelper( 901 inline bool GLES2Implementation::GetTexParameterivHelper(
886 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { 902 GLenum /* target */, GLenum /* pname */, GLint* /* params */) {
887 return false; 903 return false;
888 } 904 }
889 905
890 } // namespace gles2 906 } // namespace gles2
891 } // namespace gpu 907 } // namespace gpu
892 908
893 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ 909 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698