Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 506413004: Simplify SkGpuDevice construction (Closed) Base URL: https://skia.googlesource.com/skia.git@cons
Patch Set: Also remove init from header Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b3d154b7e21d23cd5f579d24c35c3a4a1ede58e2..b751c46c4a35778496058fcce8f49fbd39b3cbac 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -134,44 +134,27 @@ public:
SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, unsigned flags) {
SkASSERT(NULL != surface);
- if (NULL == surface->asRenderTarget() || NULL == surface->getContext()) {
+ if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) {
return NULL;
}
- if (surface->asTexture()) {
- return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asTexture(), flags));
- } else {
- return SkNEW_ARGS(SkGpuDevice, (surface->getContext(), surface->asRenderTarget(), flags));
- }
-}
-
-SkGpuDevice::SkGpuDevice(GrContext* context, GrTexture* texture, unsigned flags) {
- this->initFromRenderTarget(context, texture->asRenderTarget(), flags);
+ return SkNEW_ARGS(SkGpuDevice, (surface, flags));
}
-SkGpuDevice::SkGpuDevice(GrContext* context, GrRenderTarget* renderTarget, unsigned flags) {
- this->initFromRenderTarget(context, renderTarget, flags);
-}
+SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) {
-void SkGpuDevice::initFromRenderTarget(GrContext* context,
- GrRenderTarget* renderTarget,
- unsigned flags) {
fDrawProcs = NULL;
- fContext = context;
- fContext->ref();
+ fContext = SkRef(surface->getContext());
- fRenderTarget = NULL;
fNeedClear = flags & kNeedClear_Flag;
- SkASSERT(NULL != renderTarget);
- fRenderTarget = renderTarget;
- fRenderTarget->ref();
+ fRenderTarget = SkRef(surface->asRenderTarget());
// Hold onto to the texture in the pixel ref (if there is one) because the texture holds a ref
// on the RT but not vice-versa.
// TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without
// busting chrome (for a currently unknown reason).
- GrSurface* surface = fRenderTarget->asTexture();
+ surface = fRenderTarget->asTexture();
if (NULL == surface) {
surface = fRenderTarget;
}
@@ -217,7 +200,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
return NULL;
}
- return SkNEW_ARGS(SkGpuDevice, (context, texture.get()));
+ return SkNEW_ARGS(SkGpuDevice, (texture.get()));
}
SkGpuDevice::~SkGpuDevice() {
@@ -238,19 +221,12 @@ SkGpuDevice::~SkGpuDevice() {
fContext->setClip(NULL);
}
- SkSafeUnref(fRenderTarget);
+ fRenderTarget->unref();
fContext->unref();
}
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::makeRenderTargetCurrent() {
- DO_DEFERRED_CLEAR();
- fContext->setRenderTarget(fRenderTarget);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int x, int y) {
DO_DEFERRED_CLEAR();
« no previous file with comments | « include/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698