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

Side by Side Diff: cc/surfaces/surface_manager_ref_unittest.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 13 matching lines...) Expand all
24 constexpr LocalFrameId kLocalFrame1(1, 0); 24 constexpr LocalFrameId kLocalFrame1(1, 0);
25 constexpr LocalFrameId kLocalFrame2(2, 0); 25 constexpr LocalFrameId kLocalFrame2(2, 0);
26 26
27 // Tests for reference tracking in SurfaceManager. 27 // Tests for reference tracking in SurfaceManager.
28 class SurfaceManagerRefTest : public testing::Test { 28 class SurfaceManagerRefTest : public testing::Test {
29 public: 29 public:
30 SurfaceManager& manager() { return *manager_; } 30 SurfaceManager& manager() { return *manager_; }
31 31
32 // Creates a new Surface with the provided SurfaceId. Will first create the 32 // Creates a new Surface with the provided SurfaceId. Will first create the
33 // SurfaceFactory for |frame_sink_id| if necessary. 33 // SurfaceFactory for |frame_sink_id| if necessary.
34 SurfaceId CreateSurface(const FrameSinkId& frame_sink_id, 34 SurfaceId CreateSurface(const FrameSinkId& frame_sink_id,
Fady Samuel 2016/11/08 22:23:59 This method doesn't really make sense.
Saman Sami 2016/11/11 17:49:58 Since the code never sends a frame, I have to do t
35 const LocalFrameId& local_frame_id) { 35 const LocalFrameId& local_frame_id) {
36 GetFactory(frame_sink_id).Create(local_frame_id); 36 GetFactory(frame_sink_id)
37 .SubmitCompositorFrame(local_frame_id, CompositorFrame(),
38 SurfaceFactory::DrawCallback());
37 return SurfaceId(frame_sink_id, local_frame_id); 39 return SurfaceId(frame_sink_id, local_frame_id);
38 } 40 }
39 41
40 // Destroy Surface with |surface_id|. 42 // Destroy Surface with |surface_id|.
41 void DestroySurface(const SurfaceId& surface_id) { 43 void DestroySurface(const SurfaceId& surface_id) {
Fady Samuel 2016/11/08 22:23:59 This method doesn't really make sense.
Saman Sami 2016/11/11 17:49:58 Same
42 GetFactory(surface_id.frame_sink_id()).Destroy(surface_id.local_frame_id()); 44 GetFactory(surface_id.frame_sink_id())
45 .SubmitCompositorFrame(LocalFrameId(), CompositorFrame(),
46 SurfaceFactory::DrawCallback());
43 } 47 }
44 48
45 protected: 49 protected:
46 SurfaceFactory& GetFactory(const FrameSinkId& frame_sink_id) { 50 SurfaceFactory& GetFactory(const FrameSinkId& frame_sink_id) {
47 auto& factory_ptr = factories_[frame_sink_id]; 51 auto& factory_ptr = factories_[frame_sink_id];
48 if (!factory_ptr) 52 if (!factory_ptr)
49 factory_ptr = base::MakeUnique<SurfaceFactory>(frame_sink_id, 53 factory_ptr = base::MakeUnique<SurfaceFactory>(frame_sink_id,
50 manager_.get(), nullptr); 54 manager_.get(), nullptr);
51 return *factory_ptr; 55 return *factory_ptr;
52 } 56 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 SurfaceId id2 = CreateSurface(kFrameSink2, kLocalFrame1); 288 SurfaceId id2 = CreateSurface(kFrameSink2, kLocalFrame1);
285 289
286 // Removing non-existent reference should be ignored. 290 // Removing non-existent reference should be ignored.
287 manager().AddSurfaceReference(id1, id2); 291 manager().AddSurfaceReference(id1, id2);
288 manager().RemoveSurfaceReference(id2, id1); 292 manager().RemoveSurfaceReference(id2, id1);
289 EXPECT_EQ(manager().GetReferencedSurfaceCount(id1), 1u); 293 EXPECT_EQ(manager().GetReferencedSurfaceCount(id1), 1u);
290 EXPECT_EQ(manager().GetSurfaceReferenceCount(id2), 1u); 294 EXPECT_EQ(manager().GetSurfaceReferenceCount(id2), 1u);
291 } 295 }
292 296
293 } // namespace cc 297 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698