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

Unified Diff: src/image/SkSurface_Gpu.cpp

Issue 925343002: Swap render target instead of creating a new gpu device for surface copy-on-write (Closed) Base URL: https://skia.googlesource.com/skia.git@skimage-filters-02-use-sksurface-constructor-skgpudevice
Patch Set: Created 5 years, 10 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 | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Gpu.cpp
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index a1c31f31379ad022735e69dd5a64636f6149fca4..b94e4e30bd07f7a097a94a151a06b9558329476b 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -7,7 +7,6 @@
#include "SkSurface_Gpu.h"
-#include "GrGpuResourcePriv.h"
#include "SkCanvas.h"
#include "SkGpuDevice.h"
#include "SkImage_Base.h"
@@ -24,7 +23,7 @@ SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device)
}
SkSurface_Gpu::~SkSurface_Gpu() {
- SkSafeUnref(fDevice);
+ fDevice->unref();
}
SkCanvas* SkSurface_Gpu::onNewCanvas() {
@@ -59,8 +58,8 @@ void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint);
}
-// Create a new SkGpuDevice and, if necessary, copy the contents of the old
-// device into it. Note that this flushes the SkGpuDevice but
+// Create a new render target and, if necessary, copy the contents of the old
+// render target into it. Note that this flushes the SkGpuDevice but
// doesn't force an OpenGL flush.
void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
GrRenderTarget* rt = fDevice->accessRenderTarget();
@@ -69,22 +68,7 @@ void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
SkImage* image = this->getCachedImage(kNo_Budgeted);
SkASSERT(image);
if (rt->asTexture() == SkTextureImageGetTexture(image)) {
- GrRenderTarget* oldRT = this->fDevice->accessRenderTarget();
- SkSurface::Budgeted budgeted = oldRT->resourcePriv().isBudgeted() ? kYes_Budgeted :
- kNo_Budgeted;
- SkAutoTUnref<SkGpuDevice> newDevice(
- SkGpuDevice::Create(oldRT->getContext(), budgeted, fDevice->imageInfo(),
- oldRT->numSamples(), &this->props(), 0));
- if (kRetain_ContentChangeMode == mode && !oldRT->wasDestroyed() && newDevice) {
- oldRT->getContext()->copySurface(newDevice->accessRenderTarget(), oldRT);
- }
-
- SkASSERT(this->getCachedCanvas());
- SkASSERT(this->getCachedCanvas()->getDevice() == fDevice);
-
- this->getCachedCanvas()->setRootDevice(newDevice);
- SkRefCnt_SafeAssign(fDevice, newDevice.get());
-
+ this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode == mode);
SkTextureImageApplyBudgetedDecision(image);
} else if (kDiscard_ContentChangeMode == mode) {
this->SkSurface_Gpu::onDiscard();
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698