2009-09-23 13:57:02 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package android.renderscript;
|
|
|
|
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
2012-05-07 15:34:29 -07:00
|
|
|
/**
|
2012-05-08 19:02:07 -07:00
|
|
|
* @deprecated in API 16
|
2011-02-09 13:57:06 -08:00
|
|
|
* Program raster is primarily used to specify whether point sprites are enabled and to control
|
|
|
|
* the culling mode. By default, back faces are culled.
|
2009-09-23 13:57:02 -07:00
|
|
|
**/
|
|
|
|
public class ProgramRaster extends BaseObj {
|
2010-07-12 15:50:32 -07:00
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
**/
|
2010-07-12 15:50:32 -07:00
|
|
|
public enum CullMode {
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
**/
|
2010-07-12 15:50:32 -07:00
|
|
|
BACK (0),
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
**/
|
2010-07-12 15:50:32 -07:00
|
|
|
FRONT (1),
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
**/
|
2010-07-12 15:50:32 -07:00
|
|
|
NONE (2);
|
|
|
|
|
|
|
|
int mID;
|
|
|
|
CullMode(int id) {
|
|
|
|
mID = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-23 13:57:02 -07:00
|
|
|
boolean mPointSprite;
|
2010-07-12 15:50:32 -07:00
|
|
|
CullMode mCullMode;
|
2009-09-23 13:57:02 -07:00
|
|
|
|
|
|
|
ProgramRaster(int id, RenderScript rs) {
|
2010-08-11 14:41:28 -07:00
|
|
|
super(id, rs);
|
2009-09-23 13:57:02 -07:00
|
|
|
|
|
|
|
mPointSprite = false;
|
2010-07-12 15:50:32 -07:00
|
|
|
mCullMode = CullMode.BACK;
|
2009-09-23 13:57:02 -07:00
|
|
|
}
|
|
|
|
|
2012-05-07 15:34:29 -07:00
|
|
|
/**
|
2012-05-08 19:02:07 -07:00
|
|
|
* @deprecated in API 16
|
2012-04-11 14:04:23 -07:00
|
|
|
* Specifies whether vertices are rendered as screen aligned
|
|
|
|
* elements of a specified size
|
2011-10-18 11:08:31 -07:00
|
|
|
* @return whether point sprites are enabled
|
|
|
|
*/
|
2012-04-11 14:04:23 -07:00
|
|
|
public boolean isPointSpriteEnabled() {
|
2011-10-18 11:08:31 -07:00
|
|
|
return mPointSprite;
|
|
|
|
}
|
|
|
|
|
2012-05-07 15:34:29 -07:00
|
|
|
/**
|
2012-05-08 19:02:07 -07:00
|
|
|
* @deprecated in API 16
|
2012-04-11 14:04:23 -07:00
|
|
|
* Specifies how triangles are culled based on their orientation
|
2011-10-18 11:08:31 -07:00
|
|
|
* @return cull mode
|
|
|
|
*/
|
|
|
|
public CullMode getCullMode() {
|
|
|
|
return mCullMode;
|
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-08-24 11:37:33 -07:00
|
|
|
public static ProgramRaster CULL_BACK(RenderScript rs) {
|
|
|
|
if(rs.mProgramRaster_CULL_BACK == null) {
|
|
|
|
ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
|
|
|
|
builder.setCullMode(CullMode.BACK);
|
|
|
|
rs.mProgramRaster_CULL_BACK = builder.create();
|
|
|
|
}
|
|
|
|
return rs.mProgramRaster_CULL_BACK;
|
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-08-24 11:37:33 -07:00
|
|
|
public static ProgramRaster CULL_FRONT(RenderScript rs) {
|
|
|
|
if(rs.mProgramRaster_CULL_FRONT == null) {
|
|
|
|
ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
|
|
|
|
builder.setCullMode(CullMode.FRONT);
|
|
|
|
rs.mProgramRaster_CULL_FRONT = builder.create();
|
|
|
|
}
|
|
|
|
return rs.mProgramRaster_CULL_FRONT;
|
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-08-24 11:37:33 -07:00
|
|
|
public static ProgramRaster CULL_NONE(RenderScript rs) {
|
|
|
|
if(rs.mProgramRaster_CULL_NONE == null) {
|
|
|
|
ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
|
|
|
|
builder.setCullMode(CullMode.NONE);
|
|
|
|
rs.mProgramRaster_CULL_NONE = builder.create();
|
|
|
|
}
|
|
|
|
return rs.mProgramRaster_CULL_NONE;
|
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2009-09-23 13:57:02 -07:00
|
|
|
public static class Builder {
|
|
|
|
RenderScript mRS;
|
2010-07-12 15:50:32 -07:00
|
|
|
boolean mPointSprite;
|
2010-08-24 11:37:33 -07:00
|
|
|
CullMode mCullMode;
|
2009-09-23 13:57:02 -07:00
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-07-12 15:50:32 -07:00
|
|
|
public Builder(RenderScript rs) {
|
|
|
|
mRS = rs;
|
|
|
|
mPointSprite = false;
|
2010-08-24 11:37:33 -07:00
|
|
|
mCullMode = CullMode.BACK;
|
2009-09-23 13:57:02 -07:00
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-12-21 14:42:26 -08:00
|
|
|
public Builder setPointSpriteEnabled(boolean enable) {
|
2010-07-12 15:50:32 -07:00
|
|
|
mPointSprite = enable;
|
2010-07-07 14:24:21 -07:00
|
|
|
return this;
|
2009-09-23 13:57:02 -07:00
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2010-08-24 11:37:33 -07:00
|
|
|
public Builder setCullMode(CullMode m) {
|
|
|
|
mCullMode = m;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-05-08 19:02:07 -07:00
|
|
|
/**
|
|
|
|
* @deprecated in API 16
|
|
|
|
*/
|
2009-09-23 13:57:02 -07:00
|
|
|
public ProgramRaster create() {
|
2009-12-07 12:40:12 -08:00
|
|
|
mRS.validate();
|
2011-09-23 14:18:53 -07:00
|
|
|
int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
|
2011-10-18 11:08:31 -07:00
|
|
|
ProgramRaster programRaster = new ProgramRaster(id, mRS);
|
|
|
|
programRaster.mPointSprite = mPointSprite;
|
|
|
|
programRaster.mCullMode = mCullMode;
|
|
|
|
return programRaster;
|
2009-09-23 13:57:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-12 15:50:32 -07:00
|
|
|
|