skia2/include/gpu/GrBufferAccess.h
csmartdalton 1897cfd7a6 Abandon offset support with texel buffers
We don't seem to require nonzero offsets for texel buffers at this
point in time, and requiring this feature greatly reduces the number
of desktop clients that can use texel buffers. If we find a use for
offsets later we can always add it back as a separate feature.

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

Review-Url: https://codereview.chromium.org/2036953002
2016-06-03 08:50:54 -07:00

56 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 GrBufferAccess_DEFINED
#define GrBufferAccess_DEFINED
#include "GrBuffer.h"
#include "GrGpuResourceRef.h"
/**
* Used to represent a texel buffer that will be read in a GrProcessor. It holds a GrBuffer along
* with an associated offset and texel config.
*/
class GrBufferAccess : public SkNoncopyable {
public:
/**
* Must be initialized before adding to a GrProcessor's buffer access list.
*/
void reset(GrPixelConfig texelConfig, GrBuffer* buffer,
GrShaderFlags visibility = kFragment_GrShaderFlag) {
fTexelConfig = texelConfig;
fBuffer.set(SkRef(buffer), kRead_GrIOType);
fVisibility = visibility;
}
bool operator==(const GrBufferAccess& that) const {
return fTexelConfig == that.fTexelConfig &&
this->buffer() == that.buffer() &&
fVisibility == that.fVisibility;
}
bool operator!=(const GrBufferAccess& that) const { return !(*this == that); }
GrPixelConfig texelConfig() const { return fTexelConfig; }
GrBuffer* buffer() const { return fBuffer.get(); }
GrShaderFlags visibility() const { return fVisibility; }
/**
* For internal use by GrProcessor.
*/
const GrGpuResourceRef* getProgramBuffer() const { return &fBuffer;}
private:
GrPixelConfig fTexelConfig;
GrTGpuResourceRef<GrBuffer> fBuffer;
GrShaderFlags fVisibility;
typedef SkNoncopyable INHERITED;
};
#endif