#include "GrBlurUtils.h"
#include "GrContext.h"
#include "SkDraw.h"
-#include "GrDrawContext.h"
#include "GrGpu.h"
#include "GrGpuResourcePriv.h"
#include "GrImageIDTextureAdjuster.h"
SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
const SkSurfaceProps* props, unsigned flags)
: INHERITED(SkSurfacePropsCopyOrDefault(props))
-{
- fContext = SkRef(rt->getContext());
+ , fContext(SkRef(rt->getContext()))
+ , fRenderTarget(SkRef(rt)) {
fNeedClear = SkToBool(flags & kNeedClear_Flag);
fOpaque = SkToBool(flags & kIsOpaque_Flag);
- fRenderTarget = SkRef(rt);
-
SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
SkPixelRef* pr = new SkGrPixelRef(info, rt);
return texture->asRenderTarget();
}
-SkGpuDevice::~SkGpuDevice() {
- fRenderTarget->unref();
- fContext->unref();
-}
-
///////////////////////////////////////////////////////////////////////////////
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
SkASSERT(fRenderTarget != newRT);
- fRenderTarget->unref();
- fRenderTarget = newRT.detach();
+ fRenderTarget.reset(newRT.detach());
#ifdef SK_DEBUG
SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlphaType :
#include "SkPicture.h"
#include "SkRegion.h"
#include "SkSurface.h"
+#include "GrDrawContext.h"
#include "GrContext.h"
#include "GrSurfacePriv.h"
static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInfo&,
int sampleCount, const SkSurfaceProps*, InitContents);
- virtual ~SkGpuDevice();
+ ~SkGpuDevice() override {}
SkGpuDevice* cloneDevice(const SkSurfaceProps& props) {
SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), kPossible_TileUsage,
const SkMatrix*, const SkPaint*) override;
private:
- GrContext* fContext;
+ // We want these unreffed in DrawContext, RenderTarget, GrContext order.
+ SkAutoTUnref<GrContext> fContext;
+ SkAutoTUnref<GrRenderTarget> fRenderTarget;
+ SkAutoTUnref<GrDrawContext> fDrawContext;
+
SkAutoTUnref<const SkClipStack> fClipStack;
SkIPoint fClipOrigin;
- GrClip fClip;
- SkAutoTUnref<GrDrawContext> fDrawContext;
- GrRenderTarget* fRenderTarget;
+ GrClip fClip;;
// remove when our clients don't rely on accessBitmap()
SkBitmap fLegacyBitmap;
bool fNeedClear;