2016-07-30 19:35:14 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
2016-07-20 09:30:06 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2016-08-03 02:01:35 +00:00
|
|
|
#ifndef ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|
|
|
|
#define ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|
2016-07-20 09:30:06 +00:00
|
|
|
|
2016-07-27 17:44:41 +00:00
|
|
|
#include "base/callback.h"
|
2016-07-20 09:30:06 +00:00
|
|
|
#include "cc/output/software_output_device.h"
|
|
|
|
#include "third_party/skia/include/core/SkBitmap.h"
|
|
|
|
#include "third_party/skia/include/core/SkCanvas.h"
|
|
|
|
|
|
|
|
namespace atom {
|
2016-07-27 17:59:01 +00:00
|
|
|
|
2016-08-04 04:22:19 +00:00
|
|
|
typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
|
2016-07-20 09:30:06 +00:00
|
|
|
|
|
|
|
class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
2016-07-31 10:19:56 +00:00
|
|
|
public:
|
2016-07-27 17:59:01 +00:00
|
|
|
OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback);
|
2016-07-20 09:30:06 +00:00
|
|
|
~OffScreenOutputDevice();
|
|
|
|
|
2016-08-03 04:04:36 +00:00
|
|
|
// cc::SoftwareOutputDevice:
|
2016-07-20 09:30:06 +00:00
|
|
|
void Resize(const gfx::Size& pixel_size, float scale_factor) override;
|
|
|
|
SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
|
|
|
|
void EndPaint() override;
|
|
|
|
|
2017-11-02 21:50:04 +00:00
|
|
|
void SetActive(bool active, bool paint);
|
2016-07-27 17:44:41 +00:00
|
|
|
void OnPaint(const gfx::Rect& damage_rect);
|
|
|
|
|
2016-07-31 10:19:56 +00:00
|
|
|
private:
|
2016-07-27 17:59:01 +00:00
|
|
|
const bool transparent_;
|
2016-08-03 04:04:36 +00:00
|
|
|
OnPaintCallback callback_;
|
2016-07-27 17:44:41 +00:00
|
|
|
|
|
|
|
bool active_;
|
|
|
|
|
2016-07-20 09:30:06 +00:00
|
|
|
std::unique_ptr<SkCanvas> canvas_;
|
|
|
|
std::unique_ptr<SkBitmap> bitmap_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2016-08-03 02:01:35 +00:00
|
|
|
#endif // ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|