| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 #if !defined(OS_WIN) | 504 #if !defined(OS_WIN) |
| 505 CHECK(CanRead()); | 505 CHECK(CanRead()); |
| 506 #endif | 506 #endif |
| 507 | 507 |
| 508 ImageSkiaReps::iterator it = storage_->FindRepresentation(1.0f, true); | 508 ImageSkiaReps::iterator it = storage_->FindRepresentation(1.0f, true); |
| 509 if (it != storage_->image_reps().end()) | 509 if (it != storage_->image_reps().end()) |
| 510 return it->sk_bitmap(); | 510 return it->sk_bitmap(); |
| 511 return NullImageRep().sk_bitmap(); | 511 return NullImageRep().sk_bitmap(); |
| 512 } | 512 } |
| 513 | 513 |
| 514 // TODOs in ImageSkia() also apply to GetBitmap2x(). |
| 515 const SkBitmap& ImageSkia::GetBitmap2x() const { |
| 516 if (isNull()) { |
| 517 return NullImageRep().sk_bitmap(); |
| 518 } |
| 519 |
| 520 #if !defined(OS_WIN) |
| 521 CHECK(CanRead()); |
| 522 #endif |
| 523 |
| 524 ImageSkiaReps::iterator it = storage_->FindRepresentation(2.0f, true); |
| 525 if (it != storage_->image_reps().end()) |
| 526 return it->sk_bitmap(); |
| 527 return NullImageRep().sk_bitmap(); |
| 528 } |
| 529 |
| 514 bool ImageSkia::CanRead() const { | 530 bool ImageSkia::CanRead() const { |
| 515 return !storage_.get() || storage_->CanRead(); | 531 return !storage_.get() || storage_->CanRead(); |
| 516 } | 532 } |
| 517 | 533 |
| 518 bool ImageSkia::CanModify() const { | 534 bool ImageSkia::CanModify() const { |
| 519 return !storage_.get() || storage_->CanModify(); | 535 return !storage_.get() || storage_->CanModify(); |
| 520 } | 536 } |
| 521 | 537 |
| 522 void ImageSkia::DetachStorageFromThread() { | 538 void ImageSkia::DetachStorageFromThread() { |
| 523 if (storage_.get()) | 539 if (storage_.get()) |
| 524 storage_->DetachFromThread(); | 540 storage_->DetachFromThread(); |
| 525 } | 541 } |
| 526 | 542 |
| 527 } // namespace gfx | 543 } // namespace gfx |
| OLD | NEW |