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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst
RowBytes, | 48 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst
RowBytes, |
49 int srcX, int srcY) const { | 49 int srcX, int srcY) const { |
50 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY); | 50 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY); |
51 if (!rec.trim(this->width(), this->height())) { | 51 if (!rec.trim(this->width(), this->height())) { |
52 return false; | 52 return false; |
53 } | 53 } |
54 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.
fX, rec.fY); | 54 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.
fX, rec.fY); |
55 } | 55 } |
56 | 56 |
57 void SkImage::preroll(GrContext* ctx) const { | 57 void SkImage::preroll(GrContext* ctx) const { |
58 as_IB(this)->onPreroll(ctx); | 58 // For now, and to maintain parity w/ previous pixelref behavior, we just fo
rce the image |
| 59 // to produce a cached raster-bitmap form, so that drawing to a raster canva
s should be fast. |
| 60 // |
| 61 SkBitmap bm; |
| 62 if (as_IB(this)->getROPixels(&bm)) { |
| 63 bm.lockPixels(); |
| 64 bm.unlockPixels(); |
| 65 } |
59 } | 66 } |
60 | 67 |
61 SkShader* SkImage::newShader(SkShader::TileMode tileX, | 68 SkShader* SkImage::newShader(SkShader::TileMode tileX, |
62 SkShader::TileMode tileY, | 69 SkShader::TileMode tileY, |
63 const SkMatrix* localMatrix) const { | 70 const SkMatrix* localMatrix) const { |
64 return as_IB(this)->onNewShader(tileX, tileY, localMatrix); | 71 return as_IB(this)->onNewShader(tileX, tileY, localMatrix); |
65 } | 72 } |
66 | 73 |
67 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { | 74 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { |
68 SkBitmap bm; | 75 SkBitmap bm; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 348 |
342 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { | 349 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { |
343 return nullptr; | 350 return nullptr; |
344 } | 351 } |
345 | 352 |
346 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { | 353 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { |
347 return nullptr; | 354 return nullptr; |
348 } | 355 } |
349 | 356 |
350 #endif | 357 #endif |
OLD | NEW |