| 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 "SkImage_Gpu.h" | 8 #include "SkImage_Gpu.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 | 11 |
| 12 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCountForNewSurfaces, | 12 SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap, int sampleCountForNewSurfaces, |
| 13 SkSurface::Budgeted budgeted) | 13 SkSurface::Budgeted budgeted) |
| 14 : INHERITED(bitmap.width(), bitmap.height(), NULL) | 14 : INHERITED(bitmap.width(), bitmap.height(), NULL) |
| 15 , fBitmap(bitmap) | 15 , fBitmap(bitmap) |
| 16 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces) | 16 , fSampleCountForNewSurfaces(sampleCountForNewSurfaces) |
| 17 , fBudgeted(budgeted) | 17 , fBudgeted(budgeted) |
| 18 { | 18 { |
| 19 SkASSERT(fBitmap.getTexture()); | 19 SkASSERT(fBitmap.getTexture()); |
| 20 } | 20 } |
| 21 | 21 |
| 22 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, | 22 SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, |
| 23 SkShader::TileMode tileY, | 23 SkShader::TileMode tileY, |
| 24 const SkMatrix* localMatrix) const | 24 const SkMatrix* localMatrix) const |
| 25 { | 25 { |
| 26 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); | 26 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint
* paint) const { | |
| 30 canvas->drawBitmap(fBitmap, x, y, paint); | |
| 31 } | |
| 32 | |
| 33 void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect&
dst, | |
| 34 const SkPaint* paint) const { | |
| 35 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); | |
| 36 } | |
| 37 | |
| 38 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro
ps& props) const { | 29 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro
ps& props) const { |
| 39 GrContext* ctx = this->getTexture()->getContext(); | 30 GrContext* ctx = this->getTexture()->getContext(); |
| 40 // TODO: Change signature of onNewSurface to take a budgeted param. | 31 // TODO: Change signature of onNewSurface to take a budgeted param. |
| 41 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; | 32 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; |
| 42 return SkSurface::NewRenderTarget(ctx, kBudgeted, info, fSampleCountForNewSu
rfaces, &props); | 33 return SkSurface::NewRenderTarget(ctx, kBudgeted, info, fSampleCountForNewSu
rfaces, &props); |
| 43 } | 34 } |
| 44 | 35 |
| 45 GrTexture* SkImage_Gpu::onGetTexture() const { | 36 GrTexture* SkImage_Gpu::onGetTexture() const { |
| 46 return fBitmap.getTexture(); | 37 return fBitmap.getTexture(); |
| 47 } | 38 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 64 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces, budgeted)
); | 55 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces, budgeted)
); |
| 65 } | 56 } |
| 66 | 57 |
| 67 GrTexture* SkTextureImageGetTexture(SkImage* image) { | 58 GrTexture* SkTextureImageGetTexture(SkImage* image) { |
| 68 return ((SkImage_Gpu*)image)->getTexture(); | 59 return ((SkImage_Gpu*)image)->getTexture(); |
| 69 } | 60 } |
| 70 | 61 |
| 71 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { | 62 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { |
| 72 ((SkImage_Gpu*)image)->applyBudgetDecision(); | 63 ((SkImage_Gpu*)image)->applyBudgetDecision(); |
| 73 } | 64 } |
| OLD | NEW |