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

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

Issue 1127993004: Revert of Revert of Revert of Make drawImage a virtual on SkDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 "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
29 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const { 38 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro ps& props) const {
30 GrContext* ctx = this->getTexture()->getContext(); 39 GrContext* ctx = this->getTexture()->getContext();
31 // TODO: Change signature of onNewSurface to take a budgeted param. 40 // TODO: Change signature of onNewSurface to take a budgeted param.
32 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; 41 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted;
33 return SkSurface::NewRenderTarget(ctx, kBudgeted, info, fSampleCountForNewSu rfaces, &props); 42 return SkSurface::NewRenderTarget(ctx, kBudgeted, info, fSampleCountForNewSu rfaces, &props);
34 } 43 }
35 44
36 GrTexture* SkImage_Gpu::onGetTexture() const { 45 GrTexture* SkImage_Gpu::onGetTexture() const {
37 return fBitmap.getTexture(); 46 return fBitmap.getTexture();
38 } 47 }
(...skipping 16 matching lines...) Expand all
55 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces, budgeted) ); 64 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces, budgeted) );
56 } 65 }
57 66
58 GrTexture* SkTextureImageGetTexture(SkImage* image) { 67 GrTexture* SkTextureImageGetTexture(SkImage* image) {
59 return ((SkImage_Gpu*)image)->getTexture(); 68 return ((SkImage_Gpu*)image)->getTexture();
60 } 69 }
61 70
62 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { 71 extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
63 ((SkImage_Gpu*)image)->applyBudgetDecision(); 72 ((SkImage_Gpu*)image)->applyBudgetDecision();
64 } 73 }
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