skia2/include/utils/SkPictureUtils.h
mtklein c92c129ff8 Sketch splitting SkPicture into an interface and SkBigPicture.
Adds small pictures for drawRect(), drawTextBlob(), and drawPath().
These cover about 89% of draw calls from Blink SKPs,
and about 25% of draw calls from our GMs.

SkPicture handles:
  - serialization and deserialization
  - unique IDs

Everything else is left to the subclasses:
  - playback(), cullRect()
  - hasBitmap(), hasText(), suitableForGPU(), etc.
  - LayerInfo / AccelData if applicable.

The time to record a 1-op picture improves a good chunk
(2 mallocs to 1), and the time to record a 0-op picture
greatly improves (2 mallocs to none):

    picture_overhead_draw:   450ns -> 350ns
    picture_overhead_nodraw: 300ns -> 90ns

BUG=skia:

Review URL: https://codereview.chromium.org/1112523006
2015-05-07 13:41:07 -07:00

29 lines
731 B
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPictureUtils_DEFINED
#define SkPictureUtils_DEFINED
#include "SkPicture.h"
// TODO: remove this file?
class SK_API SkPictureUtils {
public:
/**
* How many bytes are allocated to hold the SkPicture.
* Includes operations, parameters, bounding data, deletion listeners;
* includes nested SkPictures, but does not include large objects that
* SkRecord holds a reference to (e.g. paths, or pixels backing bitmaps).
*/
static size_t ApproximateBytesUsed(const SkPicture* pict) {
return pict->approximateBytesUsed();
}
};
#endif