aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMiniRecorder.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2015-05-18 14:53:43 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-18 14:53:43 -0700
commit72743b165424efc4ef6f6614add9033ea1ef31db (patch)
tree26ebea2ec4df12ec4d94cb3089b4f3d82a032322 /src/core/SkMiniRecorder.cpp
parent4f2dba625dd858ea3591974d793ef18c10c2ca67 (diff)
Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (patchset #25 id:480001 of https://codereview.chromium.org/1112523006/)
Reason for revert: win_chromium_compile_dbg_ng FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma/gomacc "E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\third_party\skia\src\core\skia.SkBitmapHeap.obj.rsp /c ..\..\third_party\skia\src\core\SkBitmapHeap.cpp /Foobj\third_party\skia\src\core\skia.SkBitmapHeap.obj /Fdobj\skia\skia.cc.pdb e:\b\build\slave\win\build\src\third_party\skia\include\core\skpicture.h(176) : error C2487: 'CURRENT_PICTURE_VERSION' : member of dll interface class may not be declared with dll interface Original issue's description: > 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: > > Committed: https://skia.googlesource.com/skia/+/c92c129ff85b05a714bd1bf921c02d5e14651f8b > > Latest blink_linux_rel: > > http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/61248 > > Committed: https://skia.googlesource.com/skia/+/15877b6eae33a9282458bdb904a6d00440eca0ec TBR=reed@google.com,robertphillips@google.com,fmalita@chromium.org,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1130283004
Diffstat (limited to 'src/core/SkMiniRecorder.cpp')
-rw-r--r--src/core/SkMiniRecorder.cpp103
1 files changed, 0 insertions, 103 deletions
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
deleted file mode 100644
index 55dd56add7..0000000000
--- a/src/core/SkMiniRecorder.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkCanvas.h"
-#include "SkLazyPtr.h"
-#include "SkMiniRecorder.h"
-#include "SkPicture.h"
-#include "SkPictureCommon.h"
-#include "SkRecordDraw.h"
-#include "SkTextBlob.h"
-
-using namespace SkRecords;
-
-class SkEmptyPicture final : public SkPicture {
-public:
- void playback(SkCanvas*, AbortCallback*) const override { }
-
- size_t approximateBytesUsed() const override { return sizeof(*this); }
- int approximateOpCount() const override { return 0; }
- SkRect cullRect() const override { return SkRect::MakeEmpty(); }
- bool hasText() const override { return false; }
- int numSlowPaths() const override { return 0; }
- bool willPlayBackBitmaps() const override { return false; }
-};
-SK_DECLARE_STATIC_LAZY_PTR(SkEmptyPicture, gEmptyPicture);
-
-template <typename T>
-class SkMiniPicture final : public SkPicture {
-public:
- SkMiniPicture(SkRect cull, T* op) : fCull(cull) {
- memcpy(&fOp, op, sizeof(fOp)); // We take ownership of op's guts.
- }
-
- void playback(SkCanvas* c, AbortCallback*) const override {
- SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp);
- }
-
- size_t approximateBytesUsed() const override { return sizeof(*this); }
- int approximateOpCount() const override { return 1; }
- SkRect cullRect() const override { return fCull; }
- bool hasText() const override { return SkTextHunter()(fOp); }
- bool willPlayBackBitmaps() const override { return SkBitmapHunter()(fOp); }
- int numSlowPaths() const override {
- SkPathCounter counter;
- counter(fOp);
- return counter.fNumSlowPathsAndDashEffects;
- }
-
-private:
- SkRect fCull;
- T fOp;
-};
-
-
-SkMiniRecorder::SkMiniRecorder() : fState(State::kEmpty) {}
-SkMiniRecorder::~SkMiniRecorder() {
- if (fState != State::kEmpty) {
- // We have internal state pending.
- // Detaching then deleting a picture is an easy way to clean up.
- SkDELETE(this->detachAsPicture(SkRect::MakeEmpty()));
- }
- SkASSERT(fState == State::kEmpty);
-}
-
-#define TRY_TO_STORE(Type, ...) \
- if (fState != State::kEmpty) { return false; } \
- fState = State::k##Type; \
- new (fBuffer.get()) Type(__VA_ARGS__); \
- return true
-
-bool SkMiniRecorder::drawRect(const SkRect& rect, const SkPaint& paint) {
- TRY_TO_STORE(DrawRect, paint, rect);
-}
-
-bool SkMiniRecorder::drawPath(const SkPath& path, const SkPaint& paint) {
- TRY_TO_STORE(DrawPath, paint, path);
-}
-
-bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, const SkPaint& p) {
- TRY_TO_STORE(DrawTextBlob, p, b, x, y);
-}
-#undef TRY_TO_STORE
-
-#define CASE(Type) \
- case State::k##Type: \
- fState = State::kEmpty; \
- return SkNEW_ARGS(SkMiniPicture<Type>, (cull, reinterpret_cast<Type*>(fBuffer.get())))
-
-SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
- switch (fState) {
- case State::kEmpty: return SkRef(gEmptyPicture.get());
- CASE(DrawPath);
- CASE(DrawRect);
- CASE(DrawTextBlob);
- }
- SkASSERT(false);
- return NULL;
-}
-#undef CASE