blob: 56f9bf443f1180f447356ca0b33cb5bb7b8765c1 [file] [log] [blame]
Jason Samsebfb4362009-09-23 13:57:02 -07001/*
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
17package android.renderscript;
18
19
20import android.util.Config;
21import android.util.Log;
22
23
24/**
25 * @hide
26 *
27 **/
28public class ProgramRaster extends BaseObj {
29 boolean mPointSmooth;
30 boolean mLineSmooth;
31 boolean mPointSprite;
32 float mPointSize;
33 float mLineWidth;
34 Element mIn;
35 Element mOut;
36
37 ProgramRaster(int id, RenderScript rs) {
38 super(rs);
39 mID = id;
40
41 mPointSize = 1.0f;
42 mLineWidth = 1.0f;
43 mPointSmooth = false;
44 mLineSmooth = false;
45 mPointSprite = false;
46 }
47
48 public void setLineWidth(float w) {
Jason Sams771bebb2009-12-07 12:40:12 -080049 mRS.validate();
Jason Samsebfb4362009-09-23 13:57:02 -070050 mLineWidth = w;
51 mRS.nProgramRasterSetLineWidth(mID, w);
52 }
53
54 public void setPointSize(float s) {
Jason Sams771bebb2009-12-07 12:40:12 -080055 mRS.validate();
Jason Samsebfb4362009-09-23 13:57:02 -070056 mPointSize = s;
57 mRS.nProgramRasterSetPointSize(mID, s);
58 }
59
60 void internalInit() {
61 int inID = 0;
62 int outID = 0;
63 if (mIn != null) {
64 inID = mIn.mID;
65 }
66 if (mOut != null) {
67 outID = mOut.mID;
68 }
69 mID = mRS.nProgramRasterCreate(inID, outID, mPointSmooth, mLineSmooth, mPointSprite);
70 }
71
72
73 public static class Builder {
74 RenderScript mRS;
75 ProgramRaster mPR;
76
77 public Builder(RenderScript rs, Element in, Element out) {
78 mRS = rs;
79 mPR = new ProgramRaster(0, rs);
80 }
81
82 public void setPointSpriteEnable(boolean enable) {
83 mPR.mPointSprite = enable;
84 }
85
86 public void setPointSmoothEnable(boolean enable) {
87 mPR.mPointSmooth = enable;
88 }
89
90 public void setLineSmoothEnable(boolean enable) {
91 mPR.mLineSmooth = enable;
92 }
93
94
95 static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) {
96 b.mPR.internalInit();
97 ProgramRaster pr = b.mPR;
98 b.mPR = new ProgramRaster(0, b.mRS);
99 return pr;
100 }
101
102 public ProgramRaster create() {
Jason Sams771bebb2009-12-07 12:40:12 -0800103 mRS.validate();
Jason Samsebfb4362009-09-23 13:57:02 -0700104 return internalCreate(mRS, this);
105 }
106 }
107
108}
109
110
111
112
113