Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for Hidpi in download UI

BUG=136949
TEST=Manual, see instructions below

Run chrome with --force-device-scale-factor=2 --highlight-missing-2x-resources
Ensure that the file type icon in the download bar shows up red

Review URL: https://chromiumcodereview.appspot.com/10703173

git-svn-id: http://src.chromium.org/svn/trunk/src/chrome/browser@148334 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information...
commit d8012efa52d512e3c42d606cb7e42e88c63fd9a1 1 parent dce66d8
pkotwicz@chromium.org authored
View
3  icon_loader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "content/public/browser/browser_thread.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#if defined(TOOLKIT_GTK)
#include "base/nix/mime_util_xdg.h"
View
6 icon_loader.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,7 +27,7 @@ typedef std::string IconGroupID;
////////////////////////////////////////////////////////////////////////////////
//
// A facility to read a file containing an icon asynchronously in the IO
-// thread. Returns the icon in the form of an SkBitmap.
+// thread. Returns the icon in the form of an ImageSkia.
//
////////////////////////////////////////////////////////////////////////////////
class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
@@ -43,7 +43,7 @@ class IconLoader : public base::RefCountedThreadSafe<IconLoader> {
public:
// Invoked when an icon has been read. |source| is the IconLoader. If the
// icon has been successfully loaded, result is non-null. This method must
- // return true if it is taking ownership of the returned bitmap.
+ // return true if it is taking ownership of the returned image.
virtual bool OnImageLoaded(IconLoader* source, gfx::Image* result) = 0;
protected:
View
27 icon_loader_chromeos.cc
@@ -14,18 +14,18 @@
#include "base/message_loop.h"
#include "chrome/browser/icon_loader.h"
#include "grit/component_extension_resources.h"
-#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia_operations.h"
#include "webkit/glue/image_decoder.h"
namespace {
-// Used with GenerateBitmapWithSize() to indicate that the image shouldn't be
+// Used with GenerateImageWithSize() to indicate that the image shouldn't be
// resized.
const int kDoNotResize = -1;
@@ -146,21 +146,21 @@ int IconMapper::Lookup(const std::string& extension,
return idr;
}
-// Returns a copy of |source| that is |pixel_size| in width and height. If
-// |pixel_size| is |kDoNotResize|, returns an unmodified copy of |source|.
+// Returns a copy of |source| that is |dip_size| in width and height. If
+// |dip_size| is |kDoNotResize|, returns an unmodified copy of |source|.
// |source| must be a square image (width == height).
-SkBitmap GenerateBitmapWithSize(const SkBitmap& source, int pixel_size) {
+gfx::ImageSkia ResizeImage(const gfx::ImageSkia& source, int dip_size) {
DCHECK(!source.isNull());
DCHECK(source.width() == source.height());
- if (pixel_size == kDoNotResize || source.width() == pixel_size)
+ if (dip_size == kDoNotResize || source.width() == dip_size)
return source;
- return skia::ImageOperations::Resize(
- source, skia::ImageOperations::RESIZE_BEST, pixel_size, pixel_size);
+ return gfx::ImageSkiaOperations::CreateResizedImage(source,
+ gfx::Size(dip_size, dip_size));
}
-int IconSizeToPixelSize(IconLoader::IconSize size) {
+int IconSizeToDIPSize(IconLoader::IconSize size) {
switch (size) {
case IconLoader::SMALL: return 16;
case IconLoader::NORMAL: return 32;
@@ -181,14 +181,9 @@ void IconLoader::ReadIcon() {
LAZY_INSTANCE_INITIALIZER;
int idr = icon_mapper.Get().Lookup(group_, icon_size_);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- scoped_refptr<base::RefCountedStaticMemory> bytes(
- rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_100P));
- DCHECK(bytes.get());
- SkBitmap bitmap;
- if (!gfx::PNGCodec::Decode(bytes->front(), bytes->size(), &bitmap))
- NOTREACHED();
+ const gfx::ImageSkia* image_skia = rb.GetImageNamed(idr).ToImageSkia();
image_.reset(new gfx::Image(
- GenerateBitmapWithSize(bitmap, IconSizeToPixelSize(icon_size_))));
+ ResizeImage(*image_skia, IconSizeToDIPSize(icon_size_))));
target_message_loop_->PostTask(
FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this));
}
View
6 icon_loader_mac.mm
@@ -10,8 +10,8 @@
#include "base/message_loop.h"
#include "base/threading/thread.h"
#include "base/sys_string_conversions.h"
-#include "skia/ext/skia_utils_mac.h"
-#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_util_mac.h"
void IconLoader::ReadIcon() {
NSString* group = base::SysUTF8ToNSString(group_);
@@ -33,7 +33,7 @@
default:
NOTREACHED();
}
- image_.reset(new gfx::Image(gfx::NSImageToSkBitmap(icon, size, false)));
+ image_.reset(new gfx::Image(gfx::ImageSkiaFromResizedNSImage(icon, size)));
}
target_message_loop_->PostTask(FROM_HERE,
Please sign in to comment.
Something went wrong with that request. Please try again.