skia2/include/private/GrSkSLFPFactoryCache.h
Mike Klein 408ef21c79 Revert "replace SkNVRefCnt with SkRefCnt"
This reverts commit 0fb1ee98cf.

Reason for revert: looks like this increased size by ~8K.

Original change's description:
> replace SkNVRefCnt with SkRefCnt
> 
> SkNVRefCnt trades a small amount of code size (vtable) and runtime
> (vptr) memory usage for a larger amount of code size (templating).  It
> was written back in a time when all we were really thinking about was
> runtime memory usage, so I'm curious to see where performance, code
> size, and memory usage all move if it's removed.
> 
> Looking at the types I've changed here, my guess is that performance and
> memory usage will be basically unchanged, and that code size will drop a
> bit.  Nothing else it's nicer to have only one ref-counting base class.
> 
> Change-Id: I7d56a2b9e2b9fb000ff97792159ea1ff4f5e6f13
> Reviewed-on: https://skia-review.googlesource.com/c/166203
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,bsalomon@google.com,mtklein@chromium.org

Change-Id: Ibcfcc4b523c466a535bea5ffa30d0fe2574c5bd7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/166360
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-10-30 15:23:06 +00:00

38 lines
1.1 KiB
C++

/*
* Copyright 2018 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrSkSLFPFactoryCache_DEFINED
#define GrSkSLFPFactoryCache_DEFINED
#include "SkRefCnt.h"
#include <vector>
class GrSkSLFPFactory;
// This is a cache used by GrSkSLFP to retain GrSkSLFPFactory instances, so we don't have to
// re-process the SkSL source code every time we create a GrSkSLFP instance.
// For thread safety, it is important that GrSkSLFP only interact with the cache from methods that
// are only called from within the rendering thread, like onCreateGLSLInstance and
// onGetGLSLProcessorKey.
class GrSkSLFPFactoryCache : public SkNVRefCnt<GrSkSLFPFactoryCache> {
public:
// Returns a factory by its numeric index, or null if no such factory exists. Indices are
// allocated by GrSkSLFP::NewIndex().
sk_sp<GrSkSLFPFactory> get(int index);
// Stores a new factory with the given index.
void set(int index, sk_sp<GrSkSLFPFactory> factory);
~GrSkSLFPFactoryCache();
private:
std::vector<GrSkSLFPFactory*> fFactories;
};
#endif