diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 05:43:05 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 05:43:05 +0000 |
commit | cb7a6399f3bed1a6800ac93a3a5edb44468fb62c (patch) | |
tree | 19980b87b6ac5fed65c3b1c2a0c91c66e01d9d0a /ui/gfx/image/canvas_image_source.h | |
parent | 452b36f61997247d832fc61df0820e6fd161a696 (diff) | |
download | chromium_src-cb7a6399f3bed1a6800ac93a3a5edb44468fb62c.zip chromium_src-cb7a6399f3bed1a6800ac93a3a5edb44468fb62c.tar.gz chromium_src-cb7a6399f3bed1a6800ac93a3a5edb44468fb62c.tar.bz2 |
Support high dpi in menu scroll arrow, submenu arrow and drag_utils.
Created CanvasImageSource utility class to simplify the image creating using canvas.
BUG=122992
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/10702136
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/image/canvas_image_source.h')
-rw-r--r-- | ui/gfx/image/canvas_image_source.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ui/gfx/image/canvas_image_source.h b/ui/gfx/image/canvas_image_source.h new file mode 100644 index 0000000..a713b95 --- /dev/null +++ b/ui/gfx/image/canvas_image_source.h @@ -0,0 +1,46 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ +#define UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/base/ui_export.h" +#include "ui/gfx/image/image_skia_source.h" +#include "ui/gfx/size.h" + +namespace gfx { +class Canvas; +class ImageSkiaRep; + +// CanvasImageSource is useful if you need to generate an image for +// a scale factor using gfx::Canvas. It creates a new Canvas +// with target scale factor and generates ImageSkiaRep when drawing is +// completed. +class UI_EXPORT CanvasImageSource : public gfx::ImageSkiaSource { + public: + CanvasImageSource(const gfx::Size& size, bool is_opaque); + + // Called when a new image needs to be drawn for a scale factor. + virtual void Draw(gfx::Canvas* canvas) = 0; + + // Returns the size of images in DIP that this source will generate. + const gfx::Size& size() const { return size_; }; + + // Overridden from gfx::ImageSkiaSource. + virtual gfx::ImageSkiaRep GetImageForScale( + ui::ScaleFactor scale_factor) OVERRIDE; + + protected: + virtual ~CanvasImageSource() {} + + const gfx::Size size_; + const bool is_opaque_; + DISALLOW_COPY_AND_ASSIGN(CanvasImageSource); +}; + +} // namespace gfx + +#endif // UI_GFX_IMAGE_CANVAS_IMAGE_SOURCE_H_ |