add viewcount to command line arguments --debug

This commit is contained in:
houzh 2023-11-27 17:16:26 +08:00
parent 12610644cf
commit f4731ac943
6 changed files with 14 additions and 16 deletions

View File

@ -54,7 +54,7 @@ App::App(int argc,const char*argv[],const std::vector<CLA::Argument>&extoptions)
setName(std::string(argc?argv[0]:__progname));
LOGI("App [%s] started c++=%d",mName.c_str(),__cplusplus);
ViewGroup::DEBUG_DRAW = View::DEBUG_DRAW = hasSwitch("debug");
View::VIEW_DEBUG = hasSwitch("debug");
if(hasSwitch("help")){
std::cout<<cla.getUsageString()<<std::endl;
std::cout<<"params.count="<<getParamCount()<<std::endl;

View File

@ -168,8 +168,8 @@ public:
}
};
bool View::DEBUG_DRAW = false;
static int mViewCount=0;
bool View::VIEW_DEBUG = false;
int View::mViewCount = 0;
View::View(int w,int h){
initView();
mContext=&App::getInstance();
@ -441,8 +441,8 @@ View::View(Context*ctx,const AttributeSet&attrs){
void View::initView(){
mViewCount ++;
LOGD("mViewCount=%d",mViewCount);
mID = NO_ID;
LOGD_IF(View::VIEW_DEBUG,"mViewCount=%d",mViewCount);
mID = NO_ID;
mAutofillViewId =NO_ID;
mAccessibilityViewId = NO_ID;
mDrawingCacheBackgroundColor = 0;
@ -519,7 +519,7 @@ void View::initView(){
View::~View(){
mViewCount --;
LOGD("mViewCount=%d",mViewCount);
LOGD_IF(View::VIEW_DEBUG,"mViewCount=%d",mViewCount);
if(mParent)
mParent->removeViewInternal(this);
if(isAttachedToWindow())onDetachedFromWindow();
@ -547,7 +547,7 @@ View::~View(){
}
bool View::isShowingLayoutBounds()const{
return DEBUG_DRAW || mAttachInfo && mAttachInfo->mDebugLayout;
return View::VIEW_DEBUG || mAttachInfo && mAttachInfo->mDebugLayout;
}
void View::setShowingLayoutBounds(bool debugLayout){
@ -557,7 +557,7 @@ void View::setShowingLayoutBounds(bool debugLayout){
}
bool View::debugDraw()const {
return DEBUG_DRAW|| (mAttachInfo && mAttachInfo->mDebugLayout);
return View::VIEW_DEBUG|| (mAttachInfo && mAttachInfo->mDebugLayout);
}
int View::dipsToPixels(int dips)const{
@ -3977,7 +3977,7 @@ View& View::setBackgroundTintList(const ColorStateList* tint){
mBackgroundTint->mTintList=nullptr;
}else{
if(mBackgroundTint->mTintList)*mBackgroundTint->mTintList = *tint;
else mBackgroundTint->mTintList=new ColorStateList(*tint);
else mBackgroundTint->mTintList=new ColorStateList(*tint);
}
mBackgroundTint->mHasTintList = (tint!=nullptr);
@ -4086,8 +4086,8 @@ View& View::setForegroundTintList(const ColorStateList* tint){
mForegroundInfo->mTintInfo = new TintInfo();
}
if(tint == nullptr){
delete mForegroundInfo->mTintInfo->mTintList;
mForegroundInfo->mTintInfo->mTintList=nullptr;
delete mForegroundInfo->mTintInfo->mTintList;
mForegroundInfo->mTintInfo->mTintList=nullptr;
}else{
if(mForegroundInfo->mTintInfo->mTintList)
*mForegroundInfo->mTintInfo->mTintList = *tint;

View File

@ -46,7 +46,7 @@ typedef std::string Parcelable;
class View:public Drawable::Callback,public KeyEvent::Callback{
public:
static bool DEBUG_DRAW;
static bool VIEW_DEBUG;
constexpr static int DEBUG_CORNERS_COLOR = 0xFF3f7fff;
constexpr static int DEBUG_CORNERS_SIZE_DIP = 8;
constexpr static int NO_ID =-1;
@ -371,6 +371,7 @@ public:
private:
friend ViewGroup;
friend ViewPropertyAnimator;
static int mViewCount;
int mMinWidth;
int mMinHeight;
int mDrawingCacheBackgroundColor;

View File

@ -123,8 +123,6 @@ HoverTarget*HoverTarget::sRecycleBin = nullptr;
int TouchTarget::sRecycledCount = 0;
int HoverTarget::sRecycledCount = 0;
bool ViewGroup::DEBUG_DRAW = false;
ViewGroup::ViewGroup(Context*ctx,const AttributeSet& attrs):View(ctx,attrs){
initGroup();
initFromAttributes(ctx,attrs);

View File

@ -86,7 +86,6 @@ public:
LAYOUT_MODE_OPTICAL_BOUNDS=1,
LAYOUT_MODE_DEFAULT = LAYOUT_MODE_CLIP_BOUNDS
};
static bool DEBUG_DRAW;
private:
friend class View;
friend class UIEventSource;

View File

@ -115,7 +115,7 @@ void Window::draw(){
RefPtr<Canvas>canvas = getCanvas();
mAttachInfo->mDrawingTime = SystemClock::uptimeMillis();
ViewGroup::draw(*canvas);
if(DEBUG_DRAW)drawInvalidateRegion(*canvas);
if(View::VIEW_DEBUG)drawInvalidateRegion(*canvas);
mPendingRgn->do_union(mInvalidRgn);
mInvalidRgn->subtract(mInvalidRgn);
GraphDevice::getInstance().flip();