@Override public void draw(Canvas canvas) { super.draw(canvas); int totalW = getWidth(); int totalH = getHeight(); // rotate canvas first canvas.rotate(45, totalW / 2, totalH / 2); totalW /= 1.2; totalH /= 1.4; mMaxLeftRectWidth = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; RectF leftRect = new RectF(); if (mLeftRectGrowMode) { leftRect.left = 0; leftRect.right = leftRect.left + mLeftRectWidth; leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2; leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT; } else { leftRect.right = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; leftRect.left = leftRect.right - mLeftRectWidth; leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2; leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT; } canvas.drawRoundRect(leftRect, CONST_RADIUS, CONST_RADIUS, mPaint); RectF rightRect = new RectF(); rightRect.bottom = (totalH + CONST_RIGHT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1; rightRect.left = (totalW + CONST_LEFT_RECT_W) / 2; rightRect.right = rightRect.left + CONST_RECT_WEIGHT; rightRect.top = rightRect.bottom - mRightRectWidth; canvas.drawRoundRect(rightRect, CONST_RADIUS, CONST_RADIUS, mPaint); }
/** Recalculates page rectangles. */ private void updatePageRects() { if (mViewRect.width() == 0 || mViewRect.height() == 0) { return; } else if (mViewMode == SHOW_ONE_PAGE) { mPageRectRight.set(mViewRect); mPageRectRight.left += mViewRect.width() * mMargins.left; mPageRectRight.right -= mViewRect.width() * mMargins.right; mPageRectRight.top += mViewRect.height() * mMargins.top; mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom; mPageRectLeft.set(mPageRectRight); mPageRectLeft.offset(-mPageRectRight.width(), 0); int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect.width()); int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect.height()); mObserver.onPageSizeChanged(bitmapW, bitmapH); } else if (mViewMode == SHOW_TWO_PAGES) { mPageRectRight.set(mViewRect); mPageRectRight.left += mViewRect.width() * mMargins.left; mPageRectRight.right -= mViewRect.width() * mMargins.right; mPageRectRight.top += mViewRect.height() * mMargins.top; mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom; mPageRectLeft.set(mPageRectRight); mPageRectLeft.right = (mPageRectLeft.right + mPageRectLeft.left) / 2; mPageRectRight.left = mPageRectLeft.right; int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect.width()); int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect.height()); mObserver.onPageSizeChanged(bitmapW, bitmapH); } }
/** * Calculate the bounds for a view's title * * @param index * @param paint * @return */ private RectF calcBounds(int index, Paint paint) { // Calculate the text bounds RectF bounds = new RectF(); bounds.right = paint.measureText(mTitleProvider.getTitle(index)); bounds.bottom = paint.descent() - paint.ascent(); return bounds; }
/** * Set margins or padding. Note: margins are proportional. Meaning a value of .1f will produce a * 10% margin. */ public synchronized void setMargins(float left, float top, float right, float bottom) { mMargins.left = left; mMargins.top = top; mMargins.right = right; mMargins.bottom = bottom; updatePageRects(); }
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (mPositionDataList == null || mPositionDataList.isEmpty()) { return; } // 计算锚点位置 int currentPosition = Math.min(mPositionDataList.size() - 1, position); int nextPosition = Math.min(mPositionDataList.size() - 1, position + 1); PositionData current = mPositionDataList.get(currentPosition); PositionData next = mPositionDataList.get(nextPosition); mRect.left = current.mContentLeft - mHorizontalPadding + (next.mContentLeft - current.mContentLeft) * mEndInterpolator.getInterpolation(positionOffset); mRect.top = current.mContentTop - mVerticalPadding; mRect.right = current.mContentRight + mHorizontalPadding + (next.mContentRight - current.mContentRight) * mStartInterpolator.getInterpolation(positionOffset); mRect.bottom = current.mContentBottom + mVerticalPadding; if (!mRoundRadiusSet) { mRoundRadius = mRect.height() / 2; } invalidate(); }
public static Bitmap createDefaultBitmap(int rectWidth) { Bitmap bitmap = Bitmap.createBitmap(rectWidth, rectWidth, Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG); canvas.drawColor(0xffCCFEBF); float rect = rectWidth / 3; RectF f = new RectF(); f.bottom = rect; f.left = 0; f.top = 0; f.right = rect; canvas.save(); paint.setColor(Color.BLACK); canvas.drawRect(f, paint); canvas.translate(2 * rect, 0); paint.setColor(Color.BLUE); canvas.drawRect(f, paint); canvas.restore(); canvas.translate(0, 2 * rect); paint.setColor(Color.CYAN); canvas.drawRect(f, paint); canvas.translate(2 * rect, 0); paint.setColor(Color.GRAY); canvas.drawRect(f, paint); return bitmap; }
private void RandomPosition() { top = random.nextInt(CanvasHeight - water.FoamTop) + water.FoamBottom; Dest.left = CanvasWidth; Dest.top = top; Dest.right = CanvasWidth + SquidAnimMap.getHeight(); Dest.bottom = top + SquidAnimMap.getHeight(); }
public RectF BoudingRecTF() { BoudingRecTF.left = Dest.left + (SquidAnimMap.getHeight() * 0.25f); BoudingRecTF.top = Dest.top + (SquidAnimMap.getHeight() * 0.45f); BoudingRecTF.right = (Dest.left + SquidAnimMap.getHeight()) - SquidAnimMap.getHeight() * 0.30f; BoudingRecTF.bottom = Dest.top + (SquidAnimMap.getHeight()) - SquidAnimMap.getHeight() * 0.20f; return BoudingRecTF; }
public Bitmap createCodeBitmap() { Bitmap mBitmap = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Config.ARGB_8888); Canvas mCanvas = new Canvas(mBitmap); Paint mPaint = new Paint(); RectF rect = new RectF(); rect.left = 0; rect.right = mBitmapWidth; rect.top = mBitmapHeight; rect.bottom = 0; mCanvas.drawRoundRect(rect, 10, 10, mPaint); mRandomCode = CreateCodeSting(); // 获得随机的验证码字符串. mCanvas.drawColor(Color.GRAY); mPaint.setTextSize(mFontSize); for (int i = 0; i < mRandomCode.length(); i++) { randomCodeTextStyle(mPaint); randomPadding(); mCanvas.drawText(mRandomCode.charAt(i) + "", mPaddingLeft, mPaddingTop, mPaint); } for (int j = 0; j < mLineNumber; j++) { drawRandomLine(mCanvas, mPaint); } mCanvas.save(Canvas.ALL_SAVE_FLAG); mCanvas.restore(); return mBitmap; }
@Implementation public void set(RectF src) { real.left = src.left; real.top = src.top; real.right = src.right; real.bottom = src.bottom; }
@Implementation public void offset(float dx, float dy) { real.left += dx; real.top += dy; real.right += dx; real.bottom += dy; }
public final void a(PointF pointf) { q = pointf; i.left = pointf.x - (float) b; i.right = pointf.x + (float) b; i.top = pointf.y - (float) b; i.bottom = pointf.y + (float) b; }
private void getEdgesHelper(RectF edgesOut) { final float width = getWidth(); final float height = getHeight(); final float[] imageDims = getImageDims(); final float imageWidth = imageDims[0]; final float imageHeight = imageDims[1]; float initialCenterX = mRenderer.source.getImageWidth() / 2f; float initialCenterY = mRenderer.source.getImageHeight() / 2f; float[] rendererCenter = mTempRendererCenter; rendererCenter[0] = mCenterX - initialCenterX; rendererCenter[1] = mCenterY - initialCenterY; mRotateMatrix.mapPoints(rendererCenter); rendererCenter[0] += imageWidth / 2; rendererCenter[1] += imageHeight / 2; final float scale = mRenderer.scale; float centerX = (width / 2f - rendererCenter[0] + (imageWidth - width) / 2f) * scale + width / 2f; float centerY = (height / 2f - rendererCenter[1] + (imageHeight - height) / 2f) * scale + height / 2f; float leftEdge = centerX - imageWidth / 2f * scale; float rightEdge = centerX + imageWidth / 2f * scale; float topEdge = centerY - imageHeight / 2f * scale; float bottomEdge = centerY + imageHeight / 2f * scale; edgesOut.left = leftEdge; edgesOut.right = rightEdge; edgesOut.top = topEdge; edgesOut.bottom = bottomEdge; }
private void computeRect(final RectF r, View view) { // compute current rectangle according to matrix transformation final float w = view.getWidth(); final float h = view.getHeight(); // use a rectangle at 0,0 to make sure we don't run into issues with scaling r.set(0, 0, w, h); final Matrix m = mTempMatrix; m.reset(); transformMatrix(m, view); mTempMatrix.mapRect(r); r.offset(view.getLeft(), view.getTop()); // Straighten coords if rotations flipped them if (r.right < r.left) { final float f = r.right; r.right = r.left; r.left = f; } if (r.bottom < r.top) { final float f = r.top; r.top = r.bottom; r.bottom = f; } }
public static RectF translate(float x, float y, RectF rect) { rect.left += x; rect.top += y; rect.right += x; rect.bottom += y; return rect; }
@Override public void onDraw(final Canvas c) { // Draw the alpha pattern mAlphaPattern.draw(c); // Draw the shader that shows how transparent a colors looks at a given alpha on top of the // alpha pattern shaderPaint.setShader( new LinearGradient( borderSize, 0, this.getWidth() - borderSize, 0, 0, color, TileMode.CLAMP)); c.drawRect( borderSize, borderSize, this.getWidth() - borderSize, this.getHeight() - borderSize, shaderPaint); // Draw the transparency label on top of that stuff c.drawText( "Transparency", this.getWidth() / 2, this.getHeight() / 2 + labelPaint.getTextSize() / 2.0f, labelPaint); // Draw the alpha tracker on top of everything else final float xPos = alphaToXPos(alpha); final float rectWidth = 2 * mDensity; final RectF r = new RectF(); r.left = xPos - rectWidth; r.right = xPos + rectWidth; r.top = 0; r.bottom = this.getHeight(); c.drawRoundRect(r, rectWidth, rectWidth, trackerPaint); }
protected void drawCenterText(Canvas c) { SpannableString centerText = mChart.getCenterText(); if (mChart.isDrawCenterTextEnabled() && centerText != null) { PointF center = mChart.getCenterCircleBox(); float innerRadius = mChart.isDrawHoleEnabled() && mChart.isHoleTransparent() ? mChart.getRadius() * (mChart.getHoleRadius() / 100f) : mChart.getRadius(); RectF holeRect = mRectBuffer[0]; holeRect.left = center.x - innerRadius; holeRect.top = center.y - innerRadius; holeRect.right = center.x + innerRadius; holeRect.bottom = center.y + innerRadius; RectF boundingRect = mRectBuffer[1]; boundingRect.set(holeRect); float radiusPercent = mChart.getCenterTextRadiusPercent(); if (radiusPercent > 0.0) { boundingRect.inset( (boundingRect.width() - boundingRect.width() * radiusPercent) / 2.f, (boundingRect.height() - boundingRect.height() * radiusPercent) / 2.f); } if (!centerText.equals(mCenterTextLastValue) || !boundingRect.equals(mCenterTextLastBounds)) { // Next time we won't recalculate StaticLayout... mCenterTextLastBounds.set(boundingRect); mCenterTextLastValue = centerText; float width = mCenterTextLastBounds.width(); // If width is 0, it will crash. Always have a minimum of 1 mCenterTextLayout = new StaticLayout( centerText, 0, centerText.length(), mCenterTextPaint, (int) Math.max(Math.ceil(width), 1.f), Layout.Alignment.ALIGN_CENTER, 1.f, 0.f, false); } float layoutHeight = mCenterTextLayout.getHeight(); c.save(); c.translate( boundingRect.left, boundingRect.top + (boundingRect.height() - layoutHeight) / 2.f); mCenterTextLayout.draw(c); c.restore(); } }
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); fBounds.left = bounds.left + mBorderWidth / 2f + .5f; fBounds.right = bounds.right - mBorderWidth / 2f - .5f; fBounds.top = bounds.top + mBorderWidth / 2f + .5f; fBounds.bottom = bounds.bottom - mBorderWidth / 2f - .5f; }
private void resetDirtyRect(float eventX, float eventY) { // The mLastTouchX and mLastTouchY were set when the ACTION_DOWN motion event occurred. mDirtyRect.left = Math.min(mLastTouchX, eventX); mDirtyRect.right = Math.max(mLastTouchX, eventX); mDirtyRect.top = Math.min(mLastTouchY, eventY); mDirtyRect.bottom = Math.max(mLastTouchY, eventY); }
private Bitmap createShadowBitmap( int shadowWidth, int shadowHeight, float cornerRadius, float shadowRadius, float dx, float dy, int shadowColor) { Bitmap output = Bitmap.createBitmap(shadowWidth, shadowHeight, Bitmap.Config.ALPHA_8); Canvas canvas = new Canvas(output); RectF shadowRect = new RectF( shadowRadius, shadowRadius, shadowWidth - shadowRadius, shadowHeight - shadowRadius); if (dy > 0) { shadowRect.top += dy; shadowRect.bottom -= dy; } else if (dy < 0) { shadowRect.top += Math.abs(dy); shadowRect.bottom -= Math.abs(dy); } if (dx > 0) { shadowRect.left += dx; shadowRect.right -= dx; } else if (dx < 0) { shadowRect.left += Math.abs(dx); shadowRect.right -= Math.abs(dx); } Paint shadowPaint = new Paint(); shadowPaint.setAntiAlias(true); shadowPaint.setColor(shadowColor); shadowPaint.setStyle(Paint.Style.FILL); if (!isInEditMode()) { shadowPaint.setShadowLayer(shadowRadius, dx, dy, shadowColor); } canvas.drawRoundRect(shadowRect, cornerRadius, cornerRadius, shadowPaint); return output; }
/** * Transform a rectangle with all matrices with potential animation phases. * * @param r * @param phaseY */ public void rectValueToPixel(RectF r, float phaseY) { // multiply the height of the rect with the phase if (r.top > 0) r.top *= phaseY; else r.bottom *= phaseY; mMatrixValueToPx.mapRect(r); mViewPortHandler.getMatrixTouch().mapRect(r); mMatrixOffset.mapRect(r); }
private RectF getRectF() { if (backgroundRectF == null) { backgroundRectF = new RectF(); backgroundRectF.left = mPadding; backgroundRectF.top = mPadding; backgroundRectF.right = getWidth() - mPadding; backgroundRectF.bottom = getHeight() - mPadding; } return backgroundRectF; }
/** 更新当前删除、缩放按钮绘制位置 */ private void updateBtnDrawRect() { // 计算删除按钮绘制位置 mDelDrawPoint[0] = mDelPoint[0]; mDelDrawPoint[1] = mDelPoint[1]; mViewMatrix.mapPoints(mDelDrawPoint); mDelDrawRectF.left = mDelDrawPoint[0] - (mDelBitmap.getWidth() >> 1); mDelDrawRectF.top = mDelDrawPoint[1] - (mDelBitmap.getHeight() >> 1); mDelDrawRectF.right = mDelDrawPoint[0] + (mDelBitmap.getWidth() >> 1); mDelDrawRectF.bottom = mDelDrawPoint[1] + (mDelBitmap.getHeight() >> 1); // 计算缩放按钮绘制位置 mDragDrawPoint[0] = mDragPoint[0]; mDragDrawPoint[1] = mDragPoint[1]; mViewMatrix.mapPoints(mDragDrawPoint); mDragDrawRectF.left = mDragDrawPoint[0] - (mDelBitmap.getWidth() >> 1); mDragDrawRectF.top = mDragDrawPoint[1] - (mDelBitmap.getHeight() >> 1); mDragDrawRectF.right = mDragDrawPoint[0] + (mDelBitmap.getWidth() >> 1); mDragDrawRectF.bottom = mDragDrawPoint[1] + (mDelBitmap.getHeight() >> 1); }
private void drawRoundRect( float left, float top, float right, float bottom, float radius, Canvas canvas, Paint paint) { tempForRoundRect.left = left; tempForRoundRect.top = top; tempForRoundRect.right = right; tempForRoundRect.bottom = bottom; canvas.drawRoundRect(tempForRoundRect, radius, radius, paint); }
// 网络连接成功后的画图效果 private void drawOnSuccessfulConnect(Canvas canvas, boolean isRun) { int width = this.getWidth(); int height = this.getHeight(); if (width != height) { int min = Math.min(width, height); width = min; height = min; } paint.setAntiAlias(true); // 设置画笔为抗锯齿 paint.setColor(Color.WHITE); // 设置画笔颜色 canvas.drawColor(Color.TRANSPARENT); // 白色背景 // 这里绘制未完成的进度 paint.setStrokeWidth(progressStrokeWidth); // 线宽 paint.setStyle(Style.STROKE); oval.left = progressStrokeWidth / 2; // 左上角x oval.top = progressStrokeWidth / 2; // 左上角y oval.right = width - progressStrokeWidth / 2; // 左下角x oval.bottom = height - progressStrokeWidth / 2; // 右下角y paint.setColor(Color.rgb(59, 175, 218)); canvas.drawArc(oval, -90, 360, false, paint); // 绘制白色圆圈,即进度条背景 // 这里绘制已经完成的进度 oval.left = progressStrokeWidth / 2 + finishProgressStrokeWidth; // 左上角x oval.top = progressStrokeWidth / 2 + finishProgressStrokeWidth; // 左上角y oval.right = width - progressStrokeWidth / 2 - finishProgressStrokeWidth; // 左下角x oval.bottom = height - progressStrokeWidth / 2 - finishProgressStrokeWidth; // 右下角y paint.setColor(Color.rgb(59, 175, 218)); paint.setStrokeWidth(progressStrokeWidth + finishProgressStrokeWidth); // 已完成线宽 canvas.drawArc(oval, -90, (progress / maxProgress) * 360, false, paint); // 绘制进度圆弧,这里是蓝色 // 绘制正方形 paint.setStyle(Style.FILL); // 设置填满 if (!isRun) { // 暂停 canvas.drawRect(width / 3, height / 3, width / 3 + pauseThePitch, height / 3 * 2, paint); // canvas.drawRect( width / 3 * 2 - pauseThePitch, height / 3, width / 3 * 2, height / 3 * 2, paint); // } else { // 正方形 canvas.drawRect(width / 3, height / 3, width / 3 * 2, height / 3 * 2, paint); // } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); width = MeasureSpec.getSize(widthMeasureSpec); height = MeasureSpec.getSize(heightMeasureSpec); // make sure widget remain in a good appearance if ((float) height / (float) width < 0.33333F) { height = (int) ((float) width * 0.33333F); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.getMode(widthMeasureSpec)); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightMeasureSpec)); super.setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); } centerX = width / 2; centerY = height / 2; cornerRadius = centerY - shadowSpace; innerContentBound.left = outerStrokeWidth + shadowSpace; innerContentBound.top = outerStrokeWidth + shadowSpace; innerContentBound.right = width - outerStrokeWidth - shadowSpace; innerContentBound.bottom = height - outerStrokeWidth - shadowSpace; intrinsicInnerWidth = innerContentBound.width(); intrinsicInnerHeight = innerContentBound.height(); knobBound.left = outerStrokeWidth + shadowSpace; knobBound.top = outerStrokeWidth + shadowSpace; knobBound.right = height - outerStrokeWidth - shadowSpace; knobBound.bottom = height - outerStrokeWidth - shadowSpace; intrinsicKnobWidth = knobBound.height(); knobMaxExpandWidth = (float) width * 0.7F; if (knobMaxExpandWidth > knobBound.width() * 1.25F) { knobMaxExpandWidth = knobBound.width() * 1.25F; } }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public int onTestSize(int suggestedSize, RectF availableSPace) { mPaint.setTextSize(suggestedSize); String text = getText().toString(); boolean singleline = getMaxLines() == 1; if (singleline) { mTextRect.bottom = mPaint.getFontSpacing(); mTextRect.right = mPaint.measureText(text); } else { StaticLayout layout = new StaticLayout( text, mPaint, mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true); // return early if we have more lines if (getMaxLines() != NO_LINE_LIMIT && layout.getLineCount() > getMaxLines()) { return 1; } mTextRect.bottom = layout.getHeight(); int maxWidth = -1; for (int i = 0; i < layout.getLineCount(); i++) { if (maxWidth < layout.getLineWidth(i)) { maxWidth = (int) layout.getLineWidth(i); } } mTextRect.right = maxWidth; } mTextRect.offsetTo(0, 0); if (availableSPace.contains(mTextRect)) { // may be too small, don't worry we will find the best match return -1; } else { // too big return 1; } }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); padding = Math.max(w, h) * 0.1f; rect.left = padding; rect.right = w - padding; rect.top = padding; rect.bottom = h - padding; }
public void setParameterValue(ViewComponentParameter parameter) { String name = parameter.getName(); if (name.equals("backColor")) { backColor = parameter.getColorValue(); } else if (name.equals("frameWidth")) { pageFrame.right = (float) parameter.getDoubleValue(); } else if (name.equals("frameHeight")) { pageFrame.bottom = (float) parameter.getDoubleValue(); } else if (name.equals("orientation")) { orientation = parameter.getIntValue(); int orient = 0; if (orientation == 0) { orient = 0; // Landscape } else if (orientation == 1) { orient = 1; // Portrait } if (orientation == 2) { orient = 8; // Reverse Landscape } else if (orientation == 3) { orient = 9; // Reverse Portrait } else { orient = 1; // Portrait } // Log.i("BFV", "orient" + orientation); surfaceView.setCurrentViewPageOrientation(orient, true); ; } else if (name.equals("drawMap")) { drawMap = parameter.getBooleanValue(); surfaceView.drawMap(drawMap()); } else if (name.equals("autoPanMap")) { autoPanMap = parameter.getBooleanValue(); Location current = BlueFlyVario.blueFlyVario.getVarioService().getBfvLocationManager().getLocation(); if (current != null) { surfaceView.updateLocation(new LocationAltVar(current, 0, 0, 0)); } } else if (name.equals("mapSatelliteMode")) { mapSatelliteMode = parameter.getBooleanValue(); surfaceView.setDrawSatellite(mapSatelliteMode); } else if (name.equals("mapZoomLevel")) { mapZoomLevel = parameter.getIntValue(); if (mapZoomLevel < 1) { mapZoomLevel = 1; } if (mapZoomLevel > BlueFlyVario.blueFlyVario.getMapViewManager().getMap().getMaxZoomLevel()) { mapZoomLevel = BlueFlyVario.blueFlyVario.getMapViewManager().getMap().getMaxZoomLevel(); } surfaceView.setMapZoom(mapZoomLevel); } }
private void expandDirtyRect(float historicalX, float historicalY) { if (historicalX < mDirtyRect.left) { mDirtyRect.left = historicalX; } else if (historicalX > mDirtyRect.right) { mDirtyRect.right = historicalX; } if (historicalY < mDirtyRect.top) { mDirtyRect.top = historicalY; } else if (historicalY > mDirtyRect.bottom) { mDirtyRect.bottom = historicalY; } }