| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 srcRect = SkIRect::MakeWH(texture->width(), texture->height()); | 69 srcRect = SkIRect::MakeWH(texture->width(), texture->height()); |
| 70 } else { | 70 } else { |
| 71 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*
subset)); | 71 SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*
subset)); |
| 72 // Create a new texture that is the size of subset. | 72 // Create a new texture that is the size of subset. |
| 73 desc.fWidth = subset->width(); | 73 desc.fWidth = subset->width(); |
| 74 desc.fHeight = subset->height(); | 74 desc.fHeight = subset->height(); |
| 75 srcRect = *subset; | 75 srcRect = *subset; |
| 76 } | 76 } |
| 77 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 77 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 78 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT); | 78 desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT); |
| 79 desc.fIsMipMapped = false; |
| 79 | 80 |
| 80 GrTexture* dst = context->textureProvider()->createTexture(desc, false, null
ptr, 0); | 81 GrTexture* dst = context->textureProvider()->createTexture(desc, false, null
ptr, 0); |
| 81 if (nullptr == dst) { | 82 if (nullptr == dst) { |
| 82 return nullptr; | 83 return nullptr; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // Blink is relying on the above copy being sent to GL immediately in the ca
se when the source | 86 // Blink is relying on the above copy being sent to GL immediately in the ca
se when the source |
| 86 // is a WebGL canvas backing store. We could have a TODO to remove this flus
h flag, but we have | 87 // is a WebGL canvas backing store. We could have a TODO to remove this flus
h flag, but we have |
| 87 // a larger TODO to remove SkGrPixelRef entirely. | 88 // a larger TODO to remove SkGrPixelRef entirely. |
| 88 context->copySurface(dst->asRenderTarget(), texture, srcRect, SkIPoint::Make
(0,0), | 89 context->copySurface(dst->asRenderTarget(), texture, srcRect, SkIPoint::Make
(0,0), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 116 SkSafeUnref(fSurface); | 117 SkSafeUnref(fSurface); |
| 117 } | 118 } |
| 118 | 119 |
| 119 GrTexture* SkGrPixelRef::getTexture() { | 120 GrTexture* SkGrPixelRef::getTexture() { |
| 120 if (fSurface) { | 121 if (fSurface) { |
| 121 return fSurface->asTexture(); | 122 return fSurface->asTexture(); |
| 122 } | 123 } |
| 123 return nullptr; | 124 return nullptr; |
| 124 } | 125 } |
| 125 | 126 |
| 126 void SkGrPixelRef::onNotifyPixelsChanged() { | |
| 127 GrTexture* texture = this->getTexture(); | |
| 128 if (texture) { | |
| 129 texture->texturePriv().dirtyMipMaps(true); | |
| 130 } | |
| 131 } | |
| 132 | |
| 133 SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT, | 127 SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT, |
| 134 const SkIRect* subset) { | 128 const SkIRect* subset) { |
| 135 if (nullptr == fSurface) { | 129 if (nullptr == fSurface) { |
| 136 return nullptr; | 130 return nullptr; |
| 137 } | 131 } |
| 138 | 132 |
| 139 // Note that when copying a render-target-backed pixel ref, we | 133 // Note that when copying a render-target-backed pixel ref, we |
| 140 // return a texture-backed pixel ref instead. This is because | 134 // return a texture-backed pixel ref instead. This is because |
| 141 // render-target pixel refs are usually created in conjunction with | 135 // render-target pixel refs are usually created in conjunction with |
| 142 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live | 136 // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 cachedBitmap.setImmutable(); | 188 cachedBitmap.setImmutable(); |
| 195 //Add to the cache | 189 //Add to the cache |
| 196 SkBitmapCache::Add(this, bounds, cachedBitmap); | 190 SkBitmapCache::Add(this, bounds, cachedBitmap); |
| 197 | 191 |
| 198 dst->swap(cachedBitmap); | 192 dst->swap(cachedBitmap); |
| 199 } | 193 } |
| 200 | 194 |
| 201 return true; | 195 return true; |
| 202 | 196 |
| 203 } | 197 } |
| OLD | NEW |