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

Unified Diff: ui/gfx/image/image_skia.cc

Issue 11028064: Resize images for hi-dpi based on a custom PNG chunk added by GRIT r78, and roll GRIT r78 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 2 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
« ui/base/resource/resource_bundle.cc ('K') | « ui/gfx/image/image_skia.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image_skia.cc
diff --git a/ui/gfx/image/image_skia.cc b/ui/gfx/image/image_skia.cc
index e86b5e0228f64cd378e307b4cb002c54d7f81ff2..6c73b02ef8cfa915188fefe386026a09344ed2c0 100644
--- a/ui/gfx/image/image_skia.cc
+++ b/ui/gfx/image/image_skia.cc
@@ -58,6 +58,16 @@ class ImageSkiaStorage : public base::RefCounted<ImageSkiaStorage>,
read_only_(false) {
}
+ ImageSkiaStorage(ImageSkiaSource* source, ui::ScaleFactor scale_factor)
+ : source_(source),
+ read_only_(false) {
+ const ImageSkiaRep& image = *FindRepresentation(scale_factor, true);
+ if (image.is_null())
+ source_.reset();
oshima 2012/10/11 01:31:54 no need to reset here. You can just check image_re
benrg 2012/10/15 21:58:54 It's not empty -- FindRepresentation inserts an em
oshima 2012/10/16 23:12:09 ok, you can still use image_reps().begin()->is_nul
+ else
+ size_.SetSize(image.GetWidth(), image.GetHeight());
+ }
+
bool has_source() const { return source_.get() != NULL; }
std::vector<gfx::ImageSkiaRep>& image_reps() { return image_reps_; }
@@ -162,7 +172,7 @@ class ImageSkiaStorage : public base::RefCounted<ImageSkiaStorage>,
scoped_ptr<ImageSkiaSource> source_;
// Size of the image in DIP.
- const gfx::Size size_;
+ gfx::Size size_;
bool read_only_;
@@ -181,6 +191,15 @@ ImageSkia::ImageSkia(ImageSkiaSource* source, const gfx::Size& size)
DetachStorageFromThread();
}
+ImageSkia::ImageSkia(ImageSkiaSource* source, ui::ScaleFactor scale_factor)
+ : storage_(new internal::ImageSkiaStorage(source, scale_factor)) {
+ DCHECK(source);
+ if (!storage_->has_source())
+ storage_ = NULL;
+ // No other thread has reference to this, so it's safe to detach the thread.
+ DetachStorageFromThread();
+}
+
ImageSkia::ImageSkia(const SkBitmap& bitmap) {
Init(ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P));
// No other thread has reference to this, so it's safe to detach the thread.
« ui/base/resource/resource_bundle.cc ('K') | « ui/gfx/image/image_skia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698