diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 21:39:29 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 21:39:29 +0000 |
commit | 18539ee85b09a1398eb545a46f137bf336670202 (patch) | |
tree | 1f07ae1a40e8782b51b586d1f880fd154ad14df5 /gfx | |
parent | 90c62d6ab15826ff2177bae02dea70ba30125ad1 (diff) | |
download | chromium_src-18539ee85b09a1398eb545a46f137bf336670202.zip chromium_src-18539ee85b09a1398eb545a46f137bf336670202.tar.gz chromium_src-18539ee85b09a1398eb545a46f137bf336670202.tar.bz2 |
Fix problem with extension context menu items losing top-level icon.
If an extension adds some context menu items, then removes them all, and adds
some more, instead of their actual icon the new items will get the default
extension icon in context menus. This is because we use the caching feature of
ImageLoadingTracker and get an immediate callback from LoadImage before we've
put the request in pending_icons_.
BUG=53543
TEST=Steps are outlined in bug report.
Review URL: http://codereview.chromium.org/3425007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/skia_util.cc | 21 | ||||
-rw-r--r-- | gfx/skia_util.h | 10 |
2 files changed, 27 insertions, 4 deletions
diff --git a/gfx/skia_util.cc b/gfx/skia_util.cc index 13ef4d9..865f8fda 100644 --- a/gfx/skia_util.cc +++ b/gfx/skia_util.cc @@ -5,6 +5,7 @@ #include "gfx/skia_util.h" #include "gfx/rect.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/include/effects/SkGradientShader.h" @@ -38,5 +39,23 @@ SkShader* CreateGradientShader(int start_point, grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode); } -} // namespace gfx +bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) { + void* addr1 = NULL; + void* addr2 = NULL; + size_t size1 = 0; + size_t size2 = 0; + + bitmap1.lockPixels(); + addr1 = bitmap1.getAddr32(0, 0); + size1 = bitmap1.getSize(); + bitmap1.unlockPixels(); + + bitmap2.lockPixels(); + addr2 = bitmap2.getAddr32(0, 0); + size2 = bitmap2.getSize(); + bitmap2.unlockPixels(); + return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize())); +} + +} // namespace gfx diff --git a/gfx/skia_util.h b/gfx/skia_util.h index 4a55c77..26c54bf 100644 --- a/gfx/skia_util.h +++ b/gfx/skia_util.h @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef APP_GFX_SKIA_UTIL_H_ -#define APP_GFX_SKIA_UTIL_H_ +#ifndef GFX_SKIA_UTIL_H_ +#define GFX_SKIA_UTIL_H_ #pragma once #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkRect.h" +class SkBitmap; class SkShader; namespace gfx { @@ -30,6 +31,9 @@ SkShader* CreateGradientShader(int start_point, SkColor start_color, SkColor end_color); +// Returns true if the two bitmaps contain the same pixels. +bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2); + } // namespace gfx; -#endif // APP_GFX_SKIA_UTIL_H_ +#endif // GFX_SKIA_UTIL_H_ |