/rs/java/android/renderscript/ProgramRaster.java

https://github.com/aizuzi/platform_frameworks_base · Java · 171 lines · 76 code · 27 blank · 68 comment · 6 complexity · 88c0799479f6f6a477465f4f8162e7b1 MD5 · raw file

  1. /*
  2. * Copyright (C) 2008 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package android.renderscript;
  17. import android.util.Log;
  18. /**
  19. * @hide
  20. * @deprecated in API 16
  21. * Program raster is primarily used to specify whether point sprites are enabled and to control
  22. * the culling mode. By default, back faces are culled.
  23. **/
  24. public class ProgramRaster extends BaseObj {
  25. /**
  26. * @deprecated in API 16
  27. **/
  28. public enum CullMode {
  29. /**
  30. * @deprecated in API 16
  31. **/
  32. BACK (0),
  33. /**
  34. * @deprecated in API 16
  35. **/
  36. FRONT (1),
  37. /**
  38. * @deprecated in API 16
  39. **/
  40. NONE (2);
  41. int mID;
  42. CullMode(int id) {
  43. mID = id;
  44. }
  45. }
  46. boolean mPointSprite;
  47. CullMode mCullMode;
  48. ProgramRaster(long id, RenderScript rs) {
  49. super(id, rs);
  50. mPointSprite = false;
  51. mCullMode = CullMode.BACK;
  52. }
  53. /**
  54. * @deprecated in API 16
  55. * Specifies whether vertices are rendered as screen aligned
  56. * elements of a specified size
  57. * @return whether point sprites are enabled
  58. */
  59. public boolean isPointSpriteEnabled() {
  60. return mPointSprite;
  61. }
  62. /**
  63. * @deprecated in API 16
  64. * Specifies how triangles are culled based on their orientation
  65. * @return cull mode
  66. */
  67. public CullMode getCullMode() {
  68. return mCullMode;
  69. }
  70. /**
  71. * @deprecated in API 16
  72. */
  73. public static ProgramRaster CULL_BACK(RenderScript rs) {
  74. if(rs.mProgramRaster_CULL_BACK == null) {
  75. ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
  76. builder.setCullMode(CullMode.BACK);
  77. rs.mProgramRaster_CULL_BACK = builder.create();
  78. }
  79. return rs.mProgramRaster_CULL_BACK;
  80. }
  81. /**
  82. * @deprecated in API 16
  83. */
  84. public static ProgramRaster CULL_FRONT(RenderScript rs) {
  85. if(rs.mProgramRaster_CULL_FRONT == null) {
  86. ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
  87. builder.setCullMode(CullMode.FRONT);
  88. rs.mProgramRaster_CULL_FRONT = builder.create();
  89. }
  90. return rs.mProgramRaster_CULL_FRONT;
  91. }
  92. /**
  93. * @deprecated in API 16
  94. */
  95. public static ProgramRaster CULL_NONE(RenderScript rs) {
  96. if(rs.mProgramRaster_CULL_NONE == null) {
  97. ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
  98. builder.setCullMode(CullMode.NONE);
  99. rs.mProgramRaster_CULL_NONE = builder.create();
  100. }
  101. return rs.mProgramRaster_CULL_NONE;
  102. }
  103. /**
  104. * @deprecated in API 16
  105. */
  106. public static class Builder {
  107. RenderScript mRS;
  108. boolean mPointSprite;
  109. CullMode mCullMode;
  110. /**
  111. * @deprecated in API 16
  112. */
  113. public Builder(RenderScript rs) {
  114. mRS = rs;
  115. mPointSprite = false;
  116. mCullMode = CullMode.BACK;
  117. }
  118. /**
  119. * @deprecated in API 16
  120. */
  121. public Builder setPointSpriteEnabled(boolean enable) {
  122. mPointSprite = enable;
  123. return this;
  124. }
  125. /**
  126. * @deprecated in API 16
  127. */
  128. public Builder setCullMode(CullMode m) {
  129. mCullMode = m;
  130. return this;
  131. }
  132. /**
  133. * @deprecated in API 16
  134. */
  135. public ProgramRaster create() {
  136. mRS.validate();
  137. long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
  138. ProgramRaster programRaster = new ProgramRaster(id, mRS);
  139. programRaster.mPointSprite = mPointSprite;
  140. programRaster.mCullMode = mCullMode;
  141. return programRaster;
  142. }
  143. }
  144. }