1f61970fc79e9c5cf340fa942597628242361864aRomain Guy/*
2f61970fc79e9c5cf340fa942597628242361864aRomain Guy * Copyright (C) 2010 The Android Open Source Project
3f61970fc79e9c5cf340fa942597628242361864aRomain Guy *
4f61970fc79e9c5cf340fa942597628242361864aRomain Guy * Licensed under the Apache License, Version 2.0 (the "License");
5f61970fc79e9c5cf340fa942597628242361864aRomain Guy * you may not use this file except in compliance with the License.
6f61970fc79e9c5cf340fa942597628242361864aRomain Guy * You may obtain a copy of the License at
7f61970fc79e9c5cf340fa942597628242361864aRomain Guy *
8f61970fc79e9c5cf340fa942597628242361864aRomain Guy *      http://www.apache.org/licenses/LICENSE-2.0
9f61970fc79e9c5cf340fa942597628242361864aRomain Guy *
10f61970fc79e9c5cf340fa942597628242361864aRomain Guy * Unless required by applicable law or agreed to in writing, software
11f61970fc79e9c5cf340fa942597628242361864aRomain Guy * distributed under the License is distributed on an "AS IS" BASIS,
12f61970fc79e9c5cf340fa942597628242361864aRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f61970fc79e9c5cf340fa942597628242361864aRomain Guy * See the License for the specific language governing permissions and
14f61970fc79e9c5cf340fa942597628242361864aRomain Guy * limitations under the License.
15f61970fc79e9c5cf340fa942597628242361864aRomain Guy */
16f61970fc79e9c5cf340fa942597628242361864aRomain Guy
17f61970fc79e9c5cf340fa942597628242361864aRomain Guypackage com.android.test.hwui;
18f61970fc79e9c5cf340fa942597628242361864aRomain Guy
19f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.app.Activity;
20f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.content.Context;
21f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.graphics.Canvas;
22f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.os.Bundle;
23f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.util.Log;
24f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.view.View;
25f61970fc79e9c5cf340fa942597628242361864aRomain Guyimport android.widget.LinearLayout;
26f61970fc79e9c5cf340fa942597628242361864aRomain Guy
27f61970fc79e9c5cf340fa942597628242361864aRomain Guy@SuppressWarnings({"UnusedDeclaration"})
28f61970fc79e9c5cf340fa942597628242361864aRomain Guypublic class MaxBitmapSizeActivity extends Activity {
29f61970fc79e9c5cf340fa942597628242361864aRomain Guy    @Override
30f61970fc79e9c5cf340fa942597628242361864aRomain Guy    protected void onCreate(Bundle savedInstanceState) {
31f61970fc79e9c5cf340fa942597628242361864aRomain Guy        super.onCreate(savedInstanceState);
32f61970fc79e9c5cf340fa942597628242361864aRomain Guy
33f61970fc79e9c5cf340fa942597628242361864aRomain Guy        final LinearLayout layout = new LinearLayout(this);
34f61970fc79e9c5cf340fa942597628242361864aRomain Guy
35f61970fc79e9c5cf340fa942597628242361864aRomain Guy        CanvasView view = new CanvasView(this);
36f61970fc79e9c5cf340fa942597628242361864aRomain Guy        layout.addView(view, new LinearLayout.LayoutParams(200, 200));
37f61970fc79e9c5cf340fa942597628242361864aRomain Guy
38f61970fc79e9c5cf340fa942597628242361864aRomain Guy        view = new CanvasView(this);
39f61970fc79e9c5cf340fa942597628242361864aRomain Guy        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
40f61970fc79e9c5cf340fa942597628242361864aRomain Guy        layout.addView(view, new LinearLayout.LayoutParams(200, 200));
41f61970fc79e9c5cf340fa942597628242361864aRomain Guy
42f61970fc79e9c5cf340fa942597628242361864aRomain Guy        setContentView(layout);
43f61970fc79e9c5cf340fa942597628242361864aRomain Guy    }
44f61970fc79e9c5cf340fa942597628242361864aRomain Guy
45f61970fc79e9c5cf340fa942597628242361864aRomain Guy    private static class CanvasView extends View {
46f61970fc79e9c5cf340fa942597628242361864aRomain Guy        public CanvasView(Context c) {
47f61970fc79e9c5cf340fa942597628242361864aRomain Guy            super(c);
48f61970fc79e9c5cf340fa942597628242361864aRomain Guy        }
49f61970fc79e9c5cf340fa942597628242361864aRomain Guy
50f61970fc79e9c5cf340fa942597628242361864aRomain Guy        @Override
51f61970fc79e9c5cf340fa942597628242361864aRomain Guy        protected void onDraw(Canvas canvas) {
52f61970fc79e9c5cf340fa942597628242361864aRomain Guy            super.onDraw(canvas);
53f61970fc79e9c5cf340fa942597628242361864aRomain Guy            Log.d("Bitmap", "Hw         = " + canvas.isHardwareAccelerated());
54f61970fc79e9c5cf340fa942597628242361864aRomain Guy            Log.d("Bitmap", "Max width  = " + canvas.getMaximumBitmapWidth());
55f61970fc79e9c5cf340fa942597628242361864aRomain Guy            Log.d("Bitmap", "Max height = " + canvas.getMaximumBitmapHeight());
56f61970fc79e9c5cf340fa942597628242361864aRomain Guy        }
57f61970fc79e9c5cf340fa942597628242361864aRomain Guy    }
58f61970fc79e9c5cf340fa942597628242361864aRomain Guy}
59