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

Unified Diff: tools/telemetry/telemetry/core/bitmaptools/__init__.py

Issue 108333004: [telemetry] Implement per-pixel algorithms in Bitmap as a C++ extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comment that IsEqual does not compare alpha Created 7 years 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
Index: tools/telemetry/telemetry/core/bitmaptools/__init__.py
diff --git a/tools/telemetry/telemetry/core/bitmaptools/__init__.py b/tools/telemetry/telemetry/core/bitmaptools/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..8bf7958123d4b0e2d1d6ab34375ffe71e35ea447
--- /dev/null
+++ b/tools/telemetry/telemetry/core/bitmaptools/__init__.py
@@ -0,0 +1,39 @@
+""" Bitmap processing routines.
tonyg 2013/12/12 22:17:48 Please add the standard copyright.
szym 2013/12/12 22:54:12 Done.
+
+All functions accept a tuple of (pixels, width, channels) as the first argument.
+Bounding box is a tuple (left, right, width, height).
+"""
+
+def _BuildExtension():
+ """Builds the extension library in place."""
tonyg 2013/12/12 22:17:48 Clever!
+ import os
+ from distutils import log
+ from distutils.core import Distribution, Extension
+
+ dirname = os.path.dirname(__file__)
+ # Source file paths must be relative to current path.
+ relpath = os.path.relpath(dirname, os.getcwd())
+ src_files = [
+ os.path.join(relpath, 'bitmaptools.cc')
+ ]
+ dist = Distribution({
+ 'ext_modules': [ Extension('bitmaptools', src_files) ]
+ })
+ dist.script_args = ['build_ext', '--build-temp', 'build',
+ '--build-lib', dirname]
+ dist.parse_command_line()
+ log.set_threshold(log.ERROR)
+ dist.run_commands()
+ dist.script_args = ['clean', '--all']
+ dist.parse_command_line()
+ log.set_threshold(log.ERROR)
+ dist.run_commands()
tonyg 2013/12/12 22:17:48 I don't follow exactly how this works. Does this r
szym 2013/12/12 22:54:12 This _BuildExtension() is equivalent to running ma
tonyg 2013/12/12 23:19:02 Even with 'clean' in script_args?
szym 2013/12/12 23:30:36 'clean' removes the build-temp directory, not the
+
+try:
+ _BuildExtension()
+except:
+ # TODO(tonyg): fetch from cloudstorage
+ raise
tonyg 2013/12/12 22:17:48 In practice, when will we hit this?
szym 2013/12/12 22:54:12 On Ubuntu, no python-dev or build-essential.
tonyg 2013/12/12 23:19:02 The GPU tests do rely on the Bitmap class on all p
szym 2013/12/12 23:30:36 How can we check if it works on all platforms?
+
+# pylint: disable=W0401
+from .bitmaptools import *

Powered by Google App Engine
This is Rietveld 408576698