afb7870f75
The Viewer slide list stores the values from repeated calls to Slide::getName().c_str() in a large list for filtering purposes. However, the temporary SkString was being destroyed before the list was complete. This luckily happened to work because SkString's refcounting behavior kept the internal buffer alive past the lifetime of the temporary SkString object, but it's not intended to work. Returning a const-ref to the internal SkString is more efficient, and gives us long-lived SkStrings to work with. Change-Id: I958148ba46332f9ec576ac60d0a9b916284c4761 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306256 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
46 lines
1.1 KiB
C++
46 lines
1.1 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.
|
|
*/
|
|
|
|
#ifndef Slide_DEFINED
|
|
#define Slide_DEFINED
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/core/SkSize.h"
|
|
#include "include/core/SkString.h"
|
|
#include "tools/sk_app/Window.h"
|
|
|
|
class SkCanvas;
|
|
class SkMetaData;
|
|
|
|
class Slide : public SkRefCnt {
|
|
public:
|
|
virtual SkISize getDimensions() const = 0;
|
|
|
|
virtual void gpuTeardown() { }
|
|
virtual void draw(SkCanvas* canvas) = 0;
|
|
virtual bool animate(double nanos) { return false; }
|
|
virtual void load(SkScalar winWidth, SkScalar winHeight) {}
|
|
virtual void resize(SkScalar winWidth, SkScalar winHeight) {}
|
|
virtual void unload() {}
|
|
|
|
virtual bool onChar(SkUnichar c) { return false; }
|
|
virtual bool onMouse(SkScalar x, SkScalar y, skui::InputState state,
|
|
skui::ModifierKey modifiers) { return false; }
|
|
|
|
virtual bool onGetControls(SkMetaData*) { return false; }
|
|
virtual void onSetControls(const SkMetaData&) {}
|
|
|
|
const SkString& getName() { return fName; }
|
|
|
|
|
|
protected:
|
|
SkString fName;
|
|
};
|
|
|
|
|
|
#endif
|