• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "cc/resources/resource_update_queue.h"
6 
7 #include "cc/resources/prioritized_resource.h"
8 
9 namespace cc {
10 
ResourceUpdateQueue()11 ResourceUpdateQueue::ResourceUpdateQueue() {}
12 
~ResourceUpdateQueue()13 ResourceUpdateQueue::~ResourceUpdateQueue() {}
14 
AppendFullUpload(const ResourceUpdate & upload)15 void ResourceUpdateQueue::AppendFullUpload(const ResourceUpdate& upload) {
16   full_entries_.push_back(upload);
17 }
18 
AppendPartialUpload(const ResourceUpdate & upload)19 void ResourceUpdateQueue::AppendPartialUpload(const ResourceUpdate& upload) {
20   partial_entries_.push_back(upload);
21 }
22 
ClearUploadsToEvictedResources()23 void ResourceUpdateQueue::ClearUploadsToEvictedResources() {
24   ClearUploadsToEvictedResources(&full_entries_);
25   ClearUploadsToEvictedResources(&partial_entries_);
26 }
27 
ClearUploadsToEvictedResources(std::deque<ResourceUpdate> * entry_queue)28 void ResourceUpdateQueue::ClearUploadsToEvictedResources(
29     std::deque<ResourceUpdate>* entry_queue) {
30   std::deque<ResourceUpdate> temp;
31   entry_queue->swap(temp);
32   while (temp.size()) {
33     ResourceUpdate upload = temp.front();
34     temp.pop_front();
35     if (!upload.texture->BackingResourceWasEvicted())
36       entry_queue->push_back(upload);
37   }
38 }
39 
TakeFirstFullUpload()40 ResourceUpdate ResourceUpdateQueue::TakeFirstFullUpload() {
41   ResourceUpdate first = full_entries_.front();
42   full_entries_.pop_front();
43   return first;
44 }
45 
TakeFirstPartialUpload()46 ResourceUpdate ResourceUpdateQueue::TakeFirstPartialUpload() {
47   ResourceUpdate first = partial_entries_.front();
48   partial_entries_.pop_front();
49   return first;
50 }
51 
HasMoreUpdates() const52 bool ResourceUpdateQueue::HasMoreUpdates() const {
53   return !full_entries_.empty() || !partial_entries_.empty();
54 }
55 
56 }  // namespace cc
57