blob: 09ae1e244f8d3ea6359298d55d3164529753f3a4 [file] [log] [blame]
* Copyright 2015 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef SkBigPicture_DEFINED
#define SkBigPicture_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkPicture.h"
#include "include/core/SkRect.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkOnce.h"
#include "include/private/base/SkTemplates.h"
class SkBBoxHierarchy;
class SkMatrix;
class SkRecord;
// An implementation of SkPicture supporting an arbitrary number of drawing commands.
// This is called "big" because there used to be a "mini" that only supported a subset of the
// calls as an optimization.
class SkBigPicture final : public SkPicture {
// An array of refcounted const SkPicture pointers.
class SnapshotArray : ::SkNoncopyable {
SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(count) {}
~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref(); } }
const SkPicture* const* begin() const { return fPics; }
int count() const { return fCount; }
skia_private::AutoTMalloc<const SkPicture*> fPics;
int fCount;
SkBigPicture(const SkRect& cull,
size_t approxBytesUsedBySubPictures);
// SkPicture overrides
void playback(SkCanvas*, AbortCallback*) const override;
SkRect cullRect() const override;
int approximateOpCount(bool nested) const override;
size_t approximateBytesUsed() const override;
const SkBigPicture* asSkBigPicture() const override { return this; }
// Used by GrLayerHoister
void partialPlayback(SkCanvas*,
int start,
int stop,
const SkM44& initialCTM) const;
// Used by GrRecordReplaceDraw
const SkBBoxHierarchy* bbh() const { return fBBH.get(); }
const SkRecord* record() const { return fRecord.get(); }
int drawableCount() const;
SkPicture const* const* drawablePicts() const;
const SkRect fCullRect;
const size_t fApproxBytesUsedBySubPictures;
sk_sp<const SkRecord> fRecord;
std::unique_ptr<const SnapshotArray> fDrawablePicts;
sk_sp<const SkBBoxHierarchy> fBBH;