Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_ | |
| 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_ | |
|
nduca
2012/01/31 06:53:47
OK , so this file shouldn't exist. These individua
mmocny
2012/01/31 18:54:57
Done.
| |
| 7 #pragma once | |
| 8 | |
| 9 #if defined(ENABLE_GPU) | |
| 10 | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/time.h" | |
| 15 | |
| 16 #include "content/common/gpu/gpu_memory_allocation.h" | |
| 17 | |
| 18 //////////////////////////////////////////////////////////////////////////////// | |
| 19 | |
| 20 struct GpuSurfaceState { | |
|
nduca
2012/01/31 06:53:47
This I think should be a public inner struct calle
mmocny
2012/01/31 18:54:57
Done.
| |
| 21 int32 surface_id; | |
| 22 bool visible; | |
| 23 base::TimeTicks last_used_time; | |
| 24 }; | |
| 25 | |
| 26 //////////////////////////////////////////////////////////////////////////////// | |
| 27 | |
| 28 class GpuMemoryManageableCommandBufferStub { | |
|
nduca
2012/01/31 06:53:47
This should be a class in GpuCommandBufferStub and
mmocny
2012/01/31 18:54:57
Done.
| |
| 29 public: | |
| 30 virtual ~GpuMemoryManageableCommandBufferStub() {} | |
| 31 | |
| 32 virtual const GpuSurfaceState& surface_state() = 0; | |
| 33 virtual const std::vector<int32>& affected_surface_ids() = 0; | |
| 34 virtual void SendMemoryAllocation(const GpuMemoryAllocation& allocation) = 0; | |
|
nduca
2012/01/31 06:53:47
SendMemoryAllocationToProxy?
mmocny
2012/01/31 18:54:57
Done.
| |
| 35 }; | |
| 36 | |
| 37 class GpuMemoryManagerClient { | |
|
nduca
2012/01/31 06:53:47
This class should be defined in gpu_memory_manager
mmocny
2012/01/31 18:54:57
Done.
| |
| 38 public: | |
| 39 virtual ~GpuMemoryManagerClient() {} | |
| 40 | |
| 41 virtual void AppendAllCommandBufferStubs( | |
| 42 std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_with_surface, | |
| 43 std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_without_surface) | |
| 44 = 0; | |
| 45 }; | |
| 46 | |
| 47 //////////////////////////////////////////////////////////////////////////////// | |
| 48 | |
|
jonathan.backer
2012/01/31 18:13:58
I have a feeling that these comparators are only u
mmocny
2012/01/31 18:54:57
Also used in tests, but they are moved to GpuMemor
| |
| 49 /* | |
| 50 * Returns true if lhs stub is more "important" than rhs stub | |
| 51 */ | |
| 52 inline bool IsMoreImportant(GpuMemoryManageableCommandBufferStub* lhs, | |
|
nduca
2012/01/31 06:53:47
Why both a comparator and a function? Pick one or
mmocny
2012/01/31 18:54:57
Done.
| |
| 53 GpuMemoryManageableCommandBufferStub* rhs) { | |
| 54 const GpuSurfaceState& lhs_ss = lhs->surface_state(); | |
| 55 const GpuSurfaceState& rhs_ss = rhs->surface_state(); | |
| 56 | |
| 57 if (lhs_ss.visible) | |
| 58 return !rhs_ss.visible || (lhs_ss.last_used_time > rhs_ss.last_used_time); | |
| 59 else | |
| 60 return !rhs_ss.visible && (lhs_ss.last_used_time > rhs_ss.last_used_time); | |
| 61 } | |
| 62 | |
| 63 /* | |
| 64 * Comparator used to sort stubs into most-to-least "important" order | |
| 65 */ | |
| 66 struct StubComparator { | |
|
nduca
2012/01/31 06:53:47
class; struct feels awkward here.
nduca
2012/01/31 06:53:47
I think this should be an inner class in the GpuMe
mmocny
2012/01/31 18:54:57
Done.
mmocny
2012/01/31 18:54:57
Done.
| |
| 67 bool operator()(GpuMemoryManageableCommandBufferStub* lhs, | |
| 68 GpuMemoryManageableCommandBufferStub* rhs) { | |
| 69 return IsMoreImportant(lhs, rhs); | |
| 70 } | |
| 71 }; | |
| 72 | |
| 73 //////////////////////////////////////////////////////////////////////////////// | |
| 74 | |
| 75 #endif | |
| 76 | |
| 77 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGEMENT_H_ | |
| OLD | NEW |