| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/threading/simple_thread.h" | 8 #include "base/threading/simple_thread.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
| 12 #include "ui/gfx/image/image_skia_rep.h" | 12 #include "ui/gfx/image/image_skia_rep.h" |
| 13 #include "ui/gfx/image/image_skia_source.h" | 13 #include "ui/gfx/image/image_skia_source.h" |
| 14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 15 | 15 |
| 16 // Duplicated from base/threading/non_thread_safe.h so that we can be | 16 // Duplicated from base/threading/non_thread_safe.h so that we can be |
| 17 // good citizens there and undef the macro. | 17 // good citizens there and undef the macro. |
| 18 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 18 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 19 #define ENABLE_NON_THREAD_SAFE 1 | 19 #define ENABLE_NON_THREAD_SAFE 1 |
| 20 #else | 20 #else |
| 21 #define ENABLE_NON_THREAD_SAFE 0 | 21 #define ENABLE_NON_THREAD_SAFE 0 |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace gfx { | 24 namespace gfx { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class FixedSource : public ImageSkiaSource { | 28 class FixedSource : public ImageSkiaSource { |
| 29 public: | 29 public: |
| 30 FixedSource(const ImageSkiaRep& image) : image_(image) {} | 30 explicit FixedSource(const ImageSkiaRep& image) : image_(image) {} |
| 31 | 31 |
| 32 virtual ~FixedSource() { | 32 virtual ~FixedSource() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 35 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| 36 return image_; | 36 return image_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 ImageSkiaRep image_; | 40 ImageSkiaRep image_; |
| 41 | 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(FixedSource); | 42 DISALLOW_COPY_AND_ASSIGN(FixedSource); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 class DynamicSource : public ImageSkiaSource { | 45 class DynamicSource : public ImageSkiaSource { |
| 46 public: | 46 public: |
| 47 DynamicSource(const gfx::Size& size) : size_(size) {} | 47 explicit DynamicSource(const gfx::Size& size) : size_(size) {} |
| 48 | 48 |
| 49 virtual ~DynamicSource() { | 49 virtual ~DynamicSource() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { | 52 virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| 53 return gfx::ImageSkiaRep(size_, scale_factor); | 53 return gfx::ImageSkiaRep(size_, scale_factor); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 gfx::Size size_; | 57 gfx::Size size_; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 EXPECT_FALSE(threadsafe_on_thread.can_modify()); | 373 EXPECT_FALSE(threadsafe_on_thread.can_modify()); |
| 374 EXPECT_TRUE(image.CanRead()); | 374 EXPECT_TRUE(image.CanRead()); |
| 375 EXPECT_FALSE(image.CanModify()); | 375 EXPECT_FALSE(image.CanModify()); |
| 376 } | 376 } |
| 377 #endif // ENABLE_NON_THREAD_SAFE | 377 #endif // ENABLE_NON_THREAD_SAFE |
| 378 | 378 |
| 379 // Just in case we ever get lumped together with other compilation units. | 379 // Just in case we ever get lumped together with other compilation units. |
| 380 #undef ENABLE_NON_THREAD_SAFE | 380 #undef ENABLE_NON_THREAD_SAFE |
| 381 | 381 |
| 382 } // namespace gfx | 382 } // namespace gfx |
| OLD | NEW |