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

Unified Diff: ui/gfx/image/image_util.h

Issue 1836483002: Fix up and rename VisibleMargins() in preparation for making use of it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 4 years, 9 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 | « no previous file | ui/gfx/image/image_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image_util.h
diff --git a/ui/gfx/image/image_util.h b/ui/gfx/image/image_util.h
index c2ce2a105f6b543803836cfc1380c89c70493665..8f17c368a8cada1d3456f17fc1b53b23c9eef03f 100644
--- a/ui/gfx/image/image_util.h
+++ b/ui/gfx/image/image_util.h
@@ -33,21 +33,15 @@ GFX_EXPORT bool JPEG1xEncodedDataFromImage(const Image& image,
int quality,
std::vector<unsigned char>* dst);
-// Returns the visible (non-transparent) width of the 1x rep of the given
-// image. If the image has no transparency, the leading value will be 0 and
-// the trailing will be the image width. Return values are in the 1x width
-// pixel units. Margins are given in 0-based column format. So if the image
-// has only transparent pixels in columns 0, 1, 2, 3, then the leading value
-// will be 4. Similarly, if there are all transparent pixels in column
-// width-2, width-1, then the trailing margin value will be width-3.
-// Returns true if the value is computed from opacity, false if it is a
-// default value because of null image, missing Rep, etc.
-// This method is only suitable for fairly small images (i.e. 16x16).
-// The margins for a completely transparent image will be w/2-1, w/2, but this
-// will be an expensive operation: it isn't expected that it will be frequently
-// calculated.
-GFX_EXPORT bool VisibleMargins(const ImageSkia& image,
- int* leading, int* trailing);
+// Computes the width of any nearly-transparent regions at the sides of the
+// image and returns them in |left| and |right|. This checks each column of
+// pixels from the outsides in, looking for anything with alpha above a
+// reasonably small value. For a fully-opaque image, the margins will thus be
+// (0, 0); for a fully-transparent image, the margins will be
+// (width / 2, width / 2), with |left| getting the extra pixel for odd widths.
+GFX_EXPORT void GetVisibleMargins(const ImageSkia& image,
+ int* left,
+ int* right);
} // namespace gfx
« no previous file with comments | « no previous file | ui/gfx/image/image_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698