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

Side by Side Diff: ui/gfx/image/image_skia.cc

Issue 10860004: image-skia: Remove implicit conversion to SkBitmap on linux and chromeos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 4
5 #include "ui/gfx/image/image_skia.h" 5 #include "ui/gfx/image/image_skia.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 ImageSkiaReps image_reps; 269 ImageSkiaReps image_reps;
270 for (ImageSkiaReps::iterator it = internal_image_reps.begin(); 270 for (ImageSkiaReps::iterator it = internal_image_reps.begin();
271 it != internal_image_reps.end(); ++it) { 271 it != internal_image_reps.end(); ++it) {
272 if (!it->is_null()) 272 if (!it->is_null())
273 image_reps.push_back(*it); 273 image_reps.push_back(*it);
274 } 274 }
275 275
276 return image_reps; 276 return image_reps;
277 } 277 }
278 278
279 ImageSkia::operator SkBitmap&() const { 279 void ImageSkia::Init(const ImageSkiaRep& image_rep) {
280 // TODO(pkotwicz): The image should be null whenever image rep is null.
281 if (image_rep.sk_bitmap().empty()) {
282 storage_ = NULL;
283 return;
284 }
285 storage_ = new internal::ImageSkiaStorage(
286 NULL, gfx::Size(image_rep.GetWidth(), image_rep.GetHeight()));
287 storage_->image_reps().push_back(image_rep);
288 }
289
290 SkBitmap& ImageSkia::GetBitmap() const {
280 if (isNull()) { 291 if (isNull()) {
281 // Callers expect a ImageSkiaRep even if it is |isNull()|. 292 // Callers expect a ImageSkiaRep even if it is |isNull()|.
282 // TODO(pkotwicz): Fix this. 293 // TODO(pkotwicz): Fix this.
283 return NullImageRep().mutable_sk_bitmap(); 294 return NullImageRep().mutable_sk_bitmap();
284 } 295 }
285 296
286 ImageSkiaReps::iterator it = 297 ImageSkiaReps::iterator it =
287 storage_->FindRepresentation(ui::SCALE_FACTOR_100P, true); 298 storage_->FindRepresentation(ui::SCALE_FACTOR_100P, true);
288 if (it != storage_->image_reps().end()) 299 if (it != storage_->image_reps().end())
289 return it->mutable_sk_bitmap(); 300 return it->mutable_sk_bitmap();
290 return NullImageRep().mutable_sk_bitmap(); 301 return NullImageRep().mutable_sk_bitmap();
291 } 302 }
292 303
293 void ImageSkia::Init(const ImageSkiaRep& image_rep) {
294 // TODO(pkotwicz): The image should be null whenever image rep is null.
295 if (image_rep.sk_bitmap().empty()) {
296 storage_ = NULL;
297 return;
298 }
299 storage_ = new internal::ImageSkiaStorage(
300 NULL, gfx::Size(image_rep.GetWidth(), image_rep.GetHeight()));
301 storage_->image_reps().push_back(image_rep);
302 }
303
304 } // namespace gfx 304 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia.h ('k') | ui/gfx/image/image_skia_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698