| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_SURFACES_SURFACE_ID_H_ | 5 #ifndef CC_SURFACES_SURFACE_ID_H_ |
| 6 #define CC_SURFACES_SURFACE_ID_H_ | 6 #define CC_SURFACES_SURFACE_ID_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | 8 #include <stdint.h> |
| 10 | 9 |
| 11 #include <functional> | 10 #include <iosfwd> |
| 12 #include <string> | 11 #include <string> |
| 13 | 12 |
| 14 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 15 #include "base/hash.h" | 14 #include "base/hash.h" |
| 16 #include "base/strings/stringprintf.h" | |
| 17 #include "cc/surfaces/frame_sink_id.h" | 15 #include "cc/surfaces/frame_sink_id.h" |
| 18 #include "cc/surfaces/local_frame_id.h" | 16 #include "cc/surfaces/local_frame_id.h" |
| 19 | 17 |
| 20 namespace cc { | 18 namespace cc { |
| 21 | 19 |
| 22 class SurfaceId { | 20 class SurfaceId { |
| 23 public: | 21 public: |
| 24 constexpr SurfaceId() = default; | 22 constexpr SurfaceId() = default; |
| 25 | 23 |
| 26 constexpr SurfaceId(const SurfaceId& other) = default; | 24 constexpr SurfaceId(const SurfaceId& other) = default; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 | 40 |
| 43 size_t hash() const { | 41 size_t hash() const { |
| 44 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), | 42 return base::HashInts(static_cast<uint64_t>(frame_sink_id_.hash()), |
| 45 static_cast<uint64_t>(local_frame_id_.hash())); | 43 static_cast<uint64_t>(local_frame_id_.hash())); |
| 46 } | 44 } |
| 47 | 45 |
| 48 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 46 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 49 | 47 |
| 50 const LocalFrameId& local_frame_id() const { return local_frame_id_; } | 48 const LocalFrameId& local_frame_id() const { return local_frame_id_; } |
| 51 | 49 |
| 52 std::string ToString() const { | 50 std::string ToString() const; |
| 53 return base::StringPrintf("SurfaceId(%s, %s)", | |
| 54 frame_sink_id_.ToString().c_str(), | |
| 55 local_frame_id_.ToString().c_str()); | |
| 56 } | |
| 57 | 51 |
| 58 bool operator==(const SurfaceId& other) const { | 52 bool operator==(const SurfaceId& other) const { |
| 59 return frame_sink_id_ == other.frame_sink_id_ && | 53 return frame_sink_id_ == other.frame_sink_id_ && |
| 60 local_frame_id_ == other.local_frame_id_; | 54 local_frame_id_ == other.local_frame_id_; |
| 61 } | 55 } |
| 62 | 56 |
| 63 bool operator!=(const SurfaceId& other) const { return !(*this == other); } | 57 bool operator!=(const SurfaceId& other) const { return !(*this == other); } |
| 64 | 58 |
| 65 bool operator<(const SurfaceId& other) const { | 59 bool operator<(const SurfaceId& other) const { |
| 66 return std::tie(frame_sink_id_, local_frame_id_) < | 60 return std::tie(frame_sink_id_, local_frame_id_) < |
| 67 std::tie(other.frame_sink_id_, other.local_frame_id_); | 61 std::tie(other.frame_sink_id_, other.local_frame_id_); |
| 68 } | 62 } |
| 69 | 63 |
| 70 private: | 64 private: |
| 71 // See SurfaceIdAllocator::GenerateId. | 65 // See SurfaceIdAllocator::GenerateId. |
| 72 FrameSinkId frame_sink_id_; | 66 FrameSinkId frame_sink_id_; |
| 73 LocalFrameId local_frame_id_; | 67 LocalFrameId local_frame_id_; |
| 74 }; | 68 }; |
| 75 | 69 |
| 70 std::ostream& operator<<(std::ostream& out, const SurfaceId& surface_id); |
| 71 |
| 76 struct SurfaceIdHash { | 72 struct SurfaceIdHash { |
| 77 size_t operator()(const SurfaceId& key) const { return key.hash(); } | 73 size_t operator()(const SurfaceId& key) const { return key.hash(); } |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 } // namespace cc | 76 } // namespace cc |
| 81 | 77 |
| 82 #endif // CC_SURFACES_SURFACE_ID_H_ | 78 #endif // CC_SURFACES_SURFACE_ID_H_ |
| OLD | NEW |