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

Side by Side Diff: tools/telemetry/telemetry/core/bitmap.py

Issue 106523006: Add options to GPU pixel test to use cloud storage for reference and error images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/test/gpu/gpu_tests/pixel.py ('k') | tools/telemetry/telemetry/page/cloud_storage.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import base64 4 import base64
5 import cStringIO 5 import cStringIO
6 6
7 from telemetry.core import util 7 from telemetry.core import util
8 8
9 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'png') 9 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'png')
10 import png # pylint: disable=F0401 10 import png # pylint: disable=F0401
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 """Returns a RgbaColor for the pixel at (x, y).""" 85 """Returns a RgbaColor for the pixel at (x, y)."""
86 base = self._bpp * (y * self._width + x) 86 base = self._bpp * (y * self._width + x)
87 if self._bpp == 4: 87 if self._bpp == 4:
88 return RgbaColor(self._pixels[base + 0], self._pixels[base + 1], 88 return RgbaColor(self._pixels[base + 0], self._pixels[base + 1],
89 self._pixels[base + 2], self._pixels[base + 3]) 89 self._pixels[base + 2], self._pixels[base + 3])
90 return RgbaColor(self._pixels[base + 0], self._pixels[base + 1], 90 return RgbaColor(self._pixels[base + 0], self._pixels[base + 1],
91 self._pixels[base + 2]) 91 self._pixels[base + 2])
92 92
93 def WritePngFile(self, path): 93 def WritePngFile(self, path):
94 with open(path, "wb") as f: 94 with open(path, "wb") as f:
95 png.Writer(**self.metadata).write_array(f, self.pixels) 95 self.WritePngToFile(f)
96
97 def WritePngToFile(self, f):
dtu 2013/12/20 00:37:57 WritePngToFileObject Also unit test
Ken Russell (switch to Gerrit) 2013/12/20 01:52:51 Done.
98 png.Writer(**self._metadata).write_array(f, self.pixels)
96 99
97 @staticmethod 100 @staticmethod
98 def FromPng(png_data): 101 def FromPng(png_data):
99 width, height, pixels, meta = png.Reader(bytes=png_data).read_flat() 102 width, height, pixels, meta = png.Reader(bytes=png_data).read_flat()
100 return Bitmap(4 if meta['alpha'] else 3, width, height, pixels, meta) 103 return Bitmap(4 if meta['alpha'] else 3, width, height, pixels, meta)
101 104
102 @staticmethod 105 @staticmethod
103 def FromPngFile(path): 106 def FromPngFile(path):
104 with open(path, "rb") as f: 107 with open(path, "rb") as f:
105 return Bitmap.FromPng(f.read()) 108 return Bitmap.FromPng(f.read())
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 self._metadata = meta 217 self._metadata = meta
215 finally: 218 finally:
216 output.close() 219 output.close()
217 220
218 return self 221 return self
219 222
220 def ColorHistogram(self): 223 def ColorHistogram(self):
221 """Returns a histogram of the pixel colors in this Bitmap.""" 224 """Returns a histogram of the pixel colors in this Bitmap."""
222 # TODO(szym): Implement this. 225 # TODO(szym): Implement this.
223 raise NotImplementedError("ColorHistogram not yet implemented.") 226 raise NotImplementedError("ColorHistogram not yet implemented.")
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/pixel.py ('k') | tools/telemetry/telemetry/page/cloud_storage.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698