| 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
| 9 #include "SkImage_Gpu.h" | 9 #include "SkImage_Gpu.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; | 42 const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; |
| 43 return SkSurface::NewRenderTarget(ctx, budgeted, info, fSampleCountForNewSur
faces, &props); | 43 return SkSurface::NewRenderTarget(ctx, budgeted, info, fSampleCountForNewSur
faces, &props); |
| 44 } | 44 } |
| 45 | 45 |
| 46 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { | 46 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { |
| 47 if (as_IB(image)->getTexture()) { | 47 if (as_IB(image)->getTexture()) { |
| 48 ((SkImage_Gpu*)image)->applyBudgetDecision(); | 48 ((SkImage_Gpu*)image)->applyBudgetDecision(); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode
tileY, | |
| 53 const SkMatrix* localMatrix) const { | |
| 54 SkBitmap bm; | |
| 55 GrWrapTextureInBitmap(fTexture, this->width(), this->height(), this->isOpaqu
e(), &bm); | |
| 56 return SkShader::CreateBitmapShader(bm, tileX, tileY, localMatrix); | |
| 57 } | |
| 58 | |
| 59 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { | 52 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { |
| 60 if (SkBitmapCache::Find(this->uniqueID(), dst)) { | 53 if (SkBitmapCache::Find(this->uniqueID(), dst)) { |
| 61 SkASSERT(dst->getGenerationID() == this->uniqueID()); | 54 SkASSERT(dst->getGenerationID() == this->uniqueID()); |
| 62 SkASSERT(dst->isImmutable()); | 55 SkASSERT(dst->isImmutable()); |
| 63 SkASSERT(dst->getPixels()); | 56 SkASSERT(dst->getPixels()); |
| 64 return true; | 57 return true; |
| 65 } | 58 } |
| 66 | 59 |
| 67 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp
e; | 60 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp
e; |
| 68 if (!dst->tryAllocPixels(SkImageInfo::MakeN32(this->width(), this->height(),
at))) { | 61 if (!dst->tryAllocPixels(SkImageInfo::MakeN32(this->width(), this->height(),
at))) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 if (!dst) { | 273 if (!dst) { |
| 281 return nullptr; | 274 return nullptr; |
| 282 } | 275 } |
| 283 | 276 |
| 284 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 277 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 285 const SkIPoint dstP = SkIPoint::Make(0, 0); | 278 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 286 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 279 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
| 287 return dst; | 280 return dst; |
| 288 } | 281 } |
| 289 | 282 |
| OLD | NEW |