IDynamicTextureManager.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Drawing;
  29. using System.IO;
  30. using OpenMetaverse;
  31. namespace OpenSim.Region.Framework.Interfaces
  32. {
  33. public interface IDynamicTextureManager
  34. {
  35. void RegisterRender(string handleType, IDynamicTextureRender render);
  36. /// <summary>
  37. /// Used by IDynamicTextureRender implementations to return renders
  38. /// </summary>
  39. /// <param name='id'></param>
  40. /// <param name='data'></param>
  41. /// <param name='isReuseable'></param>
  42. void ReturnData(UUID id, IDynamicTexture texture);
  43. UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
  44. int updateTimer);
  45. UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
  46. int updateTimer, bool SetBlending, byte AlphaValue);
  47. UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
  48. int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
  49. UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
  50. int updateTimer);
  51. /// Apply a dynamically generated texture to all sides of the given prim. The texture is not persisted to the
  52. /// asset service.
  53. /// </summary>
  54. /// <param name="simID">The simulator in which the texture is being generated</param>
  55. /// <param name="primID">The prim to which to apply the texture.</param>
  56. /// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
  57. /// based texture or "image" to create a texture from an image at a particular URL</param>
  58. /// <param name="data">The data for the generator</param>
  59. /// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
  60. /// <param name="updateTimer">If zero, the image is never updated after the first generation. If positive
  61. /// the image is updated at the given interval. Not implemented for </param>
  62. /// <param name="SetBlending">
  63. /// If true, the newly generated texture is blended with the appropriate existing ones on the prim
  64. /// </param>
  65. /// <param name="AlphaValue">
  66. /// The alpha value of the generated texture.
  67. /// </param>
  68. /// <returns>
  69. /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
  70. /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
  71. /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
  72. /// </returns>
  73. UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
  74. int updateTimer, bool SetBlending, byte AlphaValue);
  75. /// <summary>
  76. /// Apply a dynamically generated texture to the given prim.
  77. /// </summary>
  78. /// <param name="simID">The simulator in which the texture is being generated</param>
  79. /// <param name="primID">The prim to which to apply the texture.</param>
  80. /// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
  81. /// based texture or "image" to create a texture from an image at a particular URL</param>
  82. /// <param name="data">The data for the generator</param>
  83. /// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
  84. /// <param name="updateTimer">If zero, the image is never updated after the first generation. If positive
  85. /// the image is updated at the given interval. Not implemented for </param>
  86. /// <param name="SetBlending">
  87. /// If true, the newly generated texture is blended with the appropriate existing ones on the prim
  88. /// </param>
  89. /// <param name="disp">
  90. /// Display flags. If DISP_EXPIRE then the old texture is deleted if it is replaced by a
  91. /// newer generated texture (may not currently be implemented). If DISP_TEMP then the asset is flagged as
  92. /// temporary, which often means that it is not persisted to the database.
  93. /// </param>
  94. /// <param name="AlphaValue">
  95. /// The alpha value of the generated texture.
  96. /// </param>
  97. /// <param name="face">
  98. /// The face of the prim on which to put the generated texture. If ALL_SIDES then all sides of the prim are
  99. /// set
  100. /// </param>
  101. /// <returns>
  102. /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
  103. /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
  104. /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
  105. /// </returns>
  106. UUID AddDynamicTextureData(
  107. UUID simID, UUID primID, string contentType, string data, string extraParams,
  108. int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face);
  109. void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
  110. out double xSize, out double ySize);
  111. }
  112. public interface IDynamicTextureRender
  113. {
  114. string GetName();
  115. string GetContentType();
  116. bool SupportsAsynchronous();
  117. // /// <summary>
  118. // /// Return true if converting the input body and extra params data will always result in the same byte[] array
  119. // /// </summary>
  120. // /// <remarks>
  121. // /// This method allows the caller to use a previously generated asset if it has one.
  122. // /// </remarks>
  123. // /// <returns></returns>
  124. // /// <param name='bodyData'></param>
  125. // /// <param name='extraParams'></param>
  126. // bool AlwaysIdenticalConversion(string bodyData, string extraParams);
  127. IDynamicTexture ConvertUrl(string url, string extraParams);
  128. IDynamicTexture ConvertData(string bodyData, string extraParams);
  129. bool AsyncConvertUrl(UUID id, string url, string extraParams);
  130. bool AsyncConvertData(UUID id, string bodyData, string extraParams);
  131. void GetDrawStringSize(string text, string fontName, int fontSize,
  132. out double xSize, out double ySize);
  133. }
  134. public interface IDynamicTexture
  135. {
  136. /// <summary>
  137. /// Input commands used to generate this data.
  138. /// </summary>
  139. /// <remarks>
  140. /// Null if input commands were not used.
  141. /// </remarks>
  142. string InputCommands { get; }
  143. /// <summary>
  144. /// Uri used to generate this data.
  145. /// </summary>
  146. /// <remarks>
  147. /// Null if a uri was not used.
  148. /// </remarks>
  149. Uri InputUri { get; }
  150. /// <summary>
  151. /// Extra input params used to generate this data.
  152. /// </summary>
  153. string InputParams { get; }
  154. /// <summary>
  155. /// Texture data.
  156. /// </summary>
  157. byte[] Data { get; }
  158. /// <summary>
  159. /// Size of texture.
  160. /// </summary>
  161. Size Size { get; }
  162. /// <summary>
  163. /// Signal whether the texture is reuseable (i.e. whether the same input data will always generate the same
  164. /// texture).
  165. /// </summary>
  166. bool IsReuseable { get; }
  167. }
  168. }