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 |
52 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { | 59 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { |
53 if (SkBitmapCache::Find(this->uniqueID(), dst)) { | 60 if (SkBitmapCache::Find(this->uniqueID(), dst)) { |
54 SkASSERT(dst->getGenerationID() == this->uniqueID()); | 61 SkASSERT(dst->getGenerationID() == this->uniqueID()); |
55 SkASSERT(dst->isImmutable()); | 62 SkASSERT(dst->isImmutable()); |
56 SkASSERT(dst->getPixels()); | 63 SkASSERT(dst->getPixels()); |
57 return true; | 64 return true; |
58 } | 65 } |
59 | 66 |
60 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp
e; | 67 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp
e; |
61 if (!dst->tryAllocPixels(SkImageInfo::MakeN32(this->width(), this->height(),
at))) { | 68 if (!dst->tryAllocPixels(SkImageInfo::MakeN32(this->width(), this->height(),
at))) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (!dst) { | 280 if (!dst) { |
274 return nullptr; | 281 return nullptr; |
275 } | 282 } |
276 | 283 |
277 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 284 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
278 const SkIPoint dstP = SkIPoint::Make(0, 0); | 285 const SkIPoint dstP = SkIPoint::Make(0, 0); |
279 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 286 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
280 return dst; | 287 return dst; |
281 } | 288 } |
282 | 289 |
OLD | NEW |