aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrCustomStage.cpp
blob: b9ad4eabc62ad5e4f9cdc24841ac1ca44d38f2ec (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
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrContext.h"
#include "GrCustomStage.h"
#include "GrMemoryPool.h"
#include "SkTLS.h"

SK_DEFINE_INST_COUNT(GrCustomStage)

#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
SkTArray<GrCustomStageTestFactory*, true>* GrCustomStageTestFactory::GetFactories() {
    static SkTArray<GrCustomStageTestFactory*, true> gFactories;
    return &gFactories;
}
#endif

class GrCustomStage_Globals {
public:
    static GrMemoryPool* GetTLS() {
        return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
    }

private:
    static void* CreateTLS() {
        return SkNEW_ARGS(GrMemoryPool, (4096, 4096));
    }

    static void DeleteTLS(void* pool) {
        SkDELETE(reinterpret_cast<GrMemoryPool*>(pool));
    }
};

int32_t GrProgramStageFactory::fCurrStageClassID =
                                    GrProgramStageFactory::kIllegalStageClassID;

GrCustomStage::GrCustomStage() {

}

GrCustomStage::~GrCustomStage() {

}

bool GrCustomStage::isOpaque(bool inputTextureIsOpaque) const {
    return false;
}

bool GrCustomStage::isEqual(const GrCustomStage& s) const {
    if (this->numTextures() != s.numTextures()) {
        return false;
    }
    for (int i = 0; i < this->numTextures(); ++i) {
        if (this->textureAccess(i) != s.textureAccess(i)) {
            return false;
        }
    }
    return true;
}

int GrCustomStage::numTextures() const {
    return 0;
}

const GrTextureAccess& GrCustomStage::textureAccess(int index) const {
    GrCrash("We shouldn't be calling this function on the base class.");
    static GrTextureAccess kDummy;
    return kDummy;
}

void * GrCustomStage::operator new(size_t size) {
    return GrCustomStage_Globals::GetTLS()->allocate(size);
}

void GrCustomStage::operator delete(void* target) {
    GrCustomStage_Globals::GetTLS()->release(target);
}