|
14 | 14 | CubismOffscreenFrame_Metal::CubismOffscreenFrame_Metal() |
15 | 15 | : _colorBuffer(NULL) |
16 | 16 | , _renderPassDescriptor(NULL) |
17 | | - , _isInheritedRenderTexture(false) |
18 | 17 | , _bufferWidth(0) |
19 | 18 | , _bufferHeight(0) |
20 | 19 | , _pixelFormat(MTLPixelFormatRGBA8Unorm) |
|
32 | 31 |
|
33 | 32 | do |
34 | 33 | { |
35 | | - if (colorBuffer == nil) |
| 34 | + if (colorBuffer == NULL) |
36 | 35 | { |
37 | 36 | csmBool initResult = false; |
38 | 37 |
|
39 | | - _renderPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor]; |
| 38 | + _renderPassDescriptor = [[MTLRenderPassDescriptor alloc] init]; |
40 | 39 | _renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; |
41 | 40 | _renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore; |
42 | 41 | _renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(_clearColorR, _clearColorG, _clearColorB, _clearColorA); |
|
47 | 46 |
|
48 | 47 | _renderPassDescriptor.renderTargetWidth = displayBufferWidth; |
49 | 48 | _renderPassDescriptor.renderTargetHeight = displayBufferHeight; |
50 | | - _isInheritedRenderTexture = false; |
51 | 49 |
|
52 | 50 | // Set up a texture for rendering to and sampling from |
53 | | - MTLTextureDescriptor *texDescriptor = [[MTLTextureDescriptor alloc] init]; |
| 51 | + MTLTextureDescriptor *texDescriptor = [[[MTLTextureDescriptor alloc] init] autorelease]; |
54 | 52 | texDescriptor.textureType = MTLTextureType2D; |
55 | 53 | texDescriptor.width = displayBufferWidth; |
56 | 54 | texDescriptor.height = displayBufferHeight; |
|
65 | 63 | else |
66 | 64 | { |
67 | 65 | _colorBuffer = colorBuffer; |
68 | | - _isInheritedRenderTexture = true; |
69 | 66 | } |
70 | 67 |
|
71 | 68 | if (_colorBuffer) |
|
94 | 91 |
|
95 | 92 | void CubismOffscreenFrame_Metal::DestroyOffscreenFrame() |
96 | 93 | { |
97 | | - if (!_isInheritedRenderTexture) |
| 94 | + if (_colorBuffer != NULL) |
98 | 95 | { |
| 96 | + [_colorBuffer release]; |
99 | 97 | _colorBuffer = NULL; |
100 | 98 | } |
| 99 | + |
| 100 | + if (_renderPassDescriptor != NULL) |
| 101 | + { |
| 102 | + [_renderPassDescriptor release]; |
| 103 | + _renderPassDescriptor = NULL; |
| 104 | + } |
101 | 105 | } |
102 | 106 |
|
103 | 107 | id <MTLTexture> CubismOffscreenFrame_Metal::GetColorBuffer() const |
|
0 commit comments