Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: include/private/SkFunction.h

Issue 1258293004: Revert "Move the rest of src headers used by include to include/private." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/gl/SkGLContext.h ('k') | include/private/SkGpuFenceSync.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkFunction.h
diff --git a/include/private/SkFunction.h b/include/private/SkFunction.h
deleted file mode 100644
index 8e41cba929a08b4303247f5f1b51474ae2244d66..0000000000000000000000000000000000000000
--- a/include/private/SkFunction.h
+++ /dev/null
@@ -1,75 +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.
- */
-
-#ifndef SkFunction_DEFINED
-#define SkFunction_DEFINED
-
-// TODO: document, more pervasive move support in constructors, small-Fn optimization
-
-#include "SkTemplates.h"
-#include "SkTypes.h"
-
-template <typename> class SkFunction;
-
-template <typename R, typename... Args>
-class SkFunction<R(Args...)> {
-public:
- SkFunction() {}
-
- template <typename Fn>
- SkFunction(const Fn& fn) : fFunction(SkNEW_ARGS(LambdaImpl<Fn>, (fn))) {}
-
- SkFunction(R (*fn)(Args...)) : fFunction(SkNEW_ARGS(FnPtrImpl, (fn))) {}
-
- SkFunction(const SkFunction& other) { *this = other; }
- SkFunction& operator=(const SkFunction& other) {
- if (this != &other) {
- fFunction.reset(other.fFunction ? other.fFunction->clone() : nullptr);
- }
- return *this;
- }
-
- R operator()(Args... args) const {
- SkASSERT(fFunction.get());
- return fFunction->call(Forward(args)...);
- }
-
-private:
- // ~= std::forward. This moves its argument if possible, falling back to a copy if not.
- template <typename T> static T&& Forward(T& v) { return (T&&)v; }
-
- struct Interface {
- virtual ~Interface() {}
- virtual R call(Args...) const = 0;
- virtual Interface* clone() const = 0;
- };
-
- template <typename Fn>
- class LambdaImpl final : public Interface {
- public:
- LambdaImpl(const Fn& fn) : fFn(fn) {}
-
- R call(Args... args) const override { return fFn(Forward(args)...); }
- Interface* clone() const override { return SkNEW_ARGS(LambdaImpl<Fn>, (fFn)); }
- private:
- Fn fFn;
- };
-
- class FnPtrImpl final : public Interface {
- public:
- FnPtrImpl(R (*fn)(Args...)) : fFn(fn) {}
-
- R call(Args... args) const override { return fFn(Forward(args)...); }
- Interface* clone() const override { return SkNEW_ARGS(FnPtrImpl, (fFn)); }
- private:
- R (*fFn)(Args...);
- };
-
- SkAutoTDelete<Interface> fFunction;
-};
-
-#endif//SkFunction_DEFINED
« no previous file with comments | « include/gpu/gl/SkGLContext.h ('k') | include/private/SkGpuFenceSync.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698