ImfCompositeDeepScanLine.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2012, Weta Digital Ltd
  4. //
  5. // All rights reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. // * Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. // * Redistributions in binary form must reproduce the above
  13. // copyright notice, this list of conditions and the following disclaimer
  14. // in the documentation and/or other materials provided with the
  15. // distribution.
  16. // * Neither the name of Weta Digital nor the names of
  17. // its contributors may be used to endorse or promote products derived
  18. // from this software without specific prior written permission.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. //
  32. ///////////////////////////////////////////////////////////////////////////
  33. #ifndef INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H
  34. #define INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H
  35. //-----------------------------------------------------------------------------
  36. //
  37. // Class to composite deep samples into a frame buffer
  38. // Initialise with a deep input part or deep inputfile
  39. // (also supports multiple files and parts, and will
  40. // composite them together, as long as their sizes and channelmaps agree)
  41. //
  42. // Then call setFrameBuffer, and readPixels, exactly as for reading
  43. // regular scanline images.
  44. //
  45. // Restrictions - source file(s) must contain at least Z and alpha channels
  46. // - if multiple files/parts are provided, sizes must match
  47. // - all requested channels will be composited as premultiplied
  48. // - only half and float channels can be requested
  49. //
  50. // This object should not be considered threadsafe
  51. //
  52. // The default compositing engine will give spurious results with overlapping
  53. // volumetric samples - you may derive from DeepCompositing class, override the
  54. // sort_pixel() and composite_pixel() functions, and pass an instance to
  55. // setCompositing().
  56. //
  57. //-----------------------------------------------------------------------------
  58. #include "ImfForward.h"
  59. #include "ImfNamespace.h"
  60. #include "ImfExport.h"
  61. #include <ImathBox.h>
  62. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
  63. class CompositeDeepScanLine
  64. {
  65. public:
  66. IMF_EXPORT
  67. CompositeDeepScanLine();
  68. IMF_EXPORT
  69. virtual ~CompositeDeepScanLine();
  70. /// set the source data as a part
  71. ///@note all parts must remain valid until after last interaction with DeepComp
  72. IMF_EXPORT
  73. void addSource(DeepScanLineInputPart * part);
  74. /// set the source data as a file
  75. ///@note all file must remain valid until after last interaction with DeepComp
  76. IMF_EXPORT
  77. void addSource(DeepScanLineInputFile * file);
  78. /////////////////////////////////////////
  79. //
  80. // set the frame buffer for output values
  81. // the buffers specified must be large enough
  82. // to handle the dataWindow()
  83. //
  84. /////////////////////////////////////////
  85. IMF_EXPORT
  86. void setFrameBuffer(const FrameBuffer & fr);
  87. /////////////////////////////////////////
  88. //
  89. // retrieve frameBuffer
  90. //
  91. ////////////////////////////////////////
  92. IMF_EXPORT
  93. const FrameBuffer & frameBuffer() const;
  94. //////////////////////////////////////////////////
  95. //
  96. // read scanlines start to end from the source(s)
  97. // storing the result in the frame buffer provided
  98. //
  99. //////////////////////////////////////////////////
  100. IMF_EXPORT
  101. void readPixels(int start,int end);
  102. IMF_EXPORT
  103. int sources() const; // return number of sources
  104. /////////////////////////////////////////////////
  105. //
  106. // retrieve the datawindow
  107. // If multiple parts are specified, this will
  108. // be the union of the dataWindow of all parts
  109. //
  110. ////////////////////////////////////////////////
  111. IMF_EXPORT
  112. const IMATH_NAMESPACE::Box2i & dataWindow() const;
  113. //
  114. // override default sorting/compositing operation
  115. // (otherwise an instance of the base class will be used)
  116. //
  117. IMF_EXPORT
  118. void setCompositing(DeepCompositing *);
  119. struct Data;
  120. private :
  121. struct Data *_Data;
  122. CompositeDeepScanLine(const CompositeDeepScanLine &); // not implemented
  123. const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &); // not implemented
  124. };
  125. OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
  126. #endif