Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
103 - Android Graphics Performance
Search
DouO
October 08, 2013
Technology
40
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
103 - Android Graphics Performance
Google IO 2013
DouO
October 08, 2013
Other Decks in Technology
See All in Technology
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
160
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
180
React改造してみた
tsukina_7mochi
0
110
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
専門領域のAIをどう評価するか
bengo4com
2
270
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
340
会社説明資料
persolserverworks
0
9.8k
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
110
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
2.4k
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
810
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
180
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
930
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
2
720
Believing is Seeing
oripsolob
1
240
Navigating Team Friction
lara
192
16k
Deep Space Network (abreviated)
tonyrice
0
370
Raft: Consensus for Rubyists
vanstee
142
7.8k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Building Flexible Design Systems
yeseniaperezcruz
330
41k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
Prompt Engineering for Job Search
mfonobong
0
520
Transcript
None
None
& Graphics Performance
& Chet Haase Romain Guy
Architecture
Reordering & merging
Save Cancel Maximize compatibility Include metadata
None
Include metadata Maximize compatibility Cancel Save Order of drawing commands
Include metadata Maximize compatibility Cancel Save 1. Re-ordering
Include metadata Maximize compatibility Cancel Save 2. Merging
None
Multi-threading
None
Drawing
Drawing Shadows Shadows Shadows Shadows
Drawing Paths Paths Shadows Shadows Shadows Shadows
Non-rectangular clipping
@Override protected void onDraw(Canvas canvas) { // Clip with a
shape Path clip = getPath(); canvas.clipPath(clip); // Draw the content for (int i = 0; i < mLines,length; i++) { TextLine line = mLines[i]; canvas.drawText(line.text, line.x, line.y, mPaint); } }
Developer Tools 2
Overdraw
Overdraw
Overdraw
Overdraw Blue Green Red Deep Red 1x 2x 3x 4x
0 3 6 9 12 15 Time in ms Frames
Update display lists Process display lists Swap buffers
None
None
performTraversals draw getDL drawDisplayList systrace flush drawing commands
android:sdk $ cd platform-tools/ android:platform-tools $ 㾑 ./systrace.py gfx view
freq sched
None
import android.os.Trace; @Override public View getView(int pos, View view, ViewGroup
parent) { Trace.beginSection("getView"); if (view == null) { view = createView(); } // Trace time spent binding data Trace.beginSection("bind"); bindView(pos, view); Trace.endSection(); Trace.endSection(); return view; }
android:sdk $ cd platform-tools/ android:platform-tools $ 㾑 ./systrace.py -a com.example.myapp
Tips & Tricks 3
Overdraw demo
Trilinear filtering
None
Off On
private void loadData() { // Load bitmap Bitmap b =
getBitmap(); // Enable trilinear filtering b.setHasMipMap(true); }
<bitmap android:mipMap="true" android:src="@drawable/my_drawable" />
Canvas layers
@Override protected void onDraw(Canvas canvas) { // Create a clipped
layer canvas.save(); canvas.saveLayer(x, y, width, height, Canvas.CLIP_TO_LAYER_SAVE_FLAG); // Draw stuff canvas.drawBitmap(bugDroid, 0.0f, 0.0f, null); canvas.restore(); }
saveLayer()
None
None
@Override protected void onDraw(Canvas canvas) { // Create an unclipped
layer canvas.save(); canvas.saveLayer(x, y, width, height, 0); // Draw stuff canvas.drawBitmap(bugDroid, 0.0f, 0.0f, null); canvas.restore(); }
saveLayer()
None
None
Using alpha with care
None
view.setAlpha(0.5f); View.ALPHA.set(view, 0.5f); ObjectAnimation.ofFloat(view, "alpha", 0.5f) view.animate().alpha(0.5f); view.setAnimation(new AlphaAnimation(1.0f, 0.5f));
view.setAlpha(0.5f); View.ALPHA.set(view, 0.5f); ObjectAnimation.ofFloat(view, "alpha", 0.5f) view.animate().alpha(0.5f); view.setAnimation(new AlphaAnimation(1.0f, 0.5f));
Canvas.saveLayerAlpha(l, t, r, b, 127, Canvas.CLIP_TO_LAYER_SAVE_FLAG); ==
None
None
None
None
lternatives
// Not this textView.setAlpha(alpha); // But this int newTextColor =
(int) (0xFF * alpha) << 24 | baseTextColor & 0xFFFFFF; textView.setTextColor(newTextColor);
// Not this imageView.setAlpha(alpha); // But this imageView.setImageAlpha((int) (alpha *
255));
// Not this customView.setAlpha(alpha); // But this int alpha =
(int) (255 * slider.getProgress() / 100.0f); paint.setAlpha(alpha); canvas.draw*(..., paint);
// Or use a layer view.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Transient layer
view.animate().alpha(0).withLayer();
// API level 16+ @Override public boolean hasOverlappingRendering() { //
Don't lie to us! return false; }
640 dp 400 dp Canvas
@Override protected void onDraw(Canvas canvas) { // Get the dimensions
of the Canvas int w = canvas.getWidth(); int h = canvas.getHeight(); canvas.drawRect(0, 0, w, h, mPaint); }
1280 px 800 px View 300 px 600 px
None
With hardware rendering 600x300 px (size of the View)
With hardware rendering With software rendering 600x300 px 1280x800 px
(size of the View) (size of the window)
✂ Clipping
@Override protected void onDraw(Canvas canvas) { // Keep the jellybeans
canvas.clipRect(l, t, r, b); // Rotate the jar canvas.rotate(-30.0f, pX, pY); // Draw the jar canvas.drawBitmap(mJellyBeans, x, y, null); }
None
1. Clip
2. Rotate
3. Draw
None
@Override protected void onDraw(Canvas canvas) { // Rotate the jar
canvas.rotate(-30.0f, pX, pY); // Keep the jellybeans canvas.clipRect(l, t, r, b); // Draw the jar canvas.drawBitmap(mJellyBeans, x, y, null); }
None
1. Rotate
2. Clip
3. Draw
None
Stencil buffer
Stencil buffer
640 px 400 px View
Invalidate 640 px 400 px (170,125) (470,275)
@Override protected void onDraw(Canvas canvas) { // Query the current
clip Rect clip = canvas.getClipBounds(); // ??? Log.d("I/O", "clip = " + clip); }
None
With hardware rendering 0, 0, 640, 400 (bounds of the
View)
With hardware rendering With software rendering 0, 0, 640, 400
170,125, 470, 275 (bounds of the View) (bounds of the dirty rect)
Reordering barriers
Non-rectangular clips
saveLayer()
More info Parleys.com For Butter or Worse Google I/O 2012
Various Android GUI & performance talks Accelerated Android Rendering Google I/O 2011
More info Romain’s Tips & Tricks www.curious-creature.org Chet’s Tips &
Tricks goo.gl/y9JZr Android Performance Case Study graphics-geek.blogspot.com
Q&A google.com/+ChetHaase google.com/+RomainGuy @chethaase @romainguy
Developers