| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 | 32 |
| 33 #include "core/cross/command_buffer/render_surface_cb.h" | 33 #include "core/cross/command_buffer/render_surface_cb.h" |
| 34 #include "command_buffer/client/cross/cmd_buffer_helper.h" | 34 #include "command_buffer/client/cross/cmd_buffer_helper.h" |
| 35 | 35 |
| 36 namespace o3d { | 36 namespace o3d { |
| 37 | 37 |
| 38 using command_buffer::ResourceID; | 38 using command_buffer::ResourceId; |
| 39 using command_buffer::CommandBufferEntry; | 39 using command_buffer::CommandBufferEntry; |
| 40 using command_buffer::CommandBufferHelper; | 40 using command_buffer::CommandBufferHelper; |
| 41 namespace create_render_surface_cmd = command_buffer::create_render_surface_cmd; | |
| 42 | 41 |
| 43 RenderSurfaceCB::RenderSurfaceCB(ServiceLocator *service_locator, | 42 RenderSurfaceCB::RenderSurfaceCB(ServiceLocator *service_locator, |
| 44 int width, | 43 int width, |
| 45 int height, | 44 int height, |
| 46 int mip_level, | 45 int mip_level, |
| 47 int side, | 46 int side, |
| 48 Texture *texture, | 47 Texture *texture, |
| 49 RendererCB *renderer) | 48 RendererCB *renderer) |
| 50 : RenderSurface(service_locator, width, height, texture), | 49 : RenderSurface(service_locator, width, height, texture), |
| 51 resource_id_(command_buffer::kInvalidResource), | 50 resource_id_(command_buffer::kInvalidResource), |
| 52 renderer_(renderer) { | 51 renderer_(renderer) { |
| 53 DCHECK_GT(width, 0); | 52 DCHECK_GT(width, 0); |
| 54 DCHECK_GT(height, 0); | 53 DCHECK_GT(height, 0); |
| 55 DCHECK_GT(mip_level, -1); | 54 DCHECK_GT(mip_level, -1); |
| 56 DCHECK(texture); | 55 DCHECK(texture); |
| 57 DCHECK(renderer); | 56 DCHECK(renderer); |
| 58 | 57 |
| 59 ResourceID id = renderer_->render_surface_ids().AllocateID(); | 58 ResourceId id = renderer_->render_surface_ids().AllocateID(); |
| 60 resource_id_ = id; | 59 resource_id_ = id; |
| 61 CommandBufferHelper *helper = renderer_->helper(); | 60 CommandBufferHelper *helper = renderer_->helper(); |
| 62 helper->CreateRenderSurface( | 61 helper->CreateRenderSurface( |
| 63 id, | 62 id, |
| 64 reinterpret_cast<uint32>(texture->GetTextureHandle()), | 63 reinterpret_cast<uint32>(texture->GetTextureHandle()), |
| 65 width, height, mip_level, side); | 64 width, height, mip_level, side); |
| 66 } | 65 } |
| 67 | 66 |
| 68 RenderSurfaceCB::~RenderSurfaceCB() { | 67 RenderSurfaceCB::~RenderSurfaceCB() { |
| 69 Destroy(); | 68 Destroy(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 83 ServiceLocator *service_locator, | 82 ServiceLocator *service_locator, |
| 84 int width, | 83 int width, |
| 85 int height, | 84 int height, |
| 86 RendererCB *renderer) | 85 RendererCB *renderer) |
| 87 : RenderDepthStencilSurface(service_locator, width, height), | 86 : RenderDepthStencilSurface(service_locator, width, height), |
| 88 resource_id_(command_buffer::kInvalidResource), | 87 resource_id_(command_buffer::kInvalidResource), |
| 89 renderer_(renderer) { | 88 renderer_(renderer) { |
| 90 DCHECK_GT(width, 0); | 89 DCHECK_GT(width, 0); |
| 91 DCHECK_GT(height, 0); | 90 DCHECK_GT(height, 0); |
| 92 DCHECK(renderer); | 91 DCHECK(renderer); |
| 93 ResourceID id = renderer_->depth_surface_ids().AllocateID(); | 92 ResourceId id = renderer_->depth_surface_ids().AllocateID(); |
| 94 resource_id_ = id; | 93 resource_id_ = id; |
| 95 CommandBufferHelper *helper = renderer_->helper(); | 94 CommandBufferHelper *helper = renderer_->helper(); |
| 96 helper->CreateDepthSurface(id, width, height); | 95 helper->CreateDepthSurface(id, width, height); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void RenderDepthStencilSurfaceCB::Destroy() { | 98 void RenderDepthStencilSurfaceCB::Destroy() { |
| 100 if (resource_id_ != command_buffer::kInvalidResource) { | 99 if (resource_id_ != command_buffer::kInvalidResource) { |
| 101 CommandBufferHelper *helper = renderer_->helper(); | 100 CommandBufferHelper *helper = renderer_->helper(); |
| 102 helper->DestroyDepthSurface(resource_id_); | 101 helper->DestroyDepthSurface(resource_id_); |
| 103 renderer_->depth_surface_ids().FreeID(resource_id_); | 102 renderer_->depth_surface_ids().FreeID(resource_id_); |
| 104 resource_id_ = command_buffer::kInvalidResource; | 103 resource_id_ = command_buffer::kInvalidResource; |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace o3d | 107 } // namespace o3d |
| 109 | 108 |
| OLD | NEW |