13b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy/* 23b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * Copyright (C) 2013 The Android Open Source Project 33b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * 43b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 53b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * you may not use this file except in compliance with the License. 63b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * You may obtain a copy of the License at 73b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * 83b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 93b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * 103b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * Unless required by applicable law or agreed to in writing, software 113b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 123b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * See the License for the specific language governing permissions and 143b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy * limitations under the License. 153b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy */ 163b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 173b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guypackage com.android.test.hwui; 183b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 193b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.app.Activity; 203b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.content.Context; 213b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.Bitmap; 223b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.Canvas; 233b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.Matrix; 243b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.Rect; 253b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.drawable.BitmapDrawable; 263b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.graphics.drawable.Drawable; 273b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.os.Bundle; 283b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport android.view.View; 293b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guyimport com.android.internal.R; 303b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 313b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy@SuppressWarnings({"UnusedDeclaration"}) 323b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guypublic class AssetsAtlasActivity extends Activity { 333b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy @Override 343b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy protected void onCreate(Bundle savedInstanceState) { 353b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy super.onCreate(savedInstanceState); 363b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy setContentView(new BitmapsView(this)); 373b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy } 383b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 393b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy static class BitmapsView extends View { 403b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy private final Bitmap mBitmap; 413b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 423b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy BitmapsView(Context c) { 433b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy super(c); 443b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 4563999da503dae76551f3368baa8248638634fedcAurimas Liutikas Drawable d = c.getResources().getDrawable(R.drawable.star_big_on); 463b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy mBitmap = ((BitmapDrawable) d).getBitmap(); 473b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy } 483b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 493b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy @Override 503b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy protected void onDraw(Canvas canvas) { 513b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy super.onDraw(canvas); 523b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 533b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy final Matrix matrix = new Matrix(); 543b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy matrix.setScale(0.5f, 0.5f); 553b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 563b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy final Rect src = new Rect(0, 0, mBitmap.getWidth() / 2, mBitmap.getHeight() / 2); 573b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy final Rect dst = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight()); 583b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy 593b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null); 603b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy canvas.translate(0.0f, mBitmap.getHeight()); 613b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy canvas.drawBitmap(mBitmap, matrix, null); 623b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy canvas.translate(0.0f, mBitmap.getHeight()); 633b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy canvas.drawBitmap(mBitmap, src, dst, null); 643b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy } 653b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy } 663b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy} 67