Chinmay Garde 58e84c8bf0
Re-land "Support multiple shells in a single process. (#4932)" (#4998)
* Re-land "Support multiple shells in a single process. (#4932)"

This reverts commit 723c7d01439da4261bc836075fb55651ce9e7f03.
2018-04-13 13:48:15 -07:00

83 lines
2.1 KiB
C++

// Copyright 2015 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 SHELL_COMMON_RASTERIZER_H_
#define SHELL_COMMON_RASTERIZER_H_
#include <memory>
#include "flutter/common/task_runners.h"
#include "flutter/flow/layers/layer_tree.h"
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/shell/common/surface.h"
#include "flutter/synchronization/pipeline.h"
#include "lib/fxl/functional/closure.h"
#include "lib/fxl/synchronization/waitable_event.h"
namespace shell {
class Rasterizer final {
public:
Rasterizer(blink::TaskRunners task_runners);
~Rasterizer();
void Setup(std::unique_ptr<Surface> surface);
void Teardown();
fml::WeakPtr<Rasterizer> GetWeakPtr() const;
flow::LayerTree* GetLastLayerTree();
void DrawLastLayerTree();
flow::TextureRegistry* GetTextureRegistry();
void Draw(fxl::RefPtr<flutter::Pipeline<flow::LayerTree>> pipeline);
enum class ScreenshotType {
SkiaPicture,
UncompressedImage, // In kN32_SkColorType format
CompressedImage,
};
struct Screenshot {
sk_sp<SkData> data;
SkISize frame_size = SkISize::MakeEmpty();
Screenshot() {}
Screenshot(sk_sp<SkData> p_data, SkISize p_size)
: data(std::move(p_data)), frame_size(p_size) {}
};
Screenshot ScreenshotLastLayerTree(ScreenshotType type, bool base64_encode);
// Sets a callback that will be executed after the next frame is submitted to
// the surface on the GPU task runner.
void SetNextFrameCallback(fxl::Closure callback);
private:
blink::TaskRunners task_runners_;
std::unique_ptr<Surface> surface_;
std::unique_ptr<flow::CompositorContext> compositor_context_;
std::unique_ptr<flow::LayerTree> last_layer_tree_;
fxl::Closure next_frame_callback_;
fml::WeakPtr<Rasterizer> weak_prototype_;
fml::WeakPtrFactory<Rasterizer> weak_factory_;
void DoDraw(std::unique_ptr<flow::LayerTree> layer_tree);
bool DrawToSurface(flow::LayerTree& layer_tree);
void FireNextFrameCallbackIfPresent();
FXL_DISALLOW_COPY_AND_ASSIGN(Rasterizer);
};
} // namespace shell
#endif // SHELL_COMMON_RASTERIZER_H_