11a430b831f813351d6382a16943ef2910a2bb433Romain Guy/*
21a430b831f813351d6382a16943ef2910a2bb433Romain Guy * Copyright (C) 2009 The Android Open Source Project
31a430b831f813351d6382a16943ef2910a2bb433Romain Guy *
41a430b831f813351d6382a16943ef2910a2bb433Romain Guy * Licensed under the Apache License, Version 2.0 (the "License");
51a430b831f813351d6382a16943ef2910a2bb433Romain Guy * you may not use this file except in compliance with the License.
61a430b831f813351d6382a16943ef2910a2bb433Romain Guy * You may obtain a copy of the License at
71a430b831f813351d6382a16943ef2910a2bb433Romain Guy *
81a430b831f813351d6382a16943ef2910a2bb433Romain Guy *      http://www.apache.org/licenses/LICENSE-2.0
91a430b831f813351d6382a16943ef2910a2bb433Romain Guy *
101a430b831f813351d6382a16943ef2910a2bb433Romain Guy * Unless required by applicable law or agreed to in writing, software
111a430b831f813351d6382a16943ef2910a2bb433Romain Guy * distributed under the License is distributed on an "AS IS" BASIS,
121a430b831f813351d6382a16943ef2910a2bb433Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131a430b831f813351d6382a16943ef2910a2bb433Romain Guy * See the License for the specific language governing permissions and
141a430b831f813351d6382a16943ef2910a2bb433Romain Guy * limitations under the License.
151a430b831f813351d6382a16943ef2910a2bb433Romain Guy */
161a430b831f813351d6382a16943ef2910a2bb433Romain Guy
171a430b831f813351d6382a16943ef2910a2bb433Romain Guy
181a430b831f813351d6382a16943ef2910a2bb433Romain Guypackage com.android.wallpaper.grass;
191a430b831f813351d6382a16943ef2910a2bb433Romain Guy
201a430b831f813351d6382a16943ef2910a2bb433Romain Guyimport android.renderscript.RSSurfaceView;
21b418c5c443dc18fbdc7d644c407fada2be78c50fJason Samsimport android.renderscript.RenderScriptGL;
221a430b831f813351d6382a16943ef2910a2bb433Romain Guyimport android.content.Context;
231a430b831f813351d6382a16943ef2910a2bb433Romain Guyimport android.view.SurfaceHolder;
241a430b831f813351d6382a16943ef2910a2bb433Romain Guy
251a430b831f813351d6382a16943ef2910a2bb433Romain Guyclass GrassView extends RSSurfaceView {
261a430b831f813351d6382a16943ef2910a2bb433Romain Guy
271a430b831f813351d6382a16943ef2910a2bb433Romain Guy    public GrassView(Context context) {
281a430b831f813351d6382a16943ef2910a2bb433Romain Guy        super(context);
291a430b831f813351d6382a16943ef2910a2bb433Romain Guy        setFocusable(true);
301a430b831f813351d6382a16943ef2910a2bb433Romain Guy        setFocusableInTouchMode(true);
311a430b831f813351d6382a16943ef2910a2bb433Romain Guy    }
321a430b831f813351d6382a16943ef2910a2bb433Romain Guy
331a430b831f813351d6382a16943ef2910a2bb433Romain Guy    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
341a430b831f813351d6382a16943ef2910a2bb433Romain Guy        super.surfaceChanged(holder, format, w, h);
351a430b831f813351d6382a16943ef2910a2bb433Romain Guy
36258041d23145897222e9cc291ea7230eb5010f8eJason Sams        RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
3776469b31f1bda22057330a0146d9296df92b9094Jason Sams        RenderScriptGL RS = createRenderScriptGL(sc);
38a56ce01d5f2e831ad4a5ada54a3c10f8075e4921Romain Guy        GrassRS render = new GrassRS(getContext(), w, h);
390ac0b3f704bedde5c3a117ac68e7cd4956cd73efRomain Guy        render.init(RS, getResources(), false);
40b418c5c443dc18fbdc7d644c407fada2be78c50fJason Sams        render.setOffset(0.5f, 0.0f, 0, 0);
411a430b831f813351d6382a16943ef2910a2bb433Romain Guy        render.start();
421a430b831f813351d6382a16943ef2910a2bb433Romain Guy    }
431a430b831f813351d6382a16943ef2910a2bb433Romain Guy}