2016-07-30 21:35:14 +02:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
2016-07-20 11:30:06 +02:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2016-08-03 11:01:35 +09:00
|
|
|
#ifndef ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|
|
|
|
#define ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2016-07-27 19:44:41 +02:00
|
|
|
#include "base/callback.h"
|
2017-12-18 12:31:54 +03:00
|
|
|
#include "components/viz/service/display/software_output_device.h"
|
2016-07-20 11:30:06 +02:00
|
|
|
#include "third_party/skia/include/core/SkBitmap.h"
|
|
|
|
#include "third_party/skia/include/core/SkCanvas.h"
|
|
|
|
|
|
|
|
namespace atom {
|
2016-07-27 19:59:01 +02:00
|
|
|
|
2016-08-04 13:22:19 +09:00
|
|
|
typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2017-12-18 12:31:54 +03:00
|
|
|
class OffScreenOutputDevice : public viz::SoftwareOutputDevice {
|
2016-07-31 12:19:56 +02:00
|
|
|
public:
|
2016-07-27 19:59:01 +02:00
|
|
|
OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback);
|
2018-05-03 23:45:12 -07:00
|
|
|
~OffScreenOutputDevice() override;
|
2016-07-20 11:30:06 +02:00
|
|
|
|
2017-12-18 12:31:54 +03:00
|
|
|
// viz::SoftwareOutputDevice:
|
2016-07-20 11:30:06 +02: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 22:50:04 +01:00
|
|
|
void SetActive(bool active, bool paint);
|
2016-07-27 19:44:41 +02:00
|
|
|
void OnPaint(const gfx::Rect& damage_rect);
|
|
|
|
|
2016-07-31 12:19:56 +02:00
|
|
|
private:
|
2016-07-27 19:59:01 +02:00
|
|
|
const bool transparent_;
|
2016-08-03 13:04:36 +09:00
|
|
|
OnPaintCallback callback_;
|
2016-07-27 19:44:41 +02:00
|
|
|
|
2018-05-22 00:18:38 +02:00
|
|
|
bool active_ = false;
|
2016-07-27 19:44:41 +02:00
|
|
|
|
2016-07-20 11:30:06 +02:00
|
|
|
std::unique_ptr<SkCanvas> canvas_;
|
|
|
|
std::unique_ptr<SkBitmap> bitmap_;
|
2017-10-19 21:04:21 +02:00
|
|
|
gfx::Rect pending_damage_rect_;
|
2016-07-20 11:30:06 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
2016-08-03 11:01:35 +09:00
|
|
|
#endif // ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
|