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

Unified Diff: src/gpu/GrImageIDTextureAdjuster.cpp

Issue 2241353002: pin as texture api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use refPinnedTexture in GpuDevice Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrImageIDTextureAdjuster.cpp
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp
index 989102e740f2811dd428ffc30449cd9b3432206d..7609287af8e5ffe75fa353d92ab6d6f6a1496263 100644
--- a/src/gpu/GrImageIDTextureAdjuster.cpp
+++ b/src/gpu/GrImageIDTextureAdjuster.cpp
@@ -17,32 +17,35 @@
static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); }
-// SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to
-// inspecting the texture.
-static bool tex_image_is_alpha_only(const SkImage_Base& img) {
- return GrPixelConfigIsAlphaOnly(img.peekTexture()->config());
-}
-
-GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
- : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()),
- tex_image_is_alpha_only(*img))
- , fImageBase(img) {}
-
-void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
- // By construction this texture adjuster always represents an entire SkImage, so use the
- // image's width and height for the key's rectangle.
+GrRawTextureAdjuster::GrRawTextureAdjuster(GrTexture* tex, const SkISize& size, uint32_t uniqueID,
+ SkColorSpace* cs)
+ : INHERITED(tex, SkIRect::MakeSize(size), GrPixelConfigIsAlphaOnly(tex->config()))
+ , fColorSpace(cs)
+ , fSize(size)
+ , fUniqueID(uniqueID)
+{}
+
+void GrRawTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
GrUniqueKey baseKey;
- GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
- SkIRect::MakeWH(fImageBase->width(), fImageBase->height()));
+ GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeSize(fSize));
MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
}
-void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
+void GrRawTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
// We don't currently have a mechanism for notifications on Images!
}
-SkColorSpace* GrImageTextureAdjuster::getColorSpace() {
- return fImageBase->onImageInfo().colorSpace();
+SkColorSpace* GrRawTextureAdjuster::getColorSpace() {
+ return fColorSpace;
+}
+
+// By construction this texture adjuster always represents an entire SkImage, so use the
+// image's width and height for the key's rectangle.
+GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
+ : GrRawTextureAdjuster(img->peekTexture(), img->dimensions(), img->uniqueID(),
+ img->onImageInfo().colorSpace())
+{
+ SkASSERT(img->peekTexture());
}
//////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698