OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.ui.resources.dynamics; | 5 package org.chromium.ui.resources.dynamics; |
6 | 6 |
7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 import android.graphics.Canvas; | 8 import android.graphics.Canvas; |
9 import android.graphics.Color; | 9 import android.graphics.Color; |
10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 */ | 111 */ |
112 public void invalidate(Rect dirtyRect) { | 112 public void invalidate(Rect dirtyRect) { |
113 if (dirtyRect == null) { | 113 if (dirtyRect == null) { |
114 mDirtyRect.set(0, 0, mView.getWidth(), mView.getHeight()); | 114 mDirtyRect.set(0, 0, mView.getWidth(), mView.getHeight()); |
115 } else { | 115 } else { |
116 mDirtyRect.union(dirtyRect); | 116 mDirtyRect.union(dirtyRect); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 /** | 120 /** |
| 121 * @return Dirty rect that will be drawn on capture. |
| 122 */ |
| 123 protected Rect getDirtyRect() { |
| 124 return mDirtyRect; |
| 125 } |
| 126 |
| 127 /** |
121 * Called before {@link #capture(Canvas)} is called. | 128 * Called before {@link #capture(Canvas)} is called. |
122 * @param canvas The {@link Canvas} that will be drawn to. | 129 * @param canvas The {@link Canvas} that will be drawn to. |
123 * @param dirtyRect The dirty {@link Rect} or {@code null} if the entire are
a is being redrawn. | 130 * @param dirtyRect The dirty {@link Rect} or {@code null} if the entire are
a is being redrawn. |
124 */ | 131 */ |
125 protected void onCaptureStart(Canvas canvas, Rect dirtyRect) { | 132 protected void onCaptureStart(Canvas canvas, Rect dirtyRect) { |
126 } | 133 } |
127 | 134 |
128 /** | 135 /** |
129 * Called to draw the {@link View}'s contents into the passed in {@link Canv
as}. | 136 * Called to draw the {@link View}'s contents into the passed in {@link Canv
as}. |
130 * @param canvas The {@link Canvas} that will be drawn to. | 137 * @param canvas The {@link Canvas} that will be drawn to. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (mBitmap == null) { | 182 if (mBitmap == null) { |
176 mBitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.A
RGB_8888); | 183 mBitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.A
RGB_8888); |
177 mBitmap.setHasAlpha(true); | 184 mBitmap.setHasAlpha(true); |
178 mDirtyRect.set(0, 0, viewWidth, viewHeight); | 185 mDirtyRect.set(0, 0, viewWidth, viewHeight); |
179 mBitmapSize.set(0, 0, mBitmap.getWidth(), mBitmap.getHeight()); | 186 mBitmapSize.set(0, 0, mBitmap.getWidth(), mBitmap.getHeight()); |
180 } | 187 } |
181 | 188 |
182 return !isEmpty; | 189 return !isEmpty; |
183 } | 190 } |
184 } | 191 } |
OLD | NEW |