OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/software_frame_manager.h" | 5 #include "content/browser/renderer_host/software_frame_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
12 #include "content/common/host_shared_bitmap_manager.h" | 12 #include "content/common/host_shared_bitmap_manager.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class FakeSoftwareFrameManagerClient : public SoftwareFrameManagerClient { | 17 class FakeSoftwareFrameManagerClient : public SoftwareFrameManagerClient { |
18 public: | 18 public: |
19 FakeSoftwareFrameManagerClient() | 19 FakeSoftwareFrameManagerClient() |
20 : evicted_count_(0), weak_ptr_factory_(this) { | 20 : evicted_count_(0), weak_ptr_factory_(this) { |
21 software_frame_manager_.reset(new SoftwareFrameManager( | 21 software_frame_manager_.reset(new SoftwareFrameManager( |
22 weak_ptr_factory_.GetWeakPtr())); | 22 weak_ptr_factory_.GetWeakPtr())); |
23 } | 23 } |
24 virtual ~FakeSoftwareFrameManagerClient() { | 24 virtual ~FakeSoftwareFrameManagerClient() { |
25 HostSharedBitmapManager::current()->ProcessRemoved( | 25 HostSharedBitmapManager::current()->ProcessRemoved( |
26 base::GetCurrentProcessHandle()); | 26 base::GetCurrentProcessHandle()); |
27 } | 27 } |
28 virtual void SoftwareFrameWasFreed(uint32 output_surface_id, | 28 virtual void SoftwareFrameWasFreed(uint32 output_surface_id, |
29 unsigned frame_id) OVERRIDE { | 29 unsigned frame_id) override { |
30 freed_frames_.push_back(std::make_pair(output_surface_id, frame_id)); | 30 freed_frames_.push_back(std::make_pair(output_surface_id, frame_id)); |
31 } | 31 } |
32 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE { | 32 virtual void ReleaseReferencesToSoftwareFrame() override { |
33 ++evicted_count_; | 33 ++evicted_count_; |
34 } | 34 } |
35 | 35 |
36 bool SwapToNewFrame(uint32 output_surface, unsigned frame_id) { | 36 bool SwapToNewFrame(uint32 output_surface, unsigned frame_id) { |
37 cc::SoftwareFrameData frame; | 37 cc::SoftwareFrameData frame; |
38 frame.id = frame_id; | 38 frame.id = frame_id; |
39 frame.size = gfx::Size(1, 1); | 39 frame.size = gfx::Size(1, 1); |
40 frame.damage_rect = gfx::Rect(frame.size); | 40 frame.damage_rect = gfx::Rect(frame.size); |
41 frame.bitmap_id = cc::SharedBitmap::GenerateId(); | 41 frame.bitmap_id = cc::SharedBitmap::GenerateId(); |
42 scoped_ptr<base::SharedMemory> memory = | 42 scoped_ptr<base::SharedMemory> memory = |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_EQ(1u, test_client->evicted_frame_count()); | 259 EXPECT_EQ(1u, test_client->evicted_frame_count()); |
260 callback->Run(0, false); | 260 callback->Run(0, false); |
261 callback.reset(); | 261 callback.reset(); |
262 EXPECT_EQ(10u, test_client->freed_frame_count()); | 262 EXPECT_EQ(10u, test_client->freed_frame_count()); |
263 EXPECT_EQ(1u, test_client->evicted_frame_count()); | 263 EXPECT_EQ(1u, test_client->evicted_frame_count()); |
264 | 264 |
265 FreeClients(); | 265 FreeClients(); |
266 } | 266 } |
267 | 267 |
268 } // namespace content | 268 } // namespace content |
OLD | NEW |