| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
| 9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, | 81 void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
| 82 const SkPaint* paint) { | 82 const SkPaint* paint) { |
| 83 canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint); | 83 canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Copy the contents of the SkGpuDevice into a new texture and give that | 86 // Copy the contents of the SkGpuDevice into a new texture and give that |
| 87 // texture to the SkImage. Note that this flushes the SkGpuDevice but | 87 // texture to the SkImage. Note that this flushes the SkGpuDevice but |
| 88 // doesn't force an OpenGL flush. | 88 // doesn't force an OpenGL flush. |
| 89 void SkSurface_Gpu::onCopyOnWrite(SkImage* image, SkCanvas* canvas) { | 89 void SkSurface_Gpu::onCopyOnWrite(SkImage* image, SkCanvas*) { |
| 90 GrRenderTarget* rt = (GrRenderTarget*) fDevice->accessRenderTarget(); | 90 GrRenderTarget* rt = (GrRenderTarget*) fDevice->accessRenderTarget(); |
| 91 | 91 |
| 92 // are we sharing our render target with the image? | 92 // are we sharing our render target with the image? |
| 93 if (rt->asTexture() == SkTextureImageGetTexture(image)) { | 93 if (rt->asTexture() == SkTextureImageGetTexture(image)) { |
| 94 GrTextureDesc desc; | 94 GrTextureDesc desc; |
| 95 // copyTexture requires a render target as the destination | 95 // copyTexture requires a render target as the destination |
| 96 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 96 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 97 desc.fWidth = fDevice->width(); | 97 desc.fWidth = fDevice->width(); |
| 98 desc.fHeight = fDevice->height(); | 98 desc.fHeight = fDevice->height(); |
| 99 desc.fConfig = SkBitmapConfig2GrPixelConfig(fDevice->config()); | 99 desc.fConfig = SkBitmapConfig2GrPixelConfig(fDevice->config()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); | 137 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); |
| 138 desc.fSampleCnt = sampleCount; | 138 desc.fSampleCnt = sampleCount; |
| 139 | 139 |
| 140 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); | 140 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); |
| 141 if (NULL == tex) { | 141 if (NULL == tex) { |
| 142 return NULL; | 142 return NULL; |
| 143 } | 143 } |
| 144 | 144 |
| 145 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); | 145 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); |
| 146 } | 146 } |
| OLD | NEW |