skia2/include/gpu/GrTextureContext.h
Robert Phillips 2c86249465 Move read/write-Pixels up to GrSurfaceContext
This still needs to be propagated out in several ways:
  replace more instances of GrSurface::read/write-Pixels
  add colorSpace to more instances of the TextureContext

but it establishes a beach-head and is exciting enough as is.

Change-Id: If86035aa0245e70b54541e83722b3c75bc5ade13
Reviewed-on: https://skia-review.googlesource.com/7172
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2017-01-18 16:22:59 +00:00

64 lines
1.9 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 GrTextureContext_DEFINED
#define GrTextureContext_DEFINED
#include "GrSurfaceContext.h"
#include "../private/GrTextureProxy.h"
class GrContext;
class GrDrawingManager;
class GrSurface;
class GrTextureOpList;
class GrTextureProxy;
struct SkIPoint;
struct SkIRect;
/**
* A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
* GrTextures and not GrRenderTargets.
*/
class SK_API GrTextureContext : public GrSurfaceContext {
public:
~GrTextureContext() override;
GrSurfaceProxy* asDeferredSurface() override { return fTextureProxy.get(); }
GrTextureProxy* asDeferredTexture() override { return fTextureProxy.get(); }
GrRenderTargetProxy* asDeferredRenderTarget() override;
protected:
GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
GrDrawingManager* drawingManager() { return fDrawingManager; }
SkDEBUGCODE(void validate() const;)
private:
friend class GrDrawingManager; // for ctor
bool onCopy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override;
bool onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
size_t dstRowBytes, int x, int y) override;
bool onWritePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
size_t srcRowBytes, int x, int y) override;
GrTextureOpList* getOpList();
GrDrawingManager* fDrawingManager;
sk_sp<GrTextureProxy> fTextureProxy;
// In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
// it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
GrTextureOpList* fOpList;
typedef GrSurfaceContext INHERITED;
};
#endif