Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: tools/telemetry/telemetry/core/tab.py

Issue 121493004: [telemetry] Implement per-pixel algorithms in Bitmap as a C++ extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/build_extension.py ('k') | tools/telemetry/telemetry/core/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/tab.py
diff --git a/tools/telemetry/telemetry/core/tab.py b/tools/telemetry/telemetry/core/tab.py
index 11bed68898407dbe2a1f54d2c781dc60512974b5..a4fa2a622610cae84ac9fc57de884dc9454ff94a 100644
--- a/tools/telemetry/telemetry/core/tab.py
+++ b/tools/telemetry/telemetry/core/tab.py
@@ -135,9 +135,10 @@ class Tab(web_contents.WebContents):
bitmap is a telemetry.core.Bitmap.
"""
content_box = None
+ start_time = None
for timestamp, bmp in self.browser.platform.StopVideoCapture():
if not content_box:
- content_box = bmp.GetBoundingBox(
+ content_box, pixel_count = bmp.GetBoundingBox(
bitmap.RgbaColor(*_CONTENT_FLASH_COLOR), tolerance=4)
assert content_box, 'Failed to find tab contents in first video frame.'
@@ -145,23 +146,25 @@ class Tab(web_contents.WebContents):
# We assume arbitrarily that tabs are all larger than 200x200. If this
# fails it either means that assumption has changed or something is
# awry with our bounding box calculation.
- assert content_box.width > 200 and content_box.height > 200, \
- 'Unexpectedly small tab contents'
+ assert content_box[2] > 200 and content_box[3] > 200, \
+ 'Unexpectedly small tab contents.'
+ assert pixel_count > 0.75 * bmp.width * bmp.height, \
+ 'Low count of pixels in tab contents matching expected color.'
# Since Telemetry doesn't know how to resize the window, we assume
# that we should always get the same content box for a tab. If this
- # fails, it meas either that assumption has changed or something is
+ # fails, it means either that assumption has changed or something is
# awry with our bounding box calculation.
if self._previous_tab_contents_bounding_box:
assert self._previous_tab_contents_bounding_box == content_box, \
'Unexpected change in tab contents box.'
self._previous_tab_contents_bounding_box = content_box
-
continue
- bmp.Crop(content_box)
- # TODO(tonyg): Translate timestamp into navigation timing space.
- yield timestamp, bmp
+ elif not start_time:
+ start_time = timestamp
+
+ yield timestamp - start_time, bmp.Crop(*content_box)
def PerformActionAndWaitForNavigate(
self, action_function, timeout=DEFAULT_TAB_TIMEOUT):
« no previous file with comments | « tools/telemetry/telemetry/core/build_extension.py ('k') | tools/telemetry/telemetry/core/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698