1/*
2 * Copyright (C) 2010 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 com.android.test.hwui;
18
19import android.app.Activity;
20import android.content.Context;
21import android.graphics.Canvas;
22import android.os.Bundle;
23import android.util.Log;
24import android.view.View;
25import android.widget.LinearLayout;
26
27@SuppressWarnings({"UnusedDeclaration"})
28public class MaxBitmapSizeActivity extends Activity {
29    @Override
30    protected void onCreate(Bundle savedInstanceState) {
31        super.onCreate(savedInstanceState);
32
33        final LinearLayout layout = new LinearLayout(this);
34
35        CanvasView view = new CanvasView(this);
36        layout.addView(view, new LinearLayout.LayoutParams(200, 200));
37
38        view = new CanvasView(this);
39        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
40        layout.addView(view, new LinearLayout.LayoutParams(200, 200));
41
42        setContentView(layout);
43    }
44
45    private static class CanvasView extends View {
46        public CanvasView(Context c) {
47            super(c);
48        }
49
50        @Override
51        protected void onDraw(Canvas canvas) {
52            super.onDraw(canvas);
53            Log.d("Bitmap", "Hw         = " + canvas.isHardwareAccelerated());
54            Log.d("Bitmap", "Max width  = " + canvas.getMaximumBitmapWidth());
55            Log.d("Bitmap", "Max height = " + canvas.getMaximumBitmapHeight());
56        }
57    }
58}
59