a008b0fa8b
To my surprise, this even works with homegrown smart pointers (such as SkTLazy). https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html Find and remove redundant calls to smart pointer’s .get() method. Examples: ptr.get()->Foo() ==> ptr->Foo() *ptr.get() ==> *ptr *ptr->get() ==> **ptr if (ptr.get() == nullptr) ... => if (ptr == nullptr) ... Change-Id: I8ff541e0229656b4d8e875c8053a7e6138302547 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310976 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "tools/viewer/SKPSlide.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkStream.h"
|
|
#include "src/core/SkOSFile.h"
|
|
|
|
SKPSlide::SKPSlide(const SkString& name, const SkString& path)
|
|
: SKPSlide(name, SkStream::MakeFromFile(path.c_str())) {
|
|
}
|
|
|
|
SKPSlide::SKPSlide(const SkString& name, std::unique_ptr<SkStream> stream)
|
|
: fStream(std::move(stream)) {
|
|
fName = name;
|
|
}
|
|
|
|
SKPSlide::~SKPSlide() {}
|
|
|
|
void SKPSlide::draw(SkCanvas* canvas) {
|
|
if (fPic) {
|
|
bool isOffset = SkToBool(fCullRect.left() | fCullRect.top());
|
|
if (isOffset) {
|
|
canvas->save();
|
|
canvas->translate(SkIntToScalar(-fCullRect.left()), SkIntToScalar(-fCullRect.top()));
|
|
}
|
|
|
|
canvas->drawPicture(fPic.get());
|
|
|
|
if (isOffset) {
|
|
canvas->restore();
|
|
}
|
|
}
|
|
}
|
|
|
|
void SKPSlide::load(SkScalar, SkScalar) {
|
|
if (!fStream) {
|
|
SkDebugf("No skp stream for slide %s.\n", fName.c_str());
|
|
return;
|
|
}
|
|
fStream->rewind();
|
|
fPic = SkPicture::MakeFromStream(fStream.get());
|
|
if (!fPic) {
|
|
SkDebugf("Could parse SkPicture from skp stream for slide %s.\n", fName.c_str());
|
|
return;
|
|
}
|
|
fCullRect = fPic->cullRect().roundOut();
|
|
}
|
|
|
|
void SKPSlide::unload() {
|
|
fPic.reset(nullptr);
|
|
}
|