OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ |
| 6 #define UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "ui/base/ui_export.h" |
| 12 #include "ui/gfx/image/image_skia_source.h" |
| 13 #include "ui/gfx/size.h" |
| 14 |
| 15 namespace gfx { |
| 16 class Canvas; |
| 17 class ImageSkiaRep; |
| 18 |
| 19 // CanvasImageSource is useful if you need to generate an image for |
| 20 // a scale factor using gfx::Canvas. It creates a new Canvas |
| 21 // with target scale factor and generates ImageSkiaRep when drawing is |
| 22 // completed. |
| 23 class UI_EXPORT CanvasImageSource : public gfx::ImageSkiaSource { |
| 24 public: |
| 25 CanvasImageSource(const gfx::Size& size, bool is_opaque); |
| 26 |
| 27 // Called when a new image needs to be drawn for a scale factor. |
| 28 virtual void Draw(gfx::Canvas* canvas) = 0; |
| 29 |
| 30 // Returns the size of images in DIP that this source will generate. |
| 31 const gfx::Size& size() const { return size_; }; |
| 32 |
| 33 // Overridden from gfx::ImageSkiaSource. |
| 34 virtual gfx::ImageSkiaRep GetImageForScale( |
| 35 ui::ScaleFactor scale_factor) OVERRIDE; |
| 36 |
| 37 protected: |
| 38 virtual ~CanvasImageSource() {} |
| 39 |
| 40 const gfx::Size size_; |
| 41 const bool is_opaque_; |
| 42 DISALLOW_COPY_AND_ASSIGN(CanvasImageSource); |
| 43 }; |
| 44 |
| 45 } // namespace gfx |
| 46 |
| 47 #endif // UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ |
OLD | NEW |