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_Base.h" | 8 #include "SkImage_Base.h" |
9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 canvas->drawBitmap(fBitmap, x, y, paint); | 62 canvas->drawBitmap(fBitmap, x, y, paint); |
63 } | 63 } |
64 | 64 |
65 void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect&
dst, | 65 void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect&
dst, |
66 const SkPaint* paint) const { | 66 const SkPaint* paint) const { |
67 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); | 67 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); |
68 } | 68 } |
69 | 69 |
70 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro
ps& props) const { | 70 SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfacePro
ps& props) const { |
71 GrContext* ctx = this->getTexture()->getContext(); | 71 GrContext* ctx = this->getTexture()->getContext(); |
72 return SkSurface::NewRenderTarget(ctx, info, fSampleCountForNewSurfaces, &pr
ops); | 72 // TODO: Change signature of onNewSurface to take a budgeted param. |
| 73 static const SkSurface::Budgeted kBudgeted = SkSurface::kNo_Budgeted; |
| 74 return SkSurface::NewRenderTarget(ctx, kBudgeted, info, fSampleCountForNewSu
rfaces, &props); |
73 } | 75 } |
74 | 76 |
75 GrTexture* SkImage_Gpu::onGetTexture() const { | 77 GrTexture* SkImage_Gpu::onGetTexture() const { |
76 return fBitmap.getTexture(); | 78 return fBitmap.getTexture(); |
77 } | 79 } |
78 | 80 |
79 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { | 81 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const { |
80 return fBitmap.copyTo(dst, kN32_SkColorType); | 82 return fBitmap.copyTo(dst, kN32_SkColorType); |
81 } | 83 } |
82 | 84 |
83 bool SkImage_Gpu::isOpaque() const { | 85 bool SkImage_Gpu::isOpaque() const { |
84 return fBitmap.isOpaque(); | 86 return fBitmap.isOpaque(); |
85 } | 87 } |
86 | 88 |
87 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
88 | 90 |
89 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCountForN
ewSurfaces) { | 91 SkImage* SkNewImageFromBitmapTexture(const SkBitmap& bitmap, int sampleCountForN
ewSurfaces) { |
90 if (NULL == bitmap.getTexture()) { | 92 if (NULL == bitmap.getTexture()) { |
91 return NULL; | 93 return NULL; |
92 } | 94 } |
93 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces)); | 95 return SkNEW_ARGS(SkImage_Gpu, (bitmap, sampleCountForNewSurfaces)); |
94 } | 96 } |
95 | 97 |
96 GrTexture* SkTextureImageGetTexture(SkImage* image) { | 98 GrTexture* SkTextureImageGetTexture(SkImage* image) { |
97 return ((SkImage_Gpu*)image)->getTexture(); | 99 return ((SkImage_Gpu*)image)->getTexture(); |
98 } | 100 } |
99 | 101 |
OLD | NEW |