class GrDrawTarget;
class GrFragmentProcessor;
class GrGpu;
-class GrGpuTraceMarker;
class GrIndexBuffer;
class GrLayerCache;
class GrOvalRenderer;
// Called by tests that draw directly to the context via GrDrawTarget
void getTestTarget(GrTestTarget*);
- void addGpuTraceMarker(const GrGpuTraceMarker* marker);
- void removeGpuTraceMarker(const GrGpuTraceMarker* marker);
-
GrPathRenderer* getPathRenderer(
const GrDrawTarget* target,
const GrPipelineBuilder*,
#include "GrSurfacePriv.h"
#include "GrTextBlobCache.h"
#include "GrTexturePriv.h"
-#include "GrTraceMarker.h"
#include "GrTracing.h"
#include "GrVertices.h"
#include "SkDashPathPriv.h"
fResourceCache->setLimits(maxTextures, maxTextureBytes);
}
-//////////////////////////////////////////////////////////////////////////////
-
-void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
- fGpu->addGpuTraceMarker(marker);
-}
-
-void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
- fGpu->removeGpuTraceMarker(marker);
-}
-
: fGpu(SkRef(gpu))
, fCaps(SkRef(gpu->caps()))
, fResourceProvider(resourceProvider)
- , fGpuTraceMarkerCount(0)
, fFlushing(false) {
}
}
fFlushing = true;
- this->getGpu()->saveActiveTraceMarkers();
-
this->onFlush();
- this->getGpu()->restoreActiveTraceMarkers();
-
fFlushing = false;
this->reset();
}
}
}
-typedef GrTraceMarkerSet::Iter TMIter;
-void GrDrawTarget::saveActiveTraceMarkers() {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(0 == fStoredTraceMarkers.count());
- fStoredTraceMarkers.addSet(fActiveTraceMarkers);
- for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
- this->removeGpuTraceMarker(&(*iter));
- }
- }
-}
-
-void GrDrawTarget::restoreActiveTraceMarkers() {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(0 == fActiveTraceMarkers.count());
- for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
- this->addGpuTraceMarker(&(*iter));
- }
- for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) {
- this->fStoredTraceMarkers.remove(*iter);
- }
- }
-}
-
-void GrDrawTarget::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(fGpuTraceMarkerCount >= 0);
- this->fActiveTraceMarkers.add(*marker);
- ++fGpuTraceMarkerCount;
- }
-}
-
-void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(fGpuTraceMarkerCount >= 1);
- this->fActiveTraceMarkers.remove(*marker);
- --fGpuTraceMarkerCount;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
void GrDrawTarget::copySurface(GrSurface* dst,
#include "GrPathRendering.h"
#include "GrPipelineBuilder.h"
#include "GrPipeline.h"
-#include "GrTraceMarker.h"
#include "GrVertexBuffer.h"
#include "GrXferProcessor.h"
/** Discards the contents render target. */
void discard(GrRenderTarget*);
- /**
- * Called at start and end of gpu trace marking
- * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start
- * and end of a code block respectively
- */
- void addGpuTraceMarker(const GrGpuTraceMarker* marker);
- void removeGpuTraceMarker(const GrGpuTraceMarker* marker);
-
- /**
- * Takes the current active set of markers and stores them for later use. Any current marker
- * in the active set is removed from the active set and the targets remove function is called.
- * These functions do not work as a stack so you cannot call save a second time before calling
- * restore. Also, it is assumed that when restore is called the current active set of markers
- * is empty. When the stored markers are added back into the active set, the targets add marker
- * is called.
- */
- void saveActiveTraceMarkers();
- void restoreActiveTraceMarkers();
-
/**
* Copies a pixel rectangle from one surface to another. This call may finalize
* reserved vertex/index data (as though a draw call was made). The src pixels
};
protected:
-
GrGpu* getGpu() { return fGpu; }
const GrGpu* getGpu() const { return fGpu; }
- const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; }
-
// Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
// but couldn't be made. Otherwise, returns true. This method needs to be protected because it
// needs to be accessed by GLPrograms to setup a correct drawstate
GrGpu* fGpu;
const GrCaps* fCaps;
GrResourceProvider* fResourceProvider;
- // To keep track that we always have at least as many debug marker adds as removes
- int fGpuTraceMarkerCount;
- GrTraceMarkerSet fActiveTraceMarkers;
- GrTraceMarkerSet fStoredTraceMarkers;
bool fFlushing;
typedef SkRefCnt INHERITED;
GrGpu::GrGpu(GrContext* context)
: fResetTimestamp(kExpiredTimestamp+1)
, fResetBits(kAll_GrBackendState)
- , fGpuTraceMarkerCount(0)
, fContext(context) {
}
this->onResolveRenderTarget(target);
}
-typedef GrTraceMarkerSet::Iter TMIter;
-void GrGpu::saveActiveTraceMarkers() {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(0 == fStoredTraceMarkers.count());
- fStoredTraceMarkers.addSet(fActiveTraceMarkers);
- for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
- this->removeGpuTraceMarker(&(*iter));
- }
- }
-}
-
-void GrGpu::restoreActiveTraceMarkers() {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(0 == fActiveTraceMarkers.count());
- for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
- this->addGpuTraceMarker(&(*iter));
- }
- for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) {
- this->fStoredTraceMarkers.remove(*iter);
- }
- }
-}
-
-void GrGpu::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(fGpuTraceMarkerCount >= 0);
- this->fActiveTraceMarkers.add(*marker);
- this->didAddGpuTraceMarker();
- ++fGpuTraceMarkerCount;
- }
-}
-
-void GrGpu::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
- if (this->caps()->gpuTracingSupport()) {
- SkASSERT(fGpuTraceMarkerCount >= 1);
- this->fActiveTraceMarkers.remove(*marker);
- this->didRemoveGpuTraceMarker();
- --fGpuTraceMarkerCount;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
#include "GrPipelineBuilder.h"
#include "GrProgramDesc.h"
#include "GrStencil.h"
-#include "GrTraceMarker.h"
#include "GrXferProcessor.h"
#include "SkPath.h"
Stats* stats() { return &fStats; }
- /**
- * Called at start and end of gpu trace marking
- * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start
- * and end of a code block respectively
- */
- void addGpuTraceMarker(const GrGpuTraceMarker* marker);
- void removeGpuTraceMarker(const GrGpuTraceMarker* marker);
-
- /**
- * Takes the current active set of markers and stores them for later use. Any current marker
- * in the active set is removed from the active set and the targets remove function is called.
- * These functions do not work as a stack so you cannot call save a second time before calling
- * restore. Also, it is assumed that when restore is called the current active set of markers
- * is empty. When the stored markers are added back into the active set, the targets add marker
- * is called.
- */
- void saveActiveTraceMarkers();
- void restoreActiveTraceMarkers();
-
// creation and deletion of raw texture for testing
// only to be used in GPU-specific tests
virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
*preference = SkTMax(*preference, elevation);
}
- const GrTraceMarkerSet& getActiveTraceMarkers() const { return fActiveTraceMarkers; }
-
Stats fStats;
SkAutoTDelete<GrPathRendering> fPathRendering;
// Subclass must initialize this in its constructor.
// clears target's entire stencil buffer to 0
virtual void clearStencil(GrRenderTarget* target) = 0;
- virtual void didAddGpuTraceMarker() = 0;
- virtual void didRemoveGpuTraceMarker() = 0;
-
void resetContext() {
this->onResetContext(fResetBits);
fResetBits = 0;
ResetTimestamp fResetTimestamp;
uint32_t fResetBits;
- // To keep track that we always have at least as many debug marker adds as removes
- int fGpuTraceMarkerCount;
- GrTraceMarkerSet fActiveTraceMarkers;
- GrTraceMarkerSet fStoredTraceMarkers;
// The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
GrContext* fContext;
void clearStencil(GrRenderTarget* target) override {}
- void didAddGpuTraceMarker() override {}
-
- void didRemoveGpuTraceMarker() override {}
-
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
GrPixelConfig config) const override {
return 0;
*/
class GrGpuTraceMarkerGenerator : public ::SkNoncopyable {
public:
- GrGpuTraceMarkerGenerator(GrDrawTarget* target) : fTarget(target) {}
+ GrGpuTraceMarkerGenerator(GrDrawTarget* target) {}
~GrGpuTraceMarkerGenerator() {
if (fTraceMarker.isValid()) {
- fTarget->removeGpuTraceMarker(fTraceMarker.get());
+ // TODO remove trace marker
}
}
void initialize(const char* marker_str, int* marker_counter) {
- GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
- fTarget->addGpuTraceMarker(traceMarker);
+ // GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
+ // TODO add trace marker
}
private:
- GrDrawTarget* fTarget;
SkTLazy<GrGpuTraceMarker> fTraceMarker;
};
class GrGpuTraceMarkerGeneratorContext : public ::SkNoncopyable {
public:
- GrGpuTraceMarkerGeneratorContext(GrContext* context) : fContext(context) {}
+ GrGpuTraceMarkerGeneratorContext(GrContext* context) {}
~GrGpuTraceMarkerGeneratorContext() {
if (fTraceMarker.isValid()) {
- fContext->removeGpuTraceMarker(fTraceMarker.get());
+ // TODO remove trace marker
}
}
void initialize(const char* marker_str, int* marker_counter) {
- GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
- fContext->addGpuTraceMarker(traceMarker);
+ // GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
+ // TODO add trace marker
}
private:
- GrContext* fContext;
SkTLazy<GrGpuTraceMarker> fTraceMarker;
};
}
}
-void GrGLGpu::didAddGpuTraceMarker() {
- if (this->caps()->gpuTracingSupport()) {
- const GrTraceMarkerSet& markerArray = this->getActiveTraceMarkers();
- SkString markerString = markerArray.toStringLast();
-#if GR_FORCE_GPU_TRACE_DEBUGGING
- SkDebugf("%s\n", markerString.c_str());
-#else
- GL_CALL(PushGroupMarker(0, markerString.c_str()));
-#endif
- }
-}
-
-void GrGLGpu::didRemoveGpuTraceMarker() {
- if (this->caps()->gpuTracingSupport()) {
-#if GR_FORCE_GPU_TRACE_DEBUGGING
- SkDebugf("Pop trace marker.\n");
-#else
- GL_CALL(PopGroupMarker());
-#endif
- }
-}
-
GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, int h,
GrPixelConfig config) const {
GrGLuint texID;
void clearStencil(GrRenderTarget*) override;
- // GrDrawTarget overrides
- void didAddGpuTraceMarker() override;
- void didRemoveGpuTraceMarker() override;
-
// binds texture unit in GL
void setTextureUnit(int unitIdx);