2016-05-04 19:47:41 +00:00
|
|
|
/*
|
|
|
|
* 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 GrTextureProxy_DEFINED
|
|
|
|
#define GrTextureProxy_DEFINED
|
|
|
|
|
|
|
|
#include "GrSurfaceProxy.h"
|
|
|
|
#include "GrTexture.h"
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
class GrCaps;
|
2017-03-04 13:12:46 +00:00
|
|
|
class GrResourceProvider;
|
2016-11-23 14:37:01 +00:00
|
|
|
class GrTextureOpList;
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
// This class delays the acquisition of textures until they are actually required
|
2016-11-04 15:59:10 +00:00
|
|
|
class GrTextureProxy : virtual public GrSurfaceProxy {
|
2016-05-04 19:47:41 +00:00
|
|
|
public:
|
|
|
|
GrTextureProxy* asTextureProxy() override { return this; }
|
|
|
|
const GrTextureProxy* asTextureProxy() const override { return this; }
|
|
|
|
|
|
|
|
// Actually instantiate the backing texture, if necessary
|
2017-05-17 17:49:59 +00:00
|
|
|
GrSurface* instantiate(GrResourceProvider*) override;
|
|
|
|
GrTexture* instantiateTexture(GrResourceProvider* resourceProvider) {
|
|
|
|
if (auto surf = this->instantiate(resourceProvider)) {
|
|
|
|
return surf->asTexture();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-03-15 17:02:45 +00:00
|
|
|
void setMipColorMode(SkDestinationSurfaceColorMode colorMode);
|
|
|
|
|
2017-05-08 17:41:35 +00:00
|
|
|
GrSamplerParams::FilterMode highestFilterMode() const;
|
|
|
|
|
2017-05-12 18:49:16 +00:00
|
|
|
GrSLType imageStorageType() const {
|
|
|
|
if (GrPixelConfigIsSint(this->config())) {
|
|
|
|
return kIImageStorage2D_GrSLType;
|
|
|
|
} else {
|
|
|
|
return kImageStorage2D_GrSLType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 17:49:59 +00:00
|
|
|
bool isMipMapped() const { return fIsMipMapped; }
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
protected:
|
2016-11-09 11:50:43 +00:00
|
|
|
friend class GrSurfaceProxy; // for ctors
|
|
|
|
|
2016-08-31 21:04:06 +00:00
|
|
|
// Deferred version
|
|
|
|
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
|
2017-02-28 16:26:32 +00:00
|
|
|
const void* srcData, size_t srcRowBytes, uint32_t flags);
|
2016-05-04 19:47:41 +00:00
|
|
|
// Wrapped version
|
2016-11-09 11:50:43 +00:00
|
|
|
GrTextureProxy(sk_sp<GrSurface>);
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-05-17 18:27:58 +00:00
|
|
|
SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; }
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
private:
|
2017-05-17 17:49:59 +00:00
|
|
|
bool fIsMipMapped;
|
2017-05-17 18:27:58 +00:00
|
|
|
SkDestinationSurfaceColorMode fMipColorMode;
|
2017-05-17 17:49:59 +00:00
|
|
|
|
|
|
|
size_t onUninstantiatedGpuMemorySize() const override;
|
2016-11-01 21:28:40 +00:00
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
// For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
|
2017-03-15 17:02:45 +00:00
|
|
|
// For deferred proxies that pointer will be filled in when we need to instantiate
|
2016-10-28 17:25:24 +00:00
|
|
|
// the deferred resource
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
typedef GrSurfaceProxy INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|