| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrImageIDTextureAdjuster.h" | 8 #include "GrImageIDTextureAdjuster.h" |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 #include "GrGpuResourcePriv.h" | 11 #include "GrGpuResourcePriv.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkGrPriv.h" | 13 #include "SkGrPriv.h" |
| 14 #include "SkImage_Base.h" | 14 #include "SkImage_Base.h" |
| 15 #include "SkImageCacherator.h" | 15 #include "SkImageCacherator.h" |
| 16 #include "SkPixelRef.h" | 16 #include "SkPixelRef.h" |
| 17 | 17 |
| 18 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType
== bm.colorType(); } | 18 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType
== bm.colorType(); } |
| 19 | 19 |
| 20 // By construction this texture adjuster always represents an entire SkImage, so
use the | |
| 21 // image's dimensions for the key's rectangle. | |
| 22 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) | |
| 23 : GrTextureAdjuster(img->peekTexture(), SkIRect::MakeSize(img->dimensions())
, img->uniqueID(), | |
| 24 img->onImageInfo().colorSpace()) | |
| 25 { | |
| 26 SkASSERT(img->peekTexture()); | |
| 27 } | |
| 28 | |
| 29 ////////////////////////////////////////////////////////////////////////////// | |
| 30 | |
| 31 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b
itmap) | 20 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b
itmap) |
| 32 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm
ap)) | 21 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm
ap)) |
| 33 , fBitmap(bitmap) | 22 , fBitmap(bitmap) |
| 34 { | 23 { |
| 35 if (!bitmap.isVolatile()) { | 24 if (!bitmap.isVolatile()) { |
| 36 SkIPoint origin = bitmap.pixelRefOrigin(); | 25 SkIPoint origin = bitmap.pixelRefOrigin(); |
| 37 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), | 26 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), |
| 38 bitmap.height()); | 27 bitmap.height()); |
| 39 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID()
, subset); | 28 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID()
, subset); |
| 40 } | 29 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 97 |
| 109 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { | 98 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
| 110 if (fClient) { | 99 if (fClient) { |
| 111 as_IB(fClient)->notifyAddedToCache(); | 100 as_IB(fClient)->notifyAddedToCache(); |
| 112 } | 101 } |
| 113 } | 102 } |
| 114 | 103 |
| 115 SkColorSpace* GrImageTextureMaker::getColorSpace() { | 104 SkColorSpace* GrImageTextureMaker::getColorSpace() { |
| 116 return fCacher->info().colorSpace(); | 105 return fCacher->info().colorSpace(); |
| 117 } | 106 } |
| OLD | NEW |