| Index: src/image/SkSurface_Gpu.cpp
|
| diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
|
| index b94e4e30bd07f7a097a94a151a06b9558329476b..ea6e0899eebabd2e87c934babb500e7b3ac11d11 100644
|
| --- a/src/image/SkSurface_Gpu.cpp
|
| +++ b/src/image/SkSurface_Gpu.cpp
|
| @@ -20,12 +20,23 @@
|
| SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device)
|
| : INHERITED(device->width(), device->height(), &device->surfaceProps())
|
| , fDevice(SkRef(device)) {
|
| + fDevice->setSurface(this);
|
| + fGenerationID = 0;
|
| }
|
|
|
| SkSurface_Gpu::~SkSurface_Gpu() {
|
| + // In case the device outlives this instance, make sure device does not try to access this.
|
| + fDevice->setSurface(NULL);
|
| fDevice->unref();
|
| }
|
|
|
| +uint32_t SkSurface_Gpu::generationID() {
|
| + if (0 == fGenerationID) {
|
| + fGenerationID = this->newGenerationID();
|
| + }
|
| + return fGenerationID;
|
| +}
|
| +
|
| SkCanvas* SkSurface_Gpu::onNewCanvas() {
|
| SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
|
| // When we think this works...
|
| @@ -35,8 +46,7 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
|
| }
|
|
|
| SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
|
| - GrRenderTarget* rt = fDevice->accessRenderTarget();
|
| - int sampleCount = rt->numSamples();
|
| + int sampleCount = fDevice->getBackendSampleCnt();
|
| // TODO: Make caller specify this (change virtual signature of onNewSurface).
|
| static const Budgeted kBudgeted = kNo_Budgeted;
|
| return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampleCount,
|
| @@ -44,39 +54,11 @@ SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
|
| }
|
|
|
| SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) {
|
| - const int sampleCount = fDevice->accessRenderTarget()->numSamples();
|
| - SkImage* image = SkNewImageFromBitmapTexture(fDevice->accessBitmap(false), sampleCount,
|
| - budgeted);
|
| - if (image) {
|
| - as_IB(image)->initWithProps(this->props());
|
| - }
|
| - return image;
|
| -}
|
| -
|
| -void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
|
| - const SkPaint* paint) {
|
| - canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint);
|
| -}
|
| -
|
| -// 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();
|
| - // are we sharing our render target with the image? Note this call should never create a new
|
| - // image because onCopyOnWrite is only called when there is a cached image.
|
| - SkImage* image = this->getCachedImage(kNo_Budgeted);
|
| - SkASSERT(image);
|
| - if (rt->asTexture() == SkTextureImageGetTexture(image)) {
|
| - this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode == mode);
|
| - SkTextureImageApplyBudgetedDecision(image);
|
| - } else if (kDiscard_ContentChangeMode == mode) {
|
| - this->SkSurface_Gpu::onDiscard();
|
| - }
|
| + return fDevice->newImageSnapshot(&this->props(), budgeted);
|
| }
|
|
|
| -void SkSurface_Gpu::onDiscard() {
|
| - fDevice->accessRenderTarget()->discard();
|
| +bool SkSurface_Gpu::isBackendBudgeted() const {
|
| + return fDevice->isBackendBudgeted();
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|