Line data Source code
1 0 : /* 2 : 3 : OONullTexture.m 4 : 5 : 6 : Copyright (C) 2008-2013 Jens Ayton 7 : 8 : Permission is hereby granted, free of charge, to any person obtaining a copy 9 : of this software and associated documentation files (the "Software"), to deal 10 : in the Software without restriction, including without limitation the rights 11 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 : copies of the Software, and to permit persons to whom the Software is 13 : furnished to do so, subject to the following conditions: 14 : 15 : The above copyright notice and this permission notice shall be included in all 16 : copies or substantial portions of the Software. 17 : 18 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 : SOFTWARE. 25 : 26 : */ 27 : 28 : #import "OONullTexture.h" 29 : #import "OOCocoa.h" 30 : #import "OOTextureInternal.h" 31 : 32 : 33 0 : static OONullTexture *sSingleton = nil; 34 : 35 : 36 : @implementation OONullTexture 37 : 38 : + (OONullTexture *) sharedNullTexture 39 : { 40 : // NOTE: assumes single-threaded access. 41 : if (sSingleton == nil) 42 : { 43 : sSingleton = [[self alloc] init]; 44 : } 45 : 46 : return sSingleton; 47 : } 48 : 49 : 50 0 : - (void) apply 51 : { 52 : [OOTexture applyNone]; 53 : } 54 : 55 : 56 0 : - (NSSize) dimensions 57 : { 58 : return NSZeroSize; 59 : } 60 : 61 : 62 0 : - (BOOL) isMipMapped 63 : { 64 : return NO; 65 : } 66 : 67 : 68 0 : - (void) forceRebind 69 : { 70 : 71 : } 72 : 73 : 74 : #ifndef NDEBUG 75 0 : - (NSString *) name 76 : { 77 : return @"<null texture>"; 78 : } 79 : #endif 80 : 81 : @end 82 : 83 : 84 : @implementation OONullTexture (Singleton) 85 : 86 : /* Canonical singleton boilerplate. 87 : See Cocoa Fundamentals Guide: Creating a Singleton Instance. 88 : See also +nullTexture above. 89 : 90 : NOTE: assumes single-threaded access. 91 : */ 92 : 93 0 : + (id)allocWithZone:(NSZone *)inZone 94 : { 95 : if (sSingleton == nil) 96 : { 97 : sSingleton = [super allocWithZone:inZone]; 98 : return sSingleton; 99 : } 100 : return nil; 101 : } 102 : 103 : 104 0 : - (id)copyWithZone:(NSZone *)inZone 105 : { 106 : return self; 107 : } 108 : 109 : 110 0 : - (id)retain 111 : { 112 : return self; 113 : } 114 : 115 : 116 0 : - (NSUInteger)retainCount 117 : { 118 : return UINT_MAX; 119 : } 120 : 121 : 122 0 : - (void)release 123 : {} 124 : 125 : 126 0 : - (id)autorelease 127 : { 128 : return self; 129 : } 130 : 131 : @end