summaryrefslogtreecommitdiffstats
path: root/cc/texture_update_queue.cc
blob: 0dc068325e9139598068a57f899a902932b77caf (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
// 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.

#include "config.h"

#include "cc/texture_update_queue.h"

#include "CCPrioritizedTexture.h"

namespace cc {

TextureUpdateQueue::TextureUpdateQueue()
{
}

TextureUpdateQueue::~TextureUpdateQueue()
{
}

void TextureUpdateQueue::appendFullUpload(const ResourceUpdate& upload)
{
    m_fullEntries.push_back(upload);
}

void TextureUpdateQueue::appendPartialUpload(const ResourceUpdate& upload)
{
    m_partialEntries.push_back(upload);
}

void TextureUpdateQueue::appendCopy(TextureCopier::Parameters copy)
{
    m_copyEntries.push_back(copy);
}

void TextureUpdateQueue::clearUploadsToEvictedResources()
{
    clearUploadsToEvictedResources(m_fullEntries);
    clearUploadsToEvictedResources(m_partialEntries);
}

void TextureUpdateQueue::clearUploadsToEvictedResources(std::deque<ResourceUpdate>& entryQueue)
{
    std::deque<ResourceUpdate> temp;
    entryQueue.swap(temp);
    while (temp.size()) {
        ResourceUpdate upload = temp.front();
        temp.pop_front();
        if (!upload.texture->backingResourceWasEvicted())
            entryQueue.push_back(upload);
    }
}

ResourceUpdate TextureUpdateQueue::takeFirstFullUpload()
{
    ResourceUpdate first = m_fullEntries.front();
    m_fullEntries.pop_front();
    return first;
}

ResourceUpdate TextureUpdateQueue::takeFirstPartialUpload()
{
    ResourceUpdate first = m_partialEntries.front();
    m_partialEntries.pop_front();
    return first;
}

TextureCopier::Parameters TextureUpdateQueue::takeFirstCopy()
{
    TextureCopier::Parameters first = m_copyEntries.front();
    m_copyEntries.pop_front();
    return first;
}

bool TextureUpdateQueue::hasMoreUpdates() const
{
    return m_fullEntries.size() || m_partialEntries.size() || m_copyEntries.size();
}

}