summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 05:22:28 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 05:22:28 +0000
commit54bf8134a16d70ae7302432d87420ecda6c1076b (patch)
tree4bd1a72d6a1e403aea1c566b271efc6047acbcf1
parent31a8825bab0ddfb7da147302f2646632ac63c18a (diff)
downloadchromium_src-54bf8134a16d70ae7302432d87420ecda6c1076b.zip
chromium_src-54bf8134a16d70ae7302432d87420ecda6c1076b.tar.gz
chromium_src-54bf8134a16d70ae7302432d87420ecda6c1076b.tar.bz2
Skeleton surface interfaces in cc/surfaces
This adds a very basic surface class with tests under cc/surfaces to establish gyp and DEPS rules. While this system is under early development it shouldn't be used by anything outside of unit tests. BUG=334090 Review URL: https://codereview.chromium.org/131893003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245137 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/DEPS1
-rw-r--r--cc/DEPS1
-rw-r--r--cc/cc.gyp24
-rw-r--r--cc/cc_tests.gyp49
-rw-r--r--cc/surfaces/OWNERS1
-rw-r--r--cc/surfaces/surface.cc24
-rw-r--r--cc/surfaces/surface.h37
-rw-r--r--cc/surfaces/surface_manager.cc37
-rw-r--r--cc/surfaces/surface_manager.h39
-rw-r--r--cc/surfaces/surface_unittest.cc29
-rw-r--r--cc/surfaces/surfaces_export.h29
-rw-r--r--content/DEPS1
-rw-r--r--content/common/DEPS1
-rw-r--r--ui/aura/bench/DEPS1
-rw-r--r--ui/compositor/DEPS1
-rw-r--r--ui/snapshot/DEPS1
-rw-r--r--webkit/DEPS1
17 files changed, 276 insertions, 1 deletions
diff --git a/android_webview/browser/DEPS b/android_webview/browser/DEPS
index 64fb2cf..c4c14e1 100644
--- a/android_webview/browser/DEPS
+++ b/android_webview/browser/DEPS
@@ -5,6 +5,7 @@ include_rules = [
"+android_webview/public/browser",
"+cc",
+ "-cc/surfaces",
"+components/auto_login_parser",
"+components/autofill/content/browser",
diff --git a/cc/DEPS b/cc/DEPS
index 2ae5c7b..7ce91dfc 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "-cc/surfaces", # cc shouldn't depend directly on the surface implementation
"+gpu/GLES2",
"+gpu/command_buffer/client/context_support.h",
"+gpu/command_buffer/client/gles2_interface.h",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index c9196db..f025568 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -21,6 +21,9 @@
'<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/ui/gl/gl.gyp:gl',
],
+ 'export_dependent_settings': [
+ '<(DEPTH)/skia/skia.gyp:skia',
+ ],
'defines': [
'CC_IMPLEMENTATION=1',
],
@@ -442,5 +445,26 @@
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
},
+ {
+ 'target_name': 'cc_surfaces',
+ 'type': '<(component)',
+ 'dependencies': [
+ 'cc',
+ '<(DEPTH)/base/base.gyp:base',
+ '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
+ ],
+ 'defines': [
+ 'CC_SURFACES_IMPLEMENTATION=1',
+ ],
+ 'sources': [
+ 'surfaces/surface.cc',
+ 'surfaces/surface.h',
+ 'surfaces/surface_manager.cc',
+ 'surfaces/surface_manager.h',
+ 'surfaces/surfaces_export.h',
+ ],
+ },
],
}
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 309604c..23793aa 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -347,6 +347,55 @@
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
},
+ {
+ 'target_name': 'cc_surfaces_unittests',
+ 'type': '<(gtest_target_type)',
+ 'dependencies': [
+ '../base/base.gyp:test_support_base',
+ '../media/media.gyp:media',
+ '../skia/skia.gyp:skia',
+ '../testing/gmock.gyp:gmock',
+ '../testing/gtest.gyp:gtest',
+ '../ui/gfx/gfx.gyp:gfx',
+ '../ui/gfx/gfx.gyp:gfx_geometry',
+ 'cc.gyp:cc',
+ 'cc.gyp:cc_surfaces',
+ 'cc_test_support',
+ ],
+ 'sources': [
+ 'test/run_all_unittests.cc',
+ 'test/cc_test_suite.cc',
+ 'surfaces/surface_unittest.cc',
+ ],
+ 'include_dirs': [
+ 'test',
+ '.',
+ ],
+ 'conditions': [
+ ['OS == "android" and gtest_target_type == "shared_library"',
+ {
+ 'dependencies': [
+ '../testing/android/native_test.gyp:native_test_native_code',
+ ],
+ }
+ ],
+ [ 'os_posix == 1 and OS != "mac" and OS != "android" and OS != "ios"',
+ {
+ 'conditions': [
+ [ 'linux_use_tcmalloc==1',
+ {
+ 'dependencies': [
+ '../base/allocator/allocator.gyp:allocator',
+ ],
+ }
+ ],
+ ],
+ }
+ ],
+ ],
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ 'msvs_disabled_warnings': [ 4267, ],
+ }
],
'conditions': [
# Special target to wrap a gtest_target_type==shared_library
diff --git a/cc/surfaces/OWNERS b/cc/surfaces/OWNERS
new file mode 100644
index 0000000..023e5fc
--- /dev/null
+++ b/cc/surfaces/OWNERS
@@ -0,0 +1 @@
+jamesr@chromium.org
diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc
new file mode 100644
index 0000000..12f360a
--- /dev/null
+++ b/cc/surfaces/surface.cc
@@ -0,0 +1,24 @@
+// Copyright 2014 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 "cc/surfaces/surface.h"
+
+#include "cc/surfaces/surface_manager.h"
+
+namespace cc {
+
+Surface::Surface(SurfaceManager* manager,
+ SurfaceClient* client,
+ const gfx::Size& size)
+ : manager_(manager),
+ client_(client),
+ size_(size) {
+ surface_id_ = manager_->RegisterAndAllocateIDForSurface(this);
+}
+
+Surface::~Surface() {
+ manager_->DeregisterSurface(surface_id_);
+}
+
+} // namespace cc
diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h
new file mode 100644
index 0000000..e18d121
--- /dev/null
+++ b/cc/surfaces/surface.h
@@ -0,0 +1,37 @@
+// Copyright 2014 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.
+
+#ifndef CC_SURFACES_SURFACE_H_
+#define CC_SURFACES_SURFACE_H_
+
+#include "base/macros.h"
+#include "cc/surfaces/surfaces_export.h"
+#include "ui/gfx/size.h"
+
+namespace cc {
+class SurfaceManager;
+class SurfaceClient;
+
+class CC_SURFACES_EXPORT Surface {
+ public:
+ Surface(SurfaceManager* manager,
+ SurfaceClient* client,
+ const gfx::Size& size);
+ ~Surface();
+
+ const gfx::Size& size() const { return size_; }
+ int surface_id() const { return surface_id_; }
+
+ private:
+ SurfaceManager* manager_;
+ SurfaceClient* client_;
+ gfx::Size size_;
+ int surface_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(Surface);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_SURFACE_H_
diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc
new file mode 100644
index 0000000..366fa81
--- /dev/null
+++ b/cc/surfaces/surface_manager.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 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 "cc/surfaces/surface_manager.h"
+
+#include "base/logging.h"
+
+namespace cc {
+
+SurfaceManager::SurfaceManager()
+ : next_surface_id_(1) {
+}
+
+SurfaceManager::~SurfaceManager() {}
+
+int SurfaceManager::RegisterAndAllocateIDForSurface(Surface* surface) {
+ DCHECK(surface);
+ int surface_id = next_surface_id_++;
+ surface_map_[surface_id] = surface;
+ return surface_id;
+}
+
+void SurfaceManager::DeregisterSurface(int surface_id) {
+ SurfaceMap::iterator it = surface_map_.find(surface_id);
+ DCHECK(it != surface_map_.end());
+ surface_map_.erase(it);
+}
+
+Surface* SurfaceManager::GetSurfaceForID(int surface_id) {
+ SurfaceMap::iterator it = surface_map_.find(surface_id);
+ if (it == surface_map_.end())
+ return NULL;
+ return it->second;
+}
+
+} // namespace cc
diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h
new file mode 100644
index 0000000..fe12dbf
--- /dev/null
+++ b/cc/surfaces/surface_manager.h
@@ -0,0 +1,39 @@
+// Copyright 2014 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.
+
+#ifndef CC_SURFACES_SURFACE_MANAGER_H_
+#define CC_SURFACES_SURFACE_MANAGER_H_
+
+#include "base/containers/hash_tables.h"
+#include "base/macros.h"
+#include "cc/surfaces/surfaces_export.h"
+
+namespace gfx { class Size; }
+
+namespace cc {
+class CompositorFrame;
+class Surface;
+
+class CC_SURFACES_EXPORT SurfaceManager {
+ public:
+ SurfaceManager();
+ ~SurfaceManager();
+
+ int RegisterAndAllocateIDForSurface(Surface* surface);
+ void DeregisterSurface(int surface_id);
+
+ Surface* GetSurfaceForID(int surface_id);
+
+ private:
+ typedef base::hash_map<int, Surface*> SurfaceMap;
+ SurfaceMap surface_map_;
+
+ int next_surface_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_SURFACE_MANAGER_H_
diff --git a/cc/surfaces/surface_unittest.cc b/cc/surfaces/surface_unittest.cc
new file mode 100644
index 0000000..669ec38
--- /dev/null
+++ b/cc/surfaces/surface_unittest.cc
@@ -0,0 +1,29 @@
+// Copyright 2014 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 "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/size.h"
+
+namespace cc {
+namespace {
+
+TEST(SurfaceTest, SurfaceLifetime) {
+ SurfaceManager manager;
+
+ int surface_id = 0;
+ {
+ Surface surface(&manager, NULL, gfx::Size(5, 5));
+ surface_id = surface.surface_id();
+ EXPECT_GT(surface_id, 0);
+ EXPECT_EQ(&surface, manager.GetSurfaceForID(surface_id));
+ }
+
+ EXPECT_EQ(NULL, manager.GetSurfaceForID(surface_id));
+}
+
+} // namespace
+} // namespace cc
+
diff --git a/cc/surfaces/surfaces_export.h b/cc/surfaces/surfaces_export.h
new file mode 100644
index 0000000..f849333
--- /dev/null
+++ b/cc/surfaces/surfaces_export.h
@@ -0,0 +1,29 @@
+// Copyright 2014 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.
+
+#ifndef CC_SURFACES_SURFACES_EXPORT_H_
+#define CC_SURFACES_SURFACES_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(CC_SURFACES_IMPLEMENTATION)
+#define CC_SURFACES_EXPORT __declspec(dllexport)
+#else
+#define CC_SURFACES_EXPORT __declspec(dllimport)
+#endif // defined(CC_SURFACES_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#if defined(CC_SURFACES_IMPLEMENTATION)
+#define CC_SURFACES_EXPORT __attribute__((visibility("default")))
+#else
+#define CC_SURFACES_EXPORT
+#endif
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define CC_SURFACES_EXPORT
+#endif
+
+#endif // CC_SURFACES_SURFACES_EXPORT_H_
diff --git a/content/DEPS b/content/DEPS
index 06f9207c..cf2821b 100644
--- a/content/DEPS
+++ b/content/DEPS
@@ -17,6 +17,7 @@ include_rules = [
"-base/prefs",
"+cc",
+ "-cc/surfaces",
# If you want to use any of these files, move them to src/base first.
"-cc/base/scoped_ptr_algorithm.h",
"-cc/base/scoped_ptr_deque.h",
diff --git a/content/common/DEPS b/content/common/DEPS
index 8cc7f01..d5629f2 100644
--- a/content/common/DEPS
+++ b/content/common/DEPS
@@ -1,5 +1,4 @@
include_rules = [
- "+cc",
"+media/audio",
"+media/base",
"-webkit/browser",
diff --git a/ui/aura/bench/DEPS b/ui/aura/bench/DEPS
index 70bd71c..319a251 100644
--- a/ui/aura/bench/DEPS
+++ b/ui/aura/bench/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+cc",
+ "-cc/surfaces",
"+gpu/command_buffer/client/gles2_interface.h",
"+third_party/khronos",
]
diff --git a/ui/compositor/DEPS b/ui/compositor/DEPS
index 80761f9..176fdc8 100644
--- a/ui/compositor/DEPS
+++ b/ui/compositor/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+cc",
+ "-cc/surfaces",
"+gpu/command_buffer/client/gles2_interface.h",
"+third_party/skia",
"+ui/gfx",
diff --git a/ui/snapshot/DEPS b/ui/snapshot/DEPS
index 7cdf34d..08ad30c 100644
--- a/ui/snapshot/DEPS
+++ b/ui/snapshot/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+cc",
+ "-cc/surfaces",
"+skia/ext",
"+third_party/skia",
"+ui/aura",
diff --git a/webkit/DEPS b/webkit/DEPS
index 4efa992..6e69dfd 100644
--- a/webkit/DEPS
+++ b/webkit/DEPS
@@ -9,6 +9,7 @@ include_rules = [
# For bridge/c/c_utility.h in npruntime_util.cc
"+bridge",
"+cc",
+ "-cc/surfaces",
"+grit", # For generated headers
"+skia",
"+third_party/angle",