当前位置:网站首页>Getdrawingcache of view is empty. Solution: interview questions for Android audio and video development
Getdrawingcache of view is empty. Solution: interview questions for Android audio and video development
2022-06-26 07:36:00 【m0_ sixty-six million two hundred and sixty-five thousand and o】
final boolean use32BitCache = attachInfo != null && attachInfo.mUse32BitDrawingCache;
if (width <= 0 || height <= 0 ||
// Projected bitmap size in bytes
(width * height * (opaque && !use32BitCache ? 2 : 4) >
ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize())) {
destroyDrawingCache();
mCachingFailed = true;
return;
}
boolean clear = true;
Bitmap bitmap = autoScale ? mDrawingCache : mUnscaledDrawingCache;
if (bitmap == null || bitmap.getWidth() != width || bitmap.getHeight() != height) {
Bitmap.Config quality;
if (!opaque) {
// Never pick ARGB_4444 because it looks awful
// Keep the DRAWING_CACHE_QUALITY_LOW flag just in case
switch (mViewFlags & DRAWING_CACHE_QUALITY_MASK) {
case DRAWING_CACHE_QUALITY_AUTO:
quality = Bitmap.Config.ARGB_8888;
break;
case DRAWING_CACHE_QUALITY_LOW:
quality = Bitmap.Config.ARGB_8888;
break;
case DRAWING_CACHE_QUALITY_HIGH:
quality = Bitmap.Config.ARGB_8888;
break;
default:
quality = Bitmap.Config.ARGB_8888;
break;
}
} else {
// Optimization for translucent windows
// If the window is translucent, use a 32 bits bitmap to benefit from memcpy()
quality = use32BitCache ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
}
// Try to cleanup memory
if (bitmap != null) bitmap.recycle();
try {
bitmap = Bitmap.createBitmap(width, height, quality);
bitmap.setDensity(getResources().getDisplayMetrics().densityDpi);
if (autoScale) {
mDrawingCache = bitmap;
} else {
mUnscaledDrawingCache = bitmap;
}
if (opaque && use32BitCache) bitmap.setHasAlpha(false);
} catch (OutOfMemoryError e) {
// If there is not enough memory to create the bitmap cache, just
// ignore the issue as bitmap caches are not required to draw the
// view hierarchy
if (autoScale) {
mDrawingCache = null;
} else {
mUnscaledDrawingCache = null;
}
mCachingFailed = true;
return;
}
clear = drawingCacheBackgroundColor != 0;
}
Canvas canvas;
if (attachInfo != null) {
canvas = attachInfo.mCanvas;
if (canvas == null) {
canvas = new Canvas();
}
canvas.setBitmap(bitmap);
// Temporarily clobber the cached Canvas in case one of our children
// is also using a drawing cache. Without this, the children would
// steal the canvas by attaching their own bitmap to it and bad, bad
// thing would happen (invisible views, corrupted drawings, etc.)
attachInfo.mCanvas = null;
} else {
// This case should hopefully never or seldom happen
canvas = new Canvas(bitmap);
}
if (clear) {
bitmap.eraseColor(drawingCacheBackgroundColor);
}
computeScroll();
final int restoreCount = canvas.save();
if (autoScale && scalingRequired) {
final float scale = attachInfo.mApplicationScale;
canvas.scale(scale, scale);
}
canvas.translate(-mScrollX, -mScrollY);
mPrivateFlags |= DRAWN;
if (mAttachInfo == null || !mAttachInfo.mHardwareAccelerated ||
mLayerType != LAYER_TYPE_NONE) {
mPrivateFlags |= DRAWING_CACHE_VALID;
}
// Fast path for layouts with no backgrounds
if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
if (ViewDebug.TRACE_HIERARCHY) {
ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
}
mPrivateFlags &= ~DIRTY_MASK;
dispatchDraw(canvas);
} else {
draw(canvas);
}
canvas.restoreToCount(restoreCount);
canvas.setBitmap(null);
if (attachInfo != null) {
// Restore the cached Canvas for our siblings
attachInfo.mCanvas = canvas;
}
}
}
/**
Create a snapshot of the view into a bitmap. We should probably make
some form of this public, but should think about the API.
*/
Bitmap createSnapshot(Bitmap.Config quality, int backgroundColor, boolean skipChildren) {
int width = mRight - mLeft;
int height = mBottom - mTop;
final AttachInfo attachInfo = mAttachInfo;
final float scale = attachInfo != null ? attachInfo.mApplicationScale : 1.0f;
width = (int) ((width * scale) + 0.5f);
height = (int) ((height * scale) + 0.5f);
Bitmap bitmap = Bitmap.createBitmap(width > 0 ? width : 1, height > 0 ? height : 1, quality);
if (bitmap == null) {
throw new OutOfMemoryError();
}
Resources resources = getResources();
if (resources != null) {
bitmap.setDensity(resources.getDisplayMetrics().densityDpi);
}
Canvas canvas;
if (attachInfo != null) {
canvas = attachInfo.mCanvas;
if (canvas == null) {
canvas = new Canvas();
}
canvas.setBitmap(bitmap);
// Temporarily clobber the cached Canvas in case one of our children
// is also using a drawing cache. Without this, the children would
// steal the canvas by attaching their own bitmap to it and bad, bad
// things would happen (invisible views, corrupted drawings, etc.)
attachInfo.mCanvas = null;
} else {
// This case should hopefully never or seldom happen
canvas = new Canvas(bitmap);
}
if ((backgroundColor & 0xff000000) != 0) {
bitmap.eraseColor(backgroundColor);
}
computeScroll();
final int restoreCount = canvas.save();
canvas.scale(scale, scale);
canvas.translate(-mScrollX, -mScrollY);
// Temporarily remove the dirty mask
int flags = mPrivateFlags;
mPrivateFlags &= ~DIRTY_MASK;
// Fast path for layouts with no backgrounds
if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
dispatchDraw(canvas);
} else {
draw(canvas);
}
Learning sharing
In this era of information sharing , A lot of resources can be found on the Internet , It just depends on whether you are willing to find or find a way, right
Many friends are not without information , Most of them are dozens or hundreds G, But it's messy , I don't know how to look, where to start , Even after reading, I forget
If you think the information you are looking for on the Internet is very messy 、 If it's not systematic , I also share a set for you , More systematic , I usually study it myself .
2020 The latest tens of thousands of pages of real interview in large factories

Seven modules of learning materials : Such as NDK Module development 、Android Framework architecture …

Only the system , Learning with direction , In order to quickly improve their own technology in a period of time .
This system learning notes , Adapt to the crowd :
First of all , Learning knowledge is fragmented , There is no reasonable learning route and advanced direction .
second , Several years of development , I don't know how to advance further , More confused .
Third , At the right age , The follow-up doesn't know how to develop , Transformation Management , Or strengthen technical research . If you need it , I have exactly why , Don't come to collect ! Maybe it can change your current state !
2%E4%BD%95%E9%9D%A2%E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)
[ Outside the chain picture transfer in …(img-yLxbCVLN-1645006346132)]
Seven modules of learning materials : Such as NDK Module development 、Android Framework architecture …
[ Outside the chain picture transfer in …(img-G3Su729S-1645006346133)]
Only the system , Learning with direction , In order to quickly improve their own technology in a period of time .
This system learning notes , Adapt to the crowd :
First of all , Learning knowledge is fragmented , There is no reasonable learning route and advanced direction .
second , Several years of development , I don't know how to advance further , More confused .
Third , At the right age , The follow-up doesn't know how to develop , Transformation Management , Or strengthen technical research . If you need it , I have exactly why , Don't come to collect ! Maybe it can change your current state !
Because of the more content of the article , Space is not allowed , Some of the contents not shown are shown in the form of screenshots . If you need to get a complete document, please click my GitHub Free access .
边栏推荐
- [SystemVerilog basics] post_ Randomize function record
- My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?
- 一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix
- Web technology sharing | webrtc recording video stream
- Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue
- Important reference indicators for data center disaster recovery: RTO and RPO
- Cloud native integration data warehouse heavy release
- Redis series - five common data types day1-3
- INSERT IGNORE 与INSERT INTO的区别
- The "big grievances" in the workplace are not only physically tired, but also mentally emptied
猜你喜欢
![Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue](/img/83/ddbf296ac83f006f31cfd0bbbabe5e.jpg)
Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue

QTreeWidget And QTableWidget

13. Mismatch simulation of power synthesis for ads usage recording

Liujinhai, chief architect of zhongang Mining: according to the analysis of fluorite supply and demand, it is estimated that the fluorine coating market has great potential

C#/. Net phase VI 01C Foundation_ 02:vs2019 basic operations, excluding code files, smart tips, data types, differences between float and double, and differences between string and string

Tetra - (4-pyridyl) porphyrin tpyp and metal complexes zntpyp/fetpyp/mntpyp/cutpyp/nitpyp/cotpyp/ptpyp/pdtpyp/cdtpyp (supplied by Qiyue porphyrin)

一文分析EventBus-事件总线的使用方法和实现原理

GMP model

MXNet对NIN网络中的网络的实现

Take you three minutes to get started typescript
随机推荐
蓝桥杯嵌入式学习总结(新版)
Ppbpi-h-cr, ppbpimn Cr, ppbpi Fe Cr alkynyl crosslinked porphyrin based polyimide material Qiyue porphyrin reagent
CMDA 3634 image processing
Sanic based services use celery to complete dynamic modification timing tasks
systemctl php配置文件
Database persistence
卡尔曼滤波器_Recursive Processing
INSERT IGNORE 与INSERT INTO的区别
MySQL'replace into'has a self incrementing ID of the pit. There is a problem with the backup opportunity
php array_ Merge details
Network IO, disk IO
oracle创建带返回值的存储过程并sql执行调用
5,10,15,20-tetra (4-methoxycarbonylphenyl) porphyrin tcmpp purple crystal; Meso-5,10,15,20-tetra (4-methoxyphenyl) porphyrin tmopp|zn[t (4-mop) p] and co[t (4-mop) p] complexes
ES cluster_ block_ exception read_ only_ allow_ Delete question
Take you three minutes to get started typescript
[UVM basics] understanding of sequence and sequencer
异地北京办理居住证详细材料
How MySQL implements the RC transaction isolation level
Jemter 压力测试 -可视化工具支持-【安装篇】
Solution to the permission problem when NPM install -g serve reports an error