| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #if 0 | 87 #if 0 |
| 88 // The render texture we have created (to perform the copy) isn't fully | 88 // The render texture we have created (to perform the copy) isn't fully |
| 89 // functional (since it doesn't have a stencil buffer). Release it here | 89 // functional (since it doesn't have a stencil buffer). Release it here |
| 90 // so the caller doesn't try to render to it. | 90 // so the caller doesn't try to render to it. |
| 91 // TODO: we can undo this release when dynamic stencil buffer attach/ | 91 // TODO: we can undo this release when dynamic stencil buffer attach/ |
| 92 // detach has been implemented | 92 // detach has been implemented |
| 93 dst->releaseRenderTarget(); | 93 dst->releaseRenderTarget(); |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst)); | 96 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (dst)); |
| 97 GrSafeUnref(dst); | 97 SkSafeUnref(dst); |
| 98 return pixelRef; | 98 return pixelRef; |
| 99 } | 99 } |
| 100 | 100 |
| 101 /////////////////////////////////////////////////////////////////////////////// | 101 /////////////////////////////////////////////////////////////////////////////// |
| 102 | 102 |
| 103 SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) { | 103 SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) { |
| 104 // TODO: figure out if this is responsible for Chrome canvas errors | 104 // TODO: figure out if this is responsible for Chrome canvas errors |
| 105 #if 0 | 105 #if 0 |
| 106 // The GrTexture has a ref to the GrRenderTarget but not vice versa. | 106 // The GrTexture has a ref to the GrRenderTarget but not vice versa. |
| 107 // If the GrTexture exists take a ref to that (rather than the render | 107 // If the GrTexture exists take a ref to that (rather than the render |
| 108 // target) | 108 // target) |
| 109 fSurface = surface->asTexture(); | 109 fSurface = surface->asTexture(); |
| 110 #else | 110 #else |
| 111 fSurface = NULL; | 111 fSurface = NULL; |
| 112 #endif | 112 #endif |
| 113 if (NULL == fSurface) { | 113 if (NULL == fSurface) { |
| 114 fSurface = surface; | 114 fSurface = surface; |
| 115 } | 115 } |
| 116 fUnlock = transferCacheLock; | 116 fUnlock = transferCacheLock; |
| 117 GrSafeRef(surface); | 117 SkSafeRef(surface); |
| 118 } | 118 } |
| 119 | 119 |
| 120 SkGrPixelRef::~SkGrPixelRef() { | 120 SkGrPixelRef::~SkGrPixelRef() { |
| 121 if (fUnlock) { | 121 if (fUnlock) { |
| 122 GrContext* context = fSurface->getContext(); | 122 GrContext* context = fSurface->getContext(); |
| 123 GrTexture* texture = fSurface->asTexture(); | 123 GrTexture* texture = fSurface->asTexture(); |
| 124 if (NULL != context && NULL != texture) { | 124 if (NULL != context && NULL != texture) { |
| 125 context->unlockScratchTexture(texture); | 125 context->unlockScratchTexture(texture); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 GrSafeUnref(fSurface); | 128 SkSafeUnref(fSurface); |
| 129 } | 129 } |
| 130 | 130 |
| 131 GrTexture* SkGrPixelRef::getTexture() { | 131 GrTexture* SkGrPixelRef::getTexture() { |
| 132 if (NULL != fSurface) { | 132 if (NULL != fSurface) { |
| 133 return fSurface->asTexture(); | 133 return fSurface->asTexture(); |
| 134 } | 134 } |
| 135 return NULL; | 135 return NULL; |
| 136 } | 136 } |
| 137 | 137 |
| 138 SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* su
bset) { | 138 SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* su
bset) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (!dst->allocPixels()) { | 170 if (!dst->allocPixels()) { |
| 171 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); | 171 SkDebugf("SkGrPixelRef::onReadPixels failed to alloc bitmap for result!\
n"); |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 SkAutoLockPixels al(*dst); | 174 SkAutoLockPixels al(*dst); |
| 175 void* buffer = dst->getPixels(); | 175 void* buffer = dst->getPixels(); |
| 176 return fSurface->readPixels(left, top, width, height, | 176 return fSurface->readPixels(left, top, width, height, |
| 177 kSkia8888_GrPixelConfig, | 177 kSkia8888_GrPixelConfig, |
| 178 buffer, dst->rowBytes()); | 178 buffer, dst->rowBytes()); |
| 179 } | 179 } |
| OLD | NEW |