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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapProcShader.h" | 10 #include "SkBitmapProcShader.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkColorTable.h" | 12 #include "SkColorTable.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkImagePriv.h" | 14 #include "SkImagePriv.h" |
15 #include "SkPixelRef.h" | 15 #include "SkPixelRef.h" |
16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
17 | 17 |
18 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
19 #include "GrContext.h" | 19 #include "GrContext.h" |
| 20 #include "GrImageIDTextureAdjuster.h" |
20 #include "SkGr.h" | 21 #include "SkGr.h" |
21 #include "SkGrPriv.h" | 22 #include "SkGrPriv.h" |
22 #endif | 23 #endif |
23 | 24 |
24 // fixes https://bug.skia.org/5096 | 25 // fixes https://bug.skia.org/5096 |
25 static bool is_not_subset(const SkBitmap& bm) { | 26 static bool is_not_subset(const SkBitmap& bm) { |
26 SkASSERT(bm.pixelRef()); | 27 SkASSERT(bm.pixelRef()); |
27 SkISize dim = bm.pixelRef()->info().dimensions(); | 28 SkISize dim = bm.pixelRef()->info().dimensions(); |
28 SkASSERT(dim != bm.dimensions() || bm.pixelRefOrigin().isZero()); | 29 SkASSERT(dim != bm.dimensions() || bm.pixelRefOrigin().isZero()); |
29 return dim == bm.dimensions(); | 30 return dim == bm.dimensions(); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return pr->refEncodedData(); | 188 return pr->refEncodedData(); |
188 } | 189 } |
189 return nullptr; | 190 return nullptr; |
190 } | 191 } |
191 | 192 |
192 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const { | 193 bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const { |
193 *dst = fBitmap; | 194 *dst = fBitmap; |
194 return true; | 195 return true; |
195 } | 196 } |
196 | 197 |
197 #include "GrImageIDTextureAdjuster.h" | |
198 | |
199 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams, | 198 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams, |
200 SkSourceGammaTreatment gammaTreatment) c
onst { | 199 SkSourceGammaTreatment gammaTreatment) c
onst { |
201 #if SK_SUPPORT_GPU | 200 #if SK_SUPPORT_GPU |
202 if (!ctx) { | 201 if (!ctx) { |
203 return nullptr; | 202 return nullptr; |
204 } | 203 } |
205 | 204 |
206 uint32_t uniqueID; | 205 uint32_t uniqueID; |
207 sk_sp<GrTexture> tex = this->refPinnedTexture(&uniqueID); | 206 sk_sp<GrTexture> tex = this->refPinnedTexture(&uniqueID); |
208 if (tex) { | 207 if (tex) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // pixelref since the caller might call setImmutable() themselves | 370 // pixelref since the caller might call setImmutable() themselves |
372 // (thus changing our state). | 371 // (thus changing our state). |
373 if (fBitmap.isImmutable()) { | 372 if (fBitmap.isImmutable()) { |
374 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 373 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
375 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 374 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
376 return true; | 375 return true; |
377 } | 376 } |
378 } | 377 } |
379 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 378 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
380 } | 379 } |
OLD | NEW |