OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 #include "webkit/common/gpu/managed_memory_policy_convert.h" |
| 6 |
| 7 namespace webkit { |
| 8 namespace gpu { |
| 9 |
| 10 static cc::ManagedMemoryPolicy::PriorityCutoff ConvertPriorityCutoff( |
| 11 WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff) { |
| 12 // This is simple a 1:1 map, the names differ only because the WebKit names |
| 13 // should be to match the cc names. |
| 14 switch (priority_cutoff) { |
| 15 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: |
| 16 return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; |
| 17 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: |
| 18 return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; |
| 19 case WebKit::WebGraphicsMemoryAllocation:: |
| 20 PriorityCutoffAllowVisibleAndNearby: |
| 21 return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 22 case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: |
| 23 return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; |
| 24 } |
| 25 NOTREACHED(); |
| 26 return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; |
| 27 } |
| 28 |
| 29 // static |
| 30 cc::ManagedMemoryPolicy ManagedMemoryPolicyConvert::Convert( |
| 31 const WebKit::WebGraphicsMemoryAllocation& allocation, |
| 32 bool* discard_backbuffer_when_not_visible) { |
| 33 *discard_backbuffer_when_not_visible = !allocation.suggestHaveBackbuffer; |
| 34 return cc::ManagedMemoryPolicy( |
| 35 allocation.bytesLimitWhenVisible, |
| 36 ConvertPriorityCutoff(allocation.priorityCutoffWhenVisible), |
| 37 allocation.bytesLimitWhenNotVisible, |
| 38 ConvertPriorityCutoff(allocation.priorityCutoffWhenNotVisible), |
| 39 cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit); |
| 40 } |
| 41 |
| 42 } // namespace gpu |
| 43 } // namespace webkit |
OLD | NEW |