1
0

IDynamicTextureManager.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
  45. bool SetBlending, byte AlphaValue);
  46. UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
  47. bool SetBlending, int disp, byte AlphaValue, int face);
  48. UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams);
  49. /// Apply a dynamically generated texture to all sides of the given prim. The texture is not persisted to the
  50. /// asset service.
  51. /// </summary>
  52. /// <param name="simID">The simulator in which the texture is being generated</param>
  53. /// <param name="primID">The prim to which to apply the texture.</param>
  54. /// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
  55. /// based texture or "image" to create a texture from an image at a particular URL</param>
  56. /// <param name="data">The data for the generator</param>
  57. /// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
  58. /// <param name="SetBlending">
  59. /// If true, the newly generated texture is blended with the appropriate existing ones on the prim
  60. /// </param>
  61. /// <param name="AlphaValue">
  62. /// The alpha value of the generated texture.
  63. /// </param>
  64. /// <returns>
  65. /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
  66. /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
  67. /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
  68. /// </returns>
  69. UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
  70. bool SetBlending, byte AlphaValue);
  71. /// <summary>
  72. /// Apply a dynamically generated texture to the given prim.
  73. /// </summary>
  74. /// <param name="simID">The simulator in which the texture is being generated</param>
  75. /// <param name="primID">The prim to which to apply the texture.</param>
  76. /// <param name="contentType">The content type to create. Current choices are "vector" to create a vector
  77. /// based texture or "image" to create a texture from an image at a particular URL</param>
  78. /// <param name="data">The data for the generator</param>
  79. /// <param name="extraParams">Parameters for the generator that don't form part of the main data.</param>
  80. /// <param name="SetBlending">
  81. /// If true, the newly generated texture is blended with the appropriate existing ones on the prim
  82. /// </param>
  83. /// <param name="disp">
  84. /// Display flags. If DISP_EXPIRE then the old texture is deleted if it is replaced by a
  85. /// newer generated texture (may not currently be implemented). If DISP_TEMP then the asset is flagged as
  86. /// temporary, which often means that it is not persisted to the database.
  87. /// </param>
  88. /// <param name="AlphaValue">
  89. /// The alpha value of the generated texture.
  90. /// </param>
  91. /// <param name="face">
  92. /// The face of the prim on which to put the generated texture. If ALL_SIDES then all sides of the prim are
  93. /// set
  94. /// </param>
  95. /// <returns>
  96. /// The UUID of the texture updater, not the texture UUID. If you need the texture UUID then you will need
  97. /// to obtain it directly from the SceneObjectPart. For instance, if ALL_SIDES is set then this texture
  98. /// can be obtained as SceneObjectPart.Shape.Textures.DefaultTexture.TextureID
  99. /// </returns>
  100. UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
  101. bool SetBlending, int disp, byte AlphaValue, int face);
  102. void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
  103. out double xSize, out double ySize);
  104. }
  105. public interface IDynamicTextureRender
  106. {
  107. string GetName();
  108. string GetContentType();
  109. bool SupportsAsynchronous();
  110. // /// <summary>
  111. // /// Return true if converting the input body and extra params data will always result in the same byte[] array
  112. // /// </summary>
  113. // /// <remarks>
  114. // /// This method allows the caller to use a previously generated asset if it has one.
  115. // /// </remarks>
  116. // /// <returns></returns>
  117. // /// <param name='bodyData'></param>
  118. // /// <param name='extraParams'></param>
  119. // bool AlwaysIdenticalConversion(string bodyData, string extraParams);
  120. IDynamicTexture ConvertUrl(string url, string extraParams);
  121. IDynamicTexture ConvertData(string bodyData, string extraParams);
  122. bool AsyncConvertUrl(UUID id, string url, string extraParams);
  123. bool AsyncConvertData(UUID id, string bodyData, string extraParams);
  124. void GetDrawStringSize(string text, string fontName, int fontSize,
  125. out double xSize, out double ySize);
  126. }
  127. public interface IDynamicTexture
  128. {
  129. /// <summary>
  130. /// Input commands used to generate this data.
  131. /// </summary>
  132. /// <remarks>
  133. /// Null if input commands were not used.
  134. /// </remarks>
  135. string InputCommands { get; }
  136. /// <summary>
  137. /// Uri used to generate this data.
  138. /// </summary>
  139. /// <remarks>
  140. /// Null if a uri was not used.
  141. /// </remarks>
  142. Uri InputUri { get; }
  143. /// <summary>
  144. /// Extra input params used to generate this data.
  145. /// </summary>
  146. string InputParams { get; }
  147. /// <summary>
  148. /// Texture data.
  149. /// </summary>
  150. byte[] Data { get; }
  151. /// <summary>
  152. /// Size of texture.
  153. /// </summary>
  154. Size Size { get; }
  155. /// <summary>
  156. /// Signal whether the texture is reuseable (i.e. whether the same input data will always generate the same
  157. /// texture).
  158. /// </summary>
  159. bool IsReuseable { get; }
  160. }
  161. }