blob: 43de5ae27101701637fad7caa723a62a1b465c93 [file] [log] [blame]
tomhudson@google.com168e6342012-04-18 17:49:20 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "GrContext.h"
9#include "GrCustomStage.h"
tomhudson@google.comdcba4c22012-07-24 21:36:16 +000010#include "GrMemoryPool.h"
11#include "SkTLS.h"
tomhudson@google.com168e6342012-04-18 17:49:20 +000012
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000013SK_DEFINE_INST_COUNT(GrCustomStage)
14
tomhudson@google.comdcba4c22012-07-24 21:36:16 +000015class GrCustomStage_Globals {
16public:
17 static GrMemoryPool* GetTLS() {
18 return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
19 }
20
21private:
22 static void* CreateTLS() {
23 return SkNEW_ARGS(GrMemoryPool, (4096, 4096));
24 }
25
26 static void DeleteTLS(void* pool) {
27 SkDELETE(reinterpret_cast<GrMemoryPool*>(pool));
28 }
29};
30
bsalomon@google.comae4f96a2012-05-18 19:54:48 +000031int32_t GrProgramStageFactory::fCurrStageClassID =
32 GrProgramStageFactory::kIllegalStageClassID;
tomhudson@google.com168e6342012-04-18 17:49:20 +000033
bsalomon@google.comae4f96a2012-05-18 19:54:48 +000034GrCustomStage::GrCustomStage() {
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000035
tomhudson@google.com168e6342012-04-18 17:49:20 +000036}
37
38GrCustomStage::~GrCustomStage() {
39
40}
41
42bool GrCustomStage::isOpaque(bool inputTextureIsOpaque) const {
43 return false;
44}
45
tomhudson@google.comd0c1a062012-07-12 17:23:52 +000046bool GrCustomStage::isEqual(const GrCustomStage& s) const {
47 if (this->numTextures() != s.numTextures()) {
48 return false;
49 }
50 for (unsigned int i = 0; i < this->numTextures(); ++i) {
51 if (this->texture(i) != s.texture(i)) {
52 return false;
53 }
54 }
55 return true;
56}
57
58unsigned int GrCustomStage::numTextures() const {
59 return 0;
60}
61
62GrTexture* GrCustomStage::texture(unsigned int index) const {
63 return NULL;
64}
65
tomhudson@google.comdcba4c22012-07-24 21:36:16 +000066void * GrCustomStage::operator new(size_t size) {
67 return GrCustomStage_Globals::GetTLS()->allocate(size);
68}
69
70void GrCustomStage::operator delete(void* target) {
71 GrCustomStage_Globals::GetTLS()->release(target);
72}
73