skia2/include/private/GrTextureProxy.h
Robert Phillips 9113edfff8 Add GrRenderTargetContext instantiate & asTextureProxy
This CL also centralizes the instantiation code in GrSurfaceProxy and adds a test.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4494

Change-Id: I0081d9a216dc0af293179f23bcb88acf6a822324
Reviewed-on: https://skia-review.googlesource.com/4494
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2016-11-07 20:28:13 +00:00

51 lines
1.6 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 GrTextureProxy_DEFINED
#define GrTextureProxy_DEFINED
#include "GrSurfaceProxy.h"
#include "GrTexture.h"
class GrCaps;
class GrTextureProvider;
// This class delays the acquisition of textures until they are actually required
class GrTextureProxy : virtual public GrSurfaceProxy {
public:
// TODO: need to refine ownership semantics of 'srcData' if we're in completely
// deferred mode
static sk_sp<GrTextureProxy> Make(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&,
SkBackingFit, SkBudgeted,
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
GrTexture* instantiate(GrTextureProvider*);
protected:
// Deferred version
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
const void* srcData, size_t srcRowBytes);
// Wrapped version
GrTextureProxy(sk_sp<GrTexture> tex);
private:
size_t onGpuMemorySize() const override;
// 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
typedef GrSurfaceProxy INHERITED;
};
#endif