提交 b9ff3941 编写于 作者: A Adam Barth

Break dependency from Layer to PaintContext (#2609)

Instead, make Layer::Paint take a new PaintContext that has just exactly
the state that it needs, mirroring PrerollContext. Also, rename
PaintContext to CompositorContext because it holds the context for the
whole compositor.
上级 dda79d03
......@@ -6,6 +6,8 @@ source_set("flow") {
sources = [
"checkerboard.cc",
"checkerboard.h",
"compositor_context.cc",
"compositor_context.h",
"instrumentation.cc",
"instrumentation.h",
"layers/backdrop_filter_layer.cc",
......@@ -36,8 +38,6 @@ source_set("flow") {
"layers/shader_mask_layer.h",
"layers/transform_layer.cc",
"layers/transform_layer.h",
"paint_context.cc",
"paint_context.h",
"raster_cache.cc",
"raster_cache.h",
]
......
......@@ -2,54 +2,56 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flow/paint_context.h"
#include "flow/compositor_context.h"
#include "base/logging.h"
#include "third_party/skia/include/core/SkCanvas.h"
namespace flow {
PaintContext::PaintContext() {
CompositorContext::CompositorContext() {
}
void PaintContext::BeginFrame(ScopedFrame& frame, bool enableInstrumentation) {
if (enableInstrumentation) {
CompositorContext::~CompositorContext() {
}
void CompositorContext::BeginFrame(ScopedFrame& frame,
bool enable_instrumentation) {
if (enable_instrumentation) {
frame_count_.Increment();
frame_time_.Start();
}
}
void PaintContext::EndFrame(ScopedFrame& frame, bool enableInstrumentation) {
void CompositorContext::EndFrame(ScopedFrame& frame,
bool enable_instrumentation) {
raster_cache_.SweepAfterFrame();
if (enableInstrumentation) {
if (enable_instrumentation) {
frame_time_.Stop();
}
}
PaintContext::ScopedFrame PaintContext::AcquireFrame(
CompositorContext::ScopedFrame CompositorContext::AcquireFrame(
GrContext* gr_context, SkCanvas& canvas, bool instrumentation_enabled) {
return ScopedFrame(*this, gr_context, canvas, instrumentation_enabled);
}
PaintContext::ScopedFrame::ScopedFrame(PaintContext& context,
GrContext* gr_context,
SkCanvas& canvas,
bool instrumentation_enabled)
CompositorContext::ScopedFrame::ScopedFrame(CompositorContext& context,
GrContext* gr_context,
SkCanvas& canvas,
bool instrumentation_enabled)
: context_(context), gr_context_(gr_context), canvas_(&canvas),
instrumentation_enabled_(instrumentation_enabled) {
context_.BeginFrame(*this, instrumentation_enabled_);
}
PaintContext::ScopedFrame::ScopedFrame(ScopedFrame&& frame) = default;
CompositorContext::ScopedFrame::ScopedFrame(ScopedFrame&& frame) = default;
PaintContext::ScopedFrame::~ScopedFrame() {
CompositorContext::ScopedFrame::~ScopedFrame() {
context_.EndFrame(*this, instrumentation_enabled_);
}
PaintContext::~PaintContext() {
}
void PaintContext::OnGrContextDestroyed() {
void CompositorContext::OnGrContextDestroyed() {
raster_cache_.Clear();
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLOW_PAINT_CONTEXT_H_
#define FLOW_PAINT_CONTEXT_H_
#ifndef FLOW_COMPOSITOR_CONTEXT_H_
#define FLOW_COMPOSITOR_CONTEXT_H_
#include <memory>
#include <string>
......@@ -17,35 +17,35 @@
namespace flow {
class PaintContext {
class CompositorContext {
public:
class ScopedFrame {
public:
SkCanvas& canvas() { return *canvas_; }
PaintContext& context() const { return context_; }
CompositorContext& context() const { return context_; }
GrContext* gr_context() const { return gr_context_; }
ScopedFrame(ScopedFrame&& frame);
~ScopedFrame();
private:
PaintContext& context_;
CompositorContext& context_;
GrContext* gr_context_;
SkCanvas* canvas_;
const bool instrumentation_enabled_;
ScopedFrame(PaintContext& context,
ScopedFrame(CompositorContext& context,
GrContext* gr_context,
SkCanvas& canvas,
bool instrumentation_enabled);
friend class PaintContext;
friend class CompositorContext;
DISALLOW_COPY_AND_ASSIGN(ScopedFrame);
};
PaintContext();
~PaintContext();
CompositorContext();
~CompositorContext();
ScopedFrame AcquireFrame(GrContext* gr_context,
SkCanvas& canvas,
......@@ -65,12 +65,12 @@ class PaintContext {
Stopwatch frame_time_;
Stopwatch engine_time_;
void BeginFrame(ScopedFrame& frame, bool enableInstrumentation);
void EndFrame(ScopedFrame& frame, bool enableInstrumentation);
void BeginFrame(ScopedFrame& frame, bool enable_instrumentation);
void EndFrame(ScopedFrame& frame, bool enable_instrumentation);
DISALLOW_COPY_AND_ASSIGN(PaintContext);
DISALLOW_COPY_AND_ASSIGN(CompositorContext);
};
} // namespace flow
#endif // FLOW_PAINT_CONTEXT_H_
#endif // FLOW_COMPOSITOR_CONTEXT_H_
......@@ -4,6 +4,8 @@
#include "flow/layers/backdrop_filter_layer.h"
#include "third_party/skia/include/core/SkImageFilter.h"
namespace flow {
BackdropFilterLayer::BackdropFilterLayer() {
......@@ -12,12 +14,11 @@ BackdropFilterLayer::BackdropFilterLayer() {
BackdropFilterLayer::~BackdropFilterLayer() {
}
void BackdropFilterLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(SkCanvas::SaveLayerRec{
void BackdropFilterLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(SkCanvas::SaveLayerRec{
&paint_bounds(), nullptr, filter_.get(), 0});
PaintChildren(frame);
PaintChildren(context);
}
} // namespace flow
......@@ -17,7 +17,7 @@ class BackdropFilterLayer : public ContainerLayer {
void set_filter(SkImageFilter* filter) { filter_ = skia::SharePtr(filter); }
protected:
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
skia::RefPtr<SkImageFilter> filter_;
......
......@@ -24,7 +24,7 @@ void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
transform_.preScale(inverse_device_pixel_ratio, inverse_device_pixel_ratio);
}
void ChildSceneLayer::Paint(PaintContext::ScopedFrame& frame) {
void ChildSceneLayer::Paint(PaintContext& context) {
}
void ChildSceneLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
......
......@@ -30,7 +30,7 @@ class ChildSceneLayer : public Layer {
}
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
mojo::gfx::composition::Node* container) override;
......
......@@ -19,12 +19,11 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
set_paint_bounds(context->child_paint_bounds);
}
void ClipPathLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(&paint_bounds(), nullptr);
canvas.clipPath(clip_path_);
PaintChildren(frame);
void ClipPathLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(&paint_bounds(), nullptr);
context.canvas.clipPath(clip_path_);
PaintChildren(context);
}
} // namespace flow
......@@ -18,7 +18,7 @@ class ClipPathLayer : public ContainerLayer {
protected:
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkPath clip_path_;
......
......@@ -19,11 +19,10 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
set_paint_bounds(context->child_paint_bounds);
}
void ClipRectLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, true);
canvas.clipRect(paint_bounds());
PaintChildren(frame);
void ClipRectLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, true);
context.canvas.clipRect(paint_bounds());
PaintChildren(context);
}
} // namespace flow
......@@ -18,7 +18,7 @@ class ClipRectLayer : public ContainerLayer {
protected:
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkRect clip_rect_;
......
......@@ -19,12 +19,11 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
set_paint_bounds(context->child_paint_bounds);
}
void ClipRRectLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(&paint_bounds(), nullptr);
canvas.clipRRect(clip_rrect_);
PaintChildren(frame);
void ClipRRectLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(&paint_bounds(), nullptr);
context.canvas.clipRRect(clip_rrect_);
PaintChildren(context);
}
} // namespace flow
......@@ -18,7 +18,7 @@ class ClipRRectLayer : public ContainerLayer {
protected:
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkRRect clip_rrect_;
......
......@@ -12,16 +12,15 @@ ColorFilterLayer::ColorFilterLayer() {
ColorFilterLayer::~ColorFilterLayer() {
}
void ColorFilterLayer::Paint(PaintContext::ScopedFrame& frame) {
void ColorFilterLayer::Paint(PaintContext& context) {
skia::RefPtr<SkColorFilter> color_filter =
skia::AdoptRef(SkColorFilter::CreateModeFilter(color_, transfer_mode_));
SkPaint paint;
paint.setColorFilter(color_filter.get());
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(&paint_bounds(), &paint);
PaintChildren(frame);
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(&paint_bounds(), &paint);
PaintChildren(context);
}
} // namespace flow
......@@ -21,7 +21,7 @@ class ColorFilterLayer : public ContainerLayer {
}
protected:
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkColor color_;
......
......@@ -33,9 +33,9 @@ void ContainerLayer::PrerollChildren(PrerollContext* context,
context->child_paint_bounds = child_paint_bounds;
}
void ContainerLayer::PaintChildren(PaintContext::ScopedFrame& frame) const {
void ContainerLayer::PaintChildren(PaintContext& context) const {
for (auto& layer : layers_)
layer->Paint(frame);
layer->Paint(context);
}
void ContainerLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update,
......
......@@ -20,7 +20,7 @@ class ContainerLayer : public Layer {
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void PrerollChildren(PrerollContext* context, const SkMatrix& matrix);
void PaintChildren(PaintContext::ScopedFrame& frame) const;
void PaintChildren(PaintContext& context) const;
void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
mojo::gfx::composition::Node* container) override;
......
......@@ -10,7 +10,8 @@
#include "base/logging.h"
#include "base/macros.h"
#include "flow/paint_context.h"
#include "flow/instrumentation.h"
#include "flow/raster_cache.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
......@@ -46,7 +47,14 @@ class Layer {
};
virtual void Preroll(PrerollContext* context, const SkMatrix& matrix);
virtual void Paint(PaintContext::ScopedFrame& frame) = 0;
struct PaintContext {
SkCanvas& canvas;
const Stopwatch& frame_time;
const Stopwatch& engine_time;
};
virtual void Paint(PaintContext& context) = 0;
virtual void UpdateScene(mojo::gfx::composition::SceneUpdate* update,
mojo::gfx::composition::Node* container);
......
......@@ -15,7 +15,7 @@ LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threshold_(0) {
LayerTree::~LayerTree() {
}
void LayerTree::Raster(PaintContext::ScopedFrame& frame) {
void LayerTree::Raster(CompositorContext::ScopedFrame& frame) {
{
TRACE_EVENT0("flutter", "LayerTree::Preroll");
Layer::PrerollContext context = {
......@@ -27,8 +27,13 @@ void LayerTree::Raster(PaintContext::ScopedFrame& frame) {
}
{
Layer::PaintContext context = {
frame.canvas(),
frame.context().frame_time(),
frame.context().engine_time(),
};
TRACE_EVENT0("flutter", "LayerTree::Paint");
root_layer_->Paint(frame);
root_layer_->Paint(context);
}
}
......
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "flow/compositor_context.h"
#include "flow/layers/layer.h"
#include "third_party/skia/include/core/SkSize.h"
......@@ -20,7 +21,7 @@ class LayerTree {
LayerTree();
~LayerTree();
void Raster(PaintContext::ScopedFrame& frame);
void Raster(CompositorContext::ScopedFrame& frame);
// TODO(abarth): Integrate scene updates with the rasterization pass so that
// we can draw on top of child scenes (and so that we can apply clips and
......
......@@ -12,14 +12,13 @@ OpacityLayer::OpacityLayer() {
OpacityLayer::~OpacityLayer() {
}
void OpacityLayer::Paint(PaintContext::ScopedFrame& frame) {
void OpacityLayer::Paint(PaintContext& context) {
SkPaint paint;
paint.setAlpha(alpha_);
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(&paint_bounds(), &paint);
PaintChildren(frame);
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(&paint_bounds(), &paint);
PaintChildren(context);
}
} // namespace flow
......@@ -17,7 +17,7 @@ class OpacityLayer : public ContainerLayer {
void set_alpha(int alpha) { alpha_ = alpha; }
protected:
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
int alpha_;
......
......@@ -64,7 +64,7 @@ PerformanceOverlayLayer::PerformanceOverlayLayer(uint64_t options)
}
void PerformanceOverlayLayer::Paint(PaintContext::ScopedFrame& frame) {
void PerformanceOverlayLayer::Paint(PaintContext& context) {
if (!options_)
return;
......@@ -72,15 +72,15 @@ void PerformanceOverlayLayer::Paint(PaintContext::ScopedFrame& frame) {
SkScalar y = paint_bounds().y();
SkScalar width = paint_bounds().width();
SkScalar height = paint_bounds().height() / 2;
SkAutoCanvasRestore save(&frame.canvas(), true);
SkAutoCanvasRestore save(&context.canvas, true);
VisualizeStopWatch(frame.canvas(), frame.context().frame_time(),
VisualizeStopWatch(context.canvas, context.frame_time,
x, y, width, height,
options_ & kVisualizeRasterizerStatistics,
options_ & kDisplayRasterizerStatistics,
"Rasterizer");
VisualizeStopWatch(frame.canvas(), frame.context().engine_time(),
VisualizeStopWatch(context.canvas, context.engine_time,
x, y + height, width, height,
options_ & kVisualizeEngineStatistics,
options_ & kDisplayEngineStatistics,
......
......@@ -19,7 +19,7 @@ class PerformanceOverlayLayer : public Layer {
public:
explicit PerformanceOverlayLayer(uint64_t options);
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
int options_;
......
......@@ -23,22 +23,23 @@ void PictureLayer::Preroll(PrerollContext* context,
const SkMatrix& matrix) {
image_ = context->raster_cache.GetPrerolledImage(
context->gr_context, picture_.get(), matrix);
context->child_paint_bounds = picture_->cullRect().makeOffset(offset_.x(), offset_.y());
context->child_paint_bounds =
picture_->cullRect().makeOffset(offset_.x(), offset_.y());
}
void PictureLayer::Paint(PaintContext::ScopedFrame& frame) {
void PictureLayer::Paint(PaintContext& context) {
DCHECK(picture_);
SkCanvas& canvas = frame.canvas();
if (image_) {
SkRect rect = picture_->cullRect().makeOffset(offset_.x(), offset_.y());
canvas.drawImageRect(image_.get(), rect, nullptr, SkCanvas::kFast_SrcRectConstraint);
context.canvas.drawImageRect(image_.get(), rect, nullptr,
SkCanvas::kFast_SrcRectConstraint);
if (kDebugCheckerboardRasterizedLayers)
DrawCheckerboard(&canvas, rect);
DrawCheckerboard(&context.canvas, rect);
} else {
SkAutoCanvasRestore save(&canvas, true);
canvas.translate(offset_.x(), offset_.y());
canvas.drawPicture(picture_.get());
SkAutoCanvasRestore save(&context.canvas, true);
context.canvas.translate(offset_.x(), offset_.y());
context.canvas.drawPicture(picture_.get());
}
}
......
......@@ -21,7 +21,7 @@ class PictureLayer : public Layer {
SkPicture* picture() const { return picture_.get(); }
void Preroll(PrerollContext* frame, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkPoint offset_;
......
......@@ -12,17 +12,17 @@ ShaderMaskLayer::ShaderMaskLayer() {
ShaderMaskLayer::~ShaderMaskLayer() {
}
void ShaderMaskLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, false);
canvas.saveLayer(&paint_bounds(), nullptr);
PaintChildren(frame);
void ShaderMaskLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, false);
context.canvas.saveLayer(&paint_bounds(), nullptr);
PaintChildren(context);
SkPaint paint;
paint.setXfermodeMode(transfer_mode_);
paint.setShader(shader_);
canvas.translate(mask_rect_.left(), mask_rect_.top());
canvas.drawRect(SkRect::MakeWH(mask_rect_.width(), mask_rect_.height()), paint);
context.canvas.translate(mask_rect_.left(), mask_rect_.top());
context.canvas.drawRect(
SkRect::MakeWH(mask_rect_.width(), mask_rect_.height()), paint);
}
} // namespace flow
......@@ -27,7 +27,7 @@ class ShaderMaskLayer : public ContainerLayer {
}
protected:
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
sk_sp<SkShader> shader_;
......
......@@ -19,11 +19,10 @@ void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
transform_.mapRect(&context->child_paint_bounds);
}
void TransformLayer::Paint(PaintContext::ScopedFrame& frame) {
SkCanvas& canvas = frame.canvas();
SkAutoCanvasRestore save(&canvas, true);
canvas.concat(transform_);
PaintChildren(frame);
void TransformLayer::Paint(PaintContext& context) {
SkAutoCanvasRestore save(&context.canvas, true);
context.canvas.concat(transform_);
PaintChildren(context);
}
} // namespace flow
......@@ -17,7 +17,7 @@ class TransformLayer : public ContainerLayer {
void set_transform(const SkMatrix& transform) { transform_ = transform; }
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext::ScopedFrame& frame) override;
void Paint(PaintContext& context) override;
private:
SkMatrix transform_;
......
......@@ -6,9 +6,9 @@
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "flow/paint_context.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkSurface.h"
#define ENABLE_RASTER_CACHE 1
......
......@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "dart/runtime/include/dart_api.h"
#include "dart/runtime/include/dart_native_api.h"
#include "flow/paint_context.h"
#include "flow/compositor_context.h"
#include "sky/engine/core/script/embedder_resources.h"
#include "sky/engine/tonic/dart_binding_macros.h"
#include "sky/engine/tonic/dart_invoke.h"
......@@ -128,8 +128,8 @@ void DiagnosticServer::SkiaPictureTask(Dart_Port port_id) {
recorder.beginRecording(SkRect::MakeWH(layer_tree->frame_size().width(),
layer_tree->frame_size().height()));
flow::PaintContext paint_context;
flow::PaintContext::ScopedFrame frame = paint_context.AcquireFrame(
flow::CompositorContext compositor_context;
flow::CompositorContext::ScopedFrame frame = compositor_context.AcquireFrame(
nullptr, *recorder.getRecordingCanvas(), false);
layer_tree->Raster(frame);
......
......@@ -85,15 +85,15 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
// There is no way for the compositor to know how long the layer tree
// construction took. Fortunately, the layer tree does. Grab that time
// for instrumentation.
paint_context_.engine_time().SetLapTime(layer_tree->construction_time());
compositor_context_.engine_time().SetLapTime(layer_tree->construction_time());
{
EnsureGLContext();
CHECK(context_->MakeCurrent(surface_.get()));
SkCanvas* canvas = ganesh_canvas_.GetCanvas(
surface_->GetBackingFrameBufferObject(), layer_tree->frame_size());
flow::PaintContext::ScopedFrame frame =
paint_context_.AcquireFrame(ganesh_canvas_.gr_context(), *canvas);
flow::CompositorContext::ScopedFrame frame =
compositor_context_.AcquireFrame(ganesh_canvas_.gr_context(), *canvas);
canvas->clear(SK_ColorBLACK);
layer_tree->Raster(frame);
canvas->flush();
......@@ -104,7 +104,7 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
bool frameExceededThreshold = false;
uint32_t thresholdInterval = layer_tree->rasterizer_tracing_threshold();
if (thresholdInterval != 0 &&
paint_context_.frame_time().LastLap().InMillisecondsF() >
compositor_context_.frame_time().LastLap().InMillisecondsF() >
thresholdInterval * kOneFrameDuration) {
// While rendering the last frame, if we exceeded the tracing threshold
// specified in the layer tree, we force a trace to disk.
......@@ -120,7 +120,7 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
recoder.beginRecording(SkRect::MakeWH(size.width(), size.height()));
{
auto frame = paint_context_.AcquireFrame(
auto frame = compositor_context_.AcquireFrame(
nullptr, *recoder.getRecordingCanvas(), false);
layer_tree->Raster(frame);
}
......@@ -137,7 +137,7 @@ void RasterizerDirect::Draw(uint64_t layer_tree_ptr,
void RasterizerDirect::OnOutputSurfaceDestroyed() {
if (context_) {
CHECK(context_->MakeCurrent(surface_.get()));
paint_context_.OnGrContextDestroyed();
compositor_context_.OnGrContextDestroyed();
ganesh_canvas_.SetGrGLInterface(nullptr);
context_ = nullptr;
}
......
......@@ -6,7 +6,7 @@
#define SKY_SHELL_GPU_DIRECT_RASTERIZER_H_
#include "base/memory/weak_ptr.h"
#include "flow/paint_context.h"
#include "flow/compositor_context.h"
#include "skia/ext/refptr.h"
#include "sky/shell/gpu/direct/ganesh_canvas.h"
#include "sky/shell/rasterizer.h"
......@@ -52,7 +52,7 @@ class RasterizerDirect : public Rasterizer {
skia::RefPtr<const GrGLInterface> gr_gl_interface_;
GaneshCanvas ganesh_canvas_;
flow::PaintContext paint_context_;
flow::CompositorContext compositor_context_;
mojo::Binding<rasterizer::Rasterizer> binding_;
......
......@@ -82,7 +82,7 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
return;
}
paint_context_.engine_time().SetLapTime(layer_tree->construction_time());
compositor_context_.engine_time().SetLapTime(layer_tree->construction_time());
std::unique_ptr<mojo::GLTexture> texture =
gl_state_->gl_texture_recycler.GetTexture(size);
......@@ -93,8 +93,8 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
mojo::skia::GaneshTextureSurface texture_surface(scope, std::move(texture));
SkCanvas* canvas = texture_surface.canvas();
flow::PaintContext::ScopedFrame frame =
paint_context_.AcquireFrame(scope.gr_context().get(), *canvas);
flow::CompositorContext::ScopedFrame frame =
compositor_context_.AcquireFrame(scope.gr_context().get(), *canvas);
canvas->clear(SK_ColorBLACK);
layer_tree->Raster(frame);
......
......@@ -6,7 +6,7 @@
#define SKY_SHELL_GPU_MOJO_RASTERIZER_MOJO_H_
#include "base/memory/weak_ptr.h"
#include "flow/paint_context.h"
#include "flow/compositor_context.h"
#include "mojo/gpu/gl_context.h"
#include "mojo/public/interfaces/application/application_connector.mojom.h"
#include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
......@@ -49,7 +49,7 @@ class RasterizerMojo : public Rasterizer {
mojo::Binding<rasterizer::Rasterizer> binding_;
mojo::gfx::composition::ScenePtr scene_;
std::unique_ptr<GLState> gl_state_;
flow::PaintContext paint_context_;
flow::CompositorContext compositor_context_;
std::unique_ptr<flow::LayerTree> last_layer_tree_;
base::WeakPtrFactory<RasterizerMojo> weak_factory_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册