| Index: ui/gfx/image/image_skia_operations.cc
|
| diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc
|
| index c4bbce4ac6fa482259dd75f71423fc7e8a427470..97da1bf5a7320d0a14f9634a10f4ae40396c20e9 100644
|
| --- a/ui/gfx/image/image_skia_operations.cc
|
| +++ b/ui/gfx/image/image_skia_operations.cc
|
| @@ -10,6 +10,8 @@
|
| #include "skia/ext/platform_canvas.h"
|
| #include "ui/base/layout.h"
|
| #include "ui/base/ui_base_switches.h"
|
| +#include "ui/gfx/canvas.h"
|
| +#include "ui/gfx/image/canvas_image_source.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/image/image_skia_rep.h"
|
| #include "ui/gfx/image/image_skia_source.h"
|
| @@ -89,6 +91,33 @@ class BlendingImageSource : public gfx::ImageSkiaSource {
|
| DISALLOW_COPY_AND_ASSIGN(BlendingImageSource);
|
| };
|
|
|
| +class SuperimposedImageSource : public gfx::CanvasImageSource {
|
| + public:
|
| + SuperimposedImageSource(const gfx::ImageSkia& first,
|
| + const gfx::ImageSkia& second)
|
| + : gfx::CanvasImageSource(first.size(), false /* is opaque */),
|
| + first_(first),
|
| + second_(second) {
|
| + }
|
| +
|
| + virtual ~SuperimposedImageSource() {}
|
| +
|
| + // gfx::CanvasImageSource override.
|
| + virtual void Draw(gfx::Canvas* canvas) OVERRIDE {
|
| + canvas->DrawImageInt(first_, 0, 0, SkPaint());
|
| + canvas->DrawImageInt(second_,
|
| + (first_.width() - second_.width()) / 2,
|
| + (first_.height() - second_.height()) / 2,
|
| + SkPaint());
|
| + }
|
| +
|
| + private:
|
| + const gfx::ImageSkia first_;
|
| + const gfx::ImageSkia second_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SuperimposedImageSource);
|
| +};
|
| +
|
| class MaskedImageSource : public gfx::ImageSkiaSource {
|
| public:
|
| MaskedImageSource(const ImageSkia& rgb, const ImageSkia& alpha)
|
| @@ -322,6 +351,13 @@ ImageSkia ImageSkiaOperations::CreateBlendedImage(const ImageSkia& first,
|
| }
|
|
|
| // static
|
| +ImageSkia ImageSkiaOperations::CreateSuperimposedImage(
|
| + const ImageSkia& first,
|
| + const ImageSkia& second) {
|
| + return ImageSkia(new SuperimposedImageSource(first, second), first.size());
|
| +}
|
| +
|
| +// static
|
| ImageSkia ImageSkiaOperations::CreateMaskedImage(const ImageSkia& rgb,
|
| const ImageSkia& alpha) {
|
| return ImageSkia(new MaskedImageSource(rgb, alpha), rgb.size());
|
|
|