Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1430)

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1342113002: add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698