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

Unified Diff: webkit/common/gpu/managed_memory_policy_convert.cc

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/common/gpu/managed_memory_policy_convert.h ('k') | webkit/common/gpu/webkit_gpu.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/common/gpu/managed_memory_policy_convert.cc
diff --git a/webkit/common/gpu/managed_memory_policy_convert.cc b/webkit/common/gpu/managed_memory_policy_convert.cc
new file mode 100644
index 0000000000000000000000000000000000000000..548e2aea65350b27aa563ba9685e97d96d1f5c5f
--- /dev/null
+++ b/webkit/common/gpu/managed_memory_policy_convert.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/common/gpu/managed_memory_policy_convert.h"
+
+namespace webkit {
+namespace gpu {
+
+static cc::ManagedMemoryPolicy::PriorityCutoff ConvertPriorityCutoff(
+ WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff) {
+ // This is simple a 1:1 map, the names differ only because the WebKit names
+ // should be to match the cc names.
+ switch (priority_cutoff) {
+ case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing:
+ return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
+ case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly:
+ return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY;
+ case WebKit::WebGraphicsMemoryAllocation::
+ PriorityCutoffAllowVisibleAndNearby:
+ return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE;
+ case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything:
+ return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING;
+ }
+ NOTREACHED();
+ return cc::ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
+}
+
+// static
+cc::ManagedMemoryPolicy ManagedMemoryPolicyConvert::Convert(
+ const WebKit::WebGraphicsMemoryAllocation& allocation,
+ bool* discard_backbuffer_when_not_visible) {
+ *discard_backbuffer_when_not_visible = !allocation.suggestHaveBackbuffer;
+ return cc::ManagedMemoryPolicy(
+ allocation.bytesLimitWhenVisible,
+ ConvertPriorityCutoff(allocation.priorityCutoffWhenVisible),
+ allocation.bytesLimitWhenNotVisible,
+ ConvertPriorityCutoff(allocation.priorityCutoffWhenNotVisible),
+ cc::ManagedMemoryPolicy::kDefaultNumResourcesLimit);
+}
+
+} // namespace gpu
+} // namespace webkit
« no previous file with comments | « webkit/common/gpu/managed_memory_policy_convert.h ('k') | webkit/common/gpu/webkit_gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698