tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 1 | /* |
| 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.com | dcba4c2 | 2012-07-24 21:36:16 +0000 | [diff] [blame^] | 10 | #include "GrMemoryPool.h" |
| 11 | #include "SkTLS.h" |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 12 | |
robertphillips@google.com | 15e9d3e | 2012-06-21 20:25:03 +0000 | [diff] [blame] | 13 | SK_DEFINE_INST_COUNT(GrCustomStage) |
| 14 | |
tomhudson@google.com | dcba4c2 | 2012-07-24 21:36:16 +0000 | [diff] [blame^] | 15 | class GrCustomStage_Globals { |
| 16 | public: |
| 17 | static GrMemoryPool* GetTLS() { |
| 18 | return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS); |
| 19 | } |
| 20 | |
| 21 | private: |
| 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.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 31 | int32_t GrProgramStageFactory::fCurrStageClassID = |
| 32 | GrProgramStageFactory::kIllegalStageClassID; |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 33 | |
bsalomon@google.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 34 | GrCustomStage::GrCustomStage() { |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 35 | |
tomhudson@google.com | 168e634 | 2012-04-18 17:49:20 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | GrCustomStage::~GrCustomStage() { |
| 39 | |
| 40 | } |
| 41 | |
| 42 | bool GrCustomStage::isOpaque(bool inputTextureIsOpaque) const { |
| 43 | return false; |
| 44 | } |
| 45 | |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 46 | bool 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 | |
| 58 | unsigned int GrCustomStage::numTextures() const { |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | GrTexture* GrCustomStage::texture(unsigned int index) const { |
| 63 | return NULL; |
| 64 | } |
| 65 | |
tomhudson@google.com | dcba4c2 | 2012-07-24 21:36:16 +0000 | [diff] [blame^] | 66 | void * GrCustomStage::operator new(size_t size) { |
| 67 | return GrCustomStage_Globals::GetTLS()->allocate(size); |
| 68 | } |
| 69 | |
| 70 | void GrCustomStage::operator delete(void* target) { |
| 71 | GrCustomStage_Globals::GetTLS()->release(target); |
| 72 | } |
| 73 | |