diff options
Diffstat (limited to 'src/core/SkDeferredDisplayListRecorder.cpp')
-rw-r--r-- | src/core/SkDeferredDisplayListRecorder.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp new file mode 100644 index 0000000000..c47a79a77d --- /dev/null +++ b/src/core/SkDeferredDisplayListRecorder.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkDeferredDisplayListRecorder.h" + +#include "SkCanvas.h" // TODO: remove +#include "SkDeferredDisplayList.h" +#include "SkSurface.h" // TODO: remove + +SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder( + const SkSurfaceCharacterization& characterization) + : fCharacterization(characterization) { +} + +SkCanvas* SkDeferredDisplayListRecorder::getCanvas() { + if (!fSurface) { + SkImageInfo ii = SkImageInfo::MakeN32(fCharacterization.width(), + fCharacterization.height(), + kOpaque_SkAlphaType); + + // Use raster right now to allow threading + fSurface = SkSurface::MakeRaster(ii, nullptr); + } + + return fSurface->getCanvas(); +} + +std::unique_ptr<SkDeferredDisplayList> SkDeferredDisplayListRecorder::detach() { + sk_sp<SkImage> img = fSurface->makeImageSnapshot(); + fSurface.reset(); + + // TODO: need to wrap the opLists associated with the deferred draws + // in the SkDeferredDisplayList. + return std::unique_ptr<SkDeferredDisplayList>( + new SkDeferredDisplayList(fCharacterization, std::move(img))); +} + +// Placeholder. Ultimately, the SkSurface_Gpu will pass the wrapped opLists to its +// renderTargetContext. +void SkDeferredDisplayList::draw(SkSurface* surface) { + surface->getCanvas()->drawImage(fImage.get(), 0, 0); +} |