packages/wallpapers/Basic
Revision | ff41eed2db72b18e5ef8972379228f3bdcf34fca (tree) |
---|---|
Time | 2009-08-25 05:55:57 |
Author | Romain Guy <romainguy@andr...> |
Commiter | Romain Guy |
Fix GC issues with native objects.
Change-Id: I670457555e60927f16ae383bebc6840c5d850db1
@@ -87,6 +87,12 @@ class GalaxyRS { | ||
87 | 87 | private ProgramStore mPfsLights; |
88 | 88 | @SuppressWarnings({"FieldCanBeLocal"}) |
89 | 89 | private ProgramVertex mPvBackground; |
90 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
91 | + private Sampler mSampler; | |
92 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
93 | + private Sampler mLightSampler; | |
94 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
95 | + private ProgramVertex.MatrixAllocation mPvOrthoAlloc; | |
90 | 96 | |
91 | 97 | @SuppressWarnings({"FieldCanBeLocal"}) |
92 | 98 | private Allocation[] mTextures; |
@@ -272,8 +278,7 @@ class GalaxyRS { | ||
272 | 278 | |
273 | 279 | final int count = textures.length; |
274 | 280 | for (int i = 0; i < count; i++) { |
275 | - final Allocation texture = textures[i]; | |
276 | - texture.uploadToTexture(0); | |
281 | + textures[i].uploadToTexture(0); | |
277 | 282 | } |
278 | 283 | } |
279 | 284 |
@@ -297,28 +302,28 @@ class GalaxyRS { | ||
297 | 302 | sampleBuilder.setMag(LINEAR); |
298 | 303 | sampleBuilder.setWrapS(WRAP); |
299 | 304 | sampleBuilder.setWrapT(WRAP); |
300 | - Sampler sampler = sampleBuilder.create(); | |
305 | + mSampler = sampleBuilder.create(); | |
301 | 306 | |
302 | 307 | ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null); |
303 | 308 | builder.setTexEnable(true, 0); |
304 | 309 | builder.setTexEnvMode(REPLACE, 0); |
305 | 310 | mPfBackground = builder.create(); |
306 | 311 | mPfBackground.setName("PFBackground"); |
307 | - mPfBackground.bindSampler(sampler, 0); | |
312 | + mPfBackground.bindSampler(mSampler, 0); | |
308 | 313 | |
309 | 314 | sampleBuilder = new Sampler.Builder(mRS); |
310 | 315 | sampleBuilder.setMin(NEAREST); |
311 | 316 | sampleBuilder.setMag(NEAREST); |
312 | 317 | sampleBuilder.setWrapS(WRAP); |
313 | 318 | sampleBuilder.setWrapT(WRAP); |
314 | - Sampler lightSampler = sampleBuilder.create(); | |
319 | + mLightSampler = sampleBuilder.create(); | |
315 | 320 | |
316 | 321 | builder = new ProgramFragment.Builder(mRS, null, null); |
317 | 322 | builder.setTexEnable(true, 0); |
318 | 323 | builder.setTexEnvMode(MODULATE, 0); |
319 | 324 | mPfLighting = builder.create(); |
320 | 325 | mPfLighting.setName("PFLighting"); |
321 | - mPfLighting.bindSampler(lightSampler, 0); | |
326 | + mPfLighting.bindSampler(mLightSampler, 0); | |
322 | 327 | } |
323 | 328 | |
324 | 329 | private void createProgramFragmentStore() { |
@@ -338,13 +343,13 @@ class GalaxyRS { | ||
338 | 343 | } |
339 | 344 | |
340 | 345 | private void createProgramVertex() { |
341 | - ProgramVertex.MatrixAllocation pvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); | |
346 | + mPvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); | |
342 | 347 | //mPvOrthoAlloc.setupProjectionNormalized(mWidth, mHeight); |
343 | - pvOrthoAlloc.setupOrthoWindow(mWidth, mHeight); | |
348 | + mPvOrthoAlloc.setupOrthoWindow(mWidth, mHeight); | |
344 | 349 | |
345 | 350 | ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS, null, null); |
346 | 351 | mPvBackground = builder.create(); |
347 | - mPvBackground.bindAllocation(pvOrthoAlloc); | |
352 | + mPvBackground.bindAllocation(mPvOrthoAlloc); | |
348 | 353 | mPvBackground.setName("PVBackground"); |
349 | 354 | } |
350 | 355 | } |
\ No newline at end of file |
@@ -80,6 +80,10 @@ class GrassRS { | ||
80 | 80 | private ProgramStore mPfsBackground; |
81 | 81 | @SuppressWarnings({ "FieldCanBeLocal" }) |
82 | 82 | private ProgramVertex mPvBackground; |
83 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
84 | + private Sampler mSampler; | |
85 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
86 | + private ProgramVertex.MatrixAllocation mPvOrthoAlloc; | |
83 | 87 | |
84 | 88 | @SuppressWarnings({ "FieldCanBeLocal" }) |
85 | 89 | private Allocation[] mTextures; |
@@ -89,10 +93,11 @@ class GrassRS { | ||
89 | 93 | |
90 | 94 | private Allocation mBlades; |
91 | 95 | private Allocation mBladesBuffer; |
96 | + @SuppressWarnings({"FieldCanBeLocal"}) | |
97 | + private SimpleMesh mBladesMesh; | |
92 | 98 | |
93 | 99 | private int mTriangles; |
94 | 100 | private final float[] mFloatData5 = new float[5]; |
95 | - private SimpleMesh mBladesMesh; | |
96 | 101 | |
97 | 102 | public GrassRS(int width, int height) { |
98 | 103 | mWidth = width; |
@@ -288,14 +293,14 @@ class GrassRS { | ||
288 | 293 | samplerBuilder.setMag(LINEAR); |
289 | 294 | samplerBuilder.setWrapS(WRAP); |
290 | 295 | samplerBuilder.setWrapT(WRAP); |
291 | - Sampler sampler = samplerBuilder.create(); | |
296 | + mSampler = samplerBuilder.create(); | |
292 | 297 | |
293 | 298 | ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null); |
294 | 299 | builder.setTexEnable(true, 0); |
295 | 300 | builder.setTexEnvMode(REPLACE, 0); |
296 | 301 | mPfBackground = builder.create(); |
297 | 302 | mPfBackground.setName("PFBackground"); |
298 | - mPfBackground.bindSampler(sampler, 0); | |
303 | + mPfBackground.bindSampler(mSampler, 0); | |
299 | 304 | } |
300 | 305 | |
301 | 306 | private void createProgramFragmentStore() { |
@@ -309,13 +314,13 @@ class GrassRS { | ||
309 | 314 | } |
310 | 315 | |
311 | 316 | private void createProgramVertex() { |
312 | - ProgramVertex.MatrixAllocation pvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); | |
313 | - pvOrthoAlloc.setupOrthoWindow(mWidth, mHeight); | |
317 | + mPvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); | |
318 | + mPvOrthoAlloc.setupOrthoWindow(mWidth, mHeight); | |
314 | 319 | |
315 | 320 | ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); |
316 | 321 | pvb.setTextureMatrixEnable(true); |
317 | 322 | mPvBackground = pvb.create(); |
318 | - mPvBackground.bindAllocation(pvOrthoAlloc); | |
323 | + mPvBackground.bindAllocation(mPvOrthoAlloc); | |
319 | 324 | mPvBackground.setName("PVBackground"); |
320 | 325 | } |
321 | 326 | } |