blob: b9fbfe10c4d7af3511c59c35276759a8e253ce46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright 2012 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_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
#define CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "cc/base/cc_export.h"
#include "cc/resources/resource_update_queue.h"
namespace base { class SingleThreadTaskRunner; }
namespace cc {
class ResourceProvider;
class ResourceUpdateControllerClient {
public:
virtual void ReadyToFinalizeTextureUpdates() = 0;
protected:
virtual ~ResourceUpdateControllerClient() {}
};
class CC_EXPORT ResourceUpdateController {
public:
static scoped_ptr<ResourceUpdateController> Create(
ResourceUpdateControllerClient* client,
base::SingleThreadTaskRunner* task_runner,
scoped_ptr<ResourceUpdateQueue> queue,
ResourceProvider* resource_provider) {
return make_scoped_ptr(new ResourceUpdateController(
client, task_runner, queue.Pass(), resource_provider));
}
static size_t MaxPartialTextureUpdates();
virtual ~ResourceUpdateController();
// Discard uploads to textures that were evicted on the impl thread.
void DiscardUploadsToEvictedResources();
void PerformMoreUpdates(base::TimeTicks time_limit);
void Finalize();
// Virtual for testing.
virtual base::TimeTicks Now() const;
virtual base::TimeDelta UpdateMoreTexturesTime() const;
virtual size_t UpdateMoreTexturesSize() const;
protected:
ResourceUpdateController(ResourceUpdateControllerClient* client,
base::SingleThreadTaskRunner* task_runner,
scoped_ptr<ResourceUpdateQueue> queue,
ResourceProvider* resource_provider);
private:
static size_t MaxFullUpdatesPerTick(ResourceProvider* resource_provider);
size_t MaxBlockingUpdates() const;
base::TimeDelta PendingUpdateTime() const;
void UpdateTexture(ResourceUpdate update);
// This returns true when there were textures left to update.
bool UpdateMoreTexturesIfEnoughTimeRemaining();
void UpdateMoreTexturesNow();
void OnTimerFired();
ResourceUpdateControllerClient* client_;
scoped_ptr<ResourceUpdateQueue> queue_;
bool contents_textures_purged_;
ResourceProvider* resource_provider_;
base::TimeTicks time_limit_;
size_t texture_updates_per_tick_;
bool first_update_attempt_;
base::SingleThreadTaskRunner* task_runner_;
base::WeakPtrFactory<ResourceUpdateController> weak_factory_;
bool task_posted_;
DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController);
};
} // namespace cc
#endif // CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
|