blob: 0ce170dfd9c22bb922b2917e03c029e3360fd605 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// 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/gfx/gfx_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 GFX_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(float scale) 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_
|