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;
|
2016-05-04 19:47:41 +00:00
|
|
|
class GrTextureProvider;
|
|
|
|
|
|
|
|
// 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:
|
|
|
|
// TODO: need to refine ownership semantics of 'srcData' if we're in completely
|
|
|
|
// deferred mode
|
2016-11-04 15:59:10 +00:00
|
|
|
static sk_sp<GrTextureProxy> Make(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&,
|
2016-11-01 21:28:40 +00:00
|
|
|
SkBackingFit, SkBudgeted,
|
2016-05-04 19:47:41 +00:00
|
|
|
const void* srcData = nullptr, size_t rowBytes = 0);
|
|
|
|
static sk_sp<GrTextureProxy> Make(sk_sp<GrTexture>);
|
|
|
|
|
|
|
|
GrTextureProxy* asTextureProxy() override { return this; }
|
|
|
|
const GrTextureProxy* asTextureProxy() const override { return this; }
|
|
|
|
|
|
|
|
// Actually instantiate the backing texture, if necessary
|
2016-11-01 21:28:40 +00:00
|
|
|
GrTexture* instantiate(GrTextureProvider*);
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
protected:
|
2016-08-31 21:04:06 +00:00
|
|
|
// Deferred version
|
|
|
|
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
|
|
|
|
const void* srcData, size_t srcRowBytes);
|
2016-05-04 19:47:41 +00:00
|
|
|
// Wrapped version
|
|
|
|
GrTextureProxy(sk_sp<GrTexture> tex);
|
|
|
|
|
2016-11-04 15:59:10 +00:00
|
|
|
private:
|
2016-11-01 21:28:40 +00:00
|
|
|
size_t onGpuMemorySize() const override;
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
// For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
|
|
|
|
// For deferred proxies that pointer will be filled n when we need to instantiate
|
|
|
|
// the deferred resource
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
typedef GrSurfaceProxy INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|