flutter_flutter/engine/core/painting/PictureRecorder.cpp
Ian Fischer 1799eacef5 Decouple Canvas from DisplayList and map Picture and PictureRecorder more directly to their Skia counterparts.
Also changes the framework dart code to use the
refactored APIs and fixes the various examples and
tests.

R=abarth@chromium.org, ianh@chromium.org

Review URL: https://codereview.chromium.org/1190123003.
2015-06-24 10:21:45 -07:00

43 lines
1.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.
#include "sky/engine/core/painting/Canvas.h"
#include "sky/engine/core/painting/Picture.h"
#include "sky/engine/core/painting/PictureRecorder.h"
namespace blink {
PictureRecorder::PictureRecorder()
: m_pictureRecorder(adoptPtr(new SkPictureRecorder()))
{
}
PictureRecorder::~PictureRecorder()
{
}
bool PictureRecorder::isRecording() {
return m_canvas && m_canvas->isRecording();
}
SkCanvas* PictureRecorder::beginRecording(double width, double height)
{
return m_pictureRecorder->beginRecording(width, height);
}
PassRefPtr<Picture> PictureRecorder::endRecording()
{
if (!isRecording())
return nullptr;
RefPtr<Picture> picture = Picture::create(
adoptRef(m_pictureRecorder->endRecording()));
m_canvas->clearSkCanvas();
m_canvas = nullptr;
return picture.release();
}
void PictureRecorder::set_canvas(PassRefPtr<Canvas> canvas) { m_canvas = canvas; }
} // namespace blink