Debian Codegraph @

tests/UiBench/src/com/android/test/uibench/FullscreenOverdrawActivity.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2015 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 package com.android.test.uibench;
17
18 import android.animation.ObjectAnimator;
19 import android.animation.ValueAnimator;
20 import android.content.Context;
21 import android.graphics.Canvas;
22 import android.graphics.ColorFilter;
23 import android.graphics.PixelFormat;
24 import android.graphics.Color;
25 import android.graphics.Paint;
26 import android.graphics.drawable.Drawable;
27 import android.os.Bundle;
28 import androidx.appcompat.app.AppCompatActivity;
29 import android.view.View;
30
31 /**
32 * Draws hundreds of levels of overdraw over the content area.
33 *
34 * This should all be optimized out by the renderer.
35 */
36 public class FullscreenOverdrawActivity extends AppCompatActivity {
37 private class OverdrawDrawable extends Drawable {
38 Paint paint = new Paint();
39 int mColorValue = 0;
40
41 @SuppressWarnings("unused")
42 public void setColorValue(int colorValue) {
43 mColorValue = colorValue;
44 invalidateSelf();
45 }
46
47 @Override
48 public void draw(Canvas canvas) {
49 paint.setColor(Color.rgb(mColorValue, 255 - mColorValue, 255));
50
51 for (int i = 0; i < 400; i++) {
52 canvas.drawRect(getBounds(), paint);
53 }
54 }
55
56 @Override
57 public void setAlpha(int alpha) {
58 }
59
60 @Override
61 public void setColorFilter(ColorFilter colorFilter) {
62 }
63
64 @Override
65 public int getOpacity() {
66 return PixelFormat.OPAQUE;
67 }
68 }
69 @Override
70 protected void onCreate(Bundle savedInstanceState) {
71 super.onCreate(savedInstanceState);
72
73 OverdrawDrawable overdraw = new OverdrawDrawable();
74 getWindow().setBackgroundDrawable(overdraw);
75
76 setContentView(new View(this));
77
78 ObjectAnimator objectAnimator = ObjectAnimator.ofInt(overdraw, "colorValue", 0, 255);
79 objectAnimator.setRepeatMode(ValueAnimator.REVERSE);
80 objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
81 objectAnimator.start();
82 }
83 }