aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/gpu.gypi2
-rw-r--r--src/core/SkSpecialImage.cpp24
-rw-r--r--src/gpu/SkGpuDevice.cpp1
-rw-r--r--src/gpu/SkGr.cpp8
-rw-r--r--src/gpu/SkGrPixelRef.cpp212
-rw-r--r--src/gpu/SkGrPixelRef.h61
-rw-r--r--src/gpu/SkGrPriv.h7
-rw-r--r--src/image/SkImage_Base.h6
-rw-r--r--src/image/SkImage_Gpu.cpp8
-rw-r--r--src/image/SkImage_Gpu.h2
-rw-r--r--tests/BitmapCopyTest.cpp85
11 files changed, 0 insertions, 416 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 52830bf09e..67530c2b65 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -434,8 +434,6 @@
'<(skia_src_path)/gpu/SkGpuDevice.h',
'<(skia_src_path)/gpu/SkGpuDevice_drawTexture.cpp',
'<(skia_src_path)/gpu/SkGr.cpp',
- '<(skia_src_path)/gpu/SkGrPixelRef.cpp',
- '<(skia_src_path)/gpu/SkGrPixelRef.h',
'<(skia_src_path)/gpu/SkGrPriv.h',
'<(skia_src_path)/image/SkImage_Gpu.h',
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index ecde3d97c8..d6fbd2ad2f 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -20,7 +20,6 @@
#include "GrTexture.h"
#include "GrTextureParams.h"
#include "SkGr.h"
-#include "SkGrPixelRef.h"
#include "SkGrPriv.h"
#endif
@@ -51,9 +50,6 @@ public:
virtual sk_sp<GrTexture> onAsTextureRef(GrContext* context) const = 0;
#endif
- // Delete this entry point ASAP (see skbug.com/4965)
- virtual bool getBitmapDeprecated(SkBitmap* result) const = 0;
-
virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0;
@@ -255,11 +251,6 @@ public:
}
#endif
- bool getBitmapDeprecated(SkBitmap* result) const override {
- *result = fBitmap;
- return true;
- }
-
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override {
return SkSpecialSurface::MakeRaster(info, nullptr);
}
@@ -391,21 +382,6 @@ public:
return fColorSpace.get();
}
- bool getBitmapDeprecated(SkBitmap* result) const override {
- const SkImageInfo info = GrMakeInfoFromTexture(fTexture.get(),
- this->width(), this->height(),
- this->isOpaque(), fColorSpace);
- if (!result->setInfo(info)) {
- return false;
- }
-
- const SkImageInfo prInfo = info.makeWH(fTexture->width(), fTexture->height());
-
- SkAutoTUnref<SkGrPixelRef> pixelRef(new SkGrPixelRef(prInfo, fTexture.get()));
- result->setPixelRef(pixelRef, this->subset().fLeft, this->subset().fTop);
- return true;
- }
-
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override {
if (!fTexture->getContext()) {
return nullptr;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 314281c0ad..2b4c0842a0 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -19,7 +19,6 @@
#include "SkErrorInternals.h"
#include "SkGlyphCache.h"
#include "SkGr.h"
-#include "SkGrPixelRef.h"
#include "SkGrPriv.h"
#include "SkImage_Base.h"
#include "SkImageCacherator.h"
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 3b3783ad35..ef3a39bc61 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -24,7 +24,6 @@
#include "SkCanvas.h"
#include "SkData.h"
#include "SkErrorInternals.h"
-#include "SkGrPixelRef.h"
#include "SkMessageBus.h"
#include "SkMipMap.h"
#include "SkPixelRef.h"
@@ -758,13 +757,6 @@ SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque,
return SkImageInfo::Make(w, h, ct, at, std::move(colorSpace));
}
-
-void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap* dst) {
- const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
- dst->setInfo(info);
- dst->setPixelRef(new SkGrPixelRef(info, src))->unref();
-}
-
GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
const SkMatrix& viewM,
const SkMatrix& localM,
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
deleted file mode 100644
index df2300369d..0000000000
--- a/src/gpu/SkGrPixelRef.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#include "SkGrPixelRef.h"
-
-#include "GrContext.h"
-#include "GrTexture.h"
-#include "GrTexturePriv.h"
-#include "SkBitmapCache.h"
-#include "SkGr.h"
-#include "SkRect.h"
-
-SkROLockPixelsPixelRef::SkROLockPixelsPixelRef(const SkImageInfo& info)
- : INHERITED(info) {}
-
-SkROLockPixelsPixelRef::~SkROLockPixelsPixelRef() {}
-
-bool SkROLockPixelsPixelRef::onNewLockPixels(LockRec* rec) {
- fBitmap.reset();
-// SkDebugf("---------- calling readpixels in support of lockpixels\n");
- if (!this->onReadPixels(&fBitmap, this->info().colorType(), nullptr)) {
- SkDebugf("SkROLockPixelsPixelRef::onLockPixels failed!\n");
- return false;
- }
- fBitmap.lockPixels();
- if (nullptr == fBitmap.getPixels()) {
- return false;
- }
-
- rec->fPixels = fBitmap.getPixels();
- rec->fColorTable = nullptr;
- rec->fRowBytes = fBitmap.rowBytes();
- return true;
-}
-
-void SkROLockPixelsPixelRef::onUnlockPixels() {
- fBitmap.unlockPixels();
-}
-
-bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorType dstCT,
- SkColorSpace* dstCS, const SkIRect* subset) {
- if (nullptr == texture || kUnknown_SkColorType == dstCT) {
- return nullptr;
- }
- GrContext* context = texture->getContext();
- if (nullptr == context) {
- return nullptr;
- }
- GrSurfaceDesc desc;
-
- SkIRect srcRect;
-
- if (!subset) {
- desc.fWidth = texture->width();
- desc.fHeight = texture->height();
- srcRect = SkIRect::MakeWH(texture->width(), texture->height());
- } else {
- SkASSERT(SkIRect::MakeWH(texture->width(), texture->height()).contains(*subset));
- // Create a new texture that is the size of subset.
- desc.fWidth = subset->width();
- desc.fHeight = subset->height();
- srcRect = *subset;
- }
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstCS, *context->caps());
- desc.fIsMipMapped = false;
-
- GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);
- if (nullptr == dst) {
- return nullptr;
- }
-
- // Blink is relying on the above copy being sent to GL immediately in the case when the source
- // is a WebGL canvas backing store. We could have a TODO to remove this flush, but we have
- // a larger TODO to remove SkGrPixelRef entirely.
- context->copySurface(dst, texture, srcRect, SkIPoint::Make(0,0));
- context->flushSurfaceWrites(dst);
-
- SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType,
- sk_ref_sp(dstCS));
- SkGrPixelRef* pixelRef = new SkGrPixelRef(info, dst);
- SkSafeUnref(dst);
- return pixelRef;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface) : INHERITED(info) {
- // For surfaces that are both textures and render targets, the texture owns the
- // render target but not vice versa. So we ref the texture to keep both alive for
- // the lifetime of this pixel ref.
- fSurface = SkSafeRef(surface->asTexture());
- if (nullptr == fSurface) {
- fSurface = SkSafeRef(surface);
- }
-
- if (fSurface) {
- SkASSERT(info.width() <= fSurface->width());
- SkASSERT(info.height() <= fSurface->height());
- }
-}
-
-SkGrPixelRef::~SkGrPixelRef() {
- SkSafeUnref(fSurface);
-}
-
-GrTexture* SkGrPixelRef::getTexture() {
- if (fSurface) {
- return fSurface->asTexture();
- }
- return nullptr;
-}
-
-void SkGrPixelRef::onNotifyPixelsChanged() {
- GrTexture* texture = this->getTexture();
- if (texture) {
- texture->texturePriv().dirtyMipMaps(true);
- }
-}
-
-SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorSpace* dstCS, const SkIRect* subset) {
- if (nullptr == fSurface) {
- return nullptr;
- }
-
- // Note that when copying a render-target-backed pixel ref, we
- // return a texture-backed pixel ref instead. This is because
- // render-target pixel refs are usually created in conjunction with
- // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
- // independently of that texture. Texture-backed pixel refs, on the other
- // hand, own their GrTextures, and are thus self-contained.
- return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstCS, subset);
-}
-
-static bool tryAllocBitmapPixels(SkBitmap* bitmap) {
- SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator();
- if (nullptr != allocator) {
- return allocator->allocPixelRef(bitmap, 0);
- } else {
- // DiscardableMemory is not available, fallback to default allocator
- return bitmap->tryAllocPixels();
- }
-}
-
-bool SkGrPixelRef::onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subset) {
- if (nullptr == fSurface || fSurface->wasDestroyed()) {
- return false;
- }
-
- GrPixelConfig config;
- if (kRGBA_8888_SkColorType == colorType) {
- config = kRGBA_8888_GrPixelConfig;
- } else if (kBGRA_8888_SkColorType == colorType) {
- config = kBGRA_8888_GrPixelConfig;
- } else {
- return false;
- }
-
- SkIRect bounds;
- if (subset) {
- bounds = *subset;
- } else {
- bounds = SkIRect::MakeWH(this->info().width(), this->info().height());
- }
-
- //Check the cache
- if(!SkBitmapCache::Find(this->getGenerationID(), bounds, dst)) {
- //Cache miss
-
- SkBitmap cachedBitmap;
- cachedBitmap.setInfo(SkImageInfo::Make(bounds.width(), bounds.height(), colorType,
- this->info().alphaType(),
- sk_ref_sp(this->info().colorSpace())));
-
- // If we can't alloc the pixels, then fail
- if (!tryAllocBitmapPixels(&cachedBitmap)) {
- return false;
- }
-
- // Try to read the pixels from the surface
- void* buffer = cachedBitmap.getPixels();
- bool readPixelsOk = fSurface->readPixels(bounds.fLeft, bounds.fTop,
- bounds.width(), bounds.height(),
- config, buffer, cachedBitmap.rowBytes());
-
- if (!readPixelsOk) {
- return false;
- }
-
- // If we are here, pixels were read correctly from the surface.
- cachedBitmap.setImmutable();
- //Add to the cache
- SkBitmapCache::Add(this, bounds, cachedBitmap);
-
- dst->swap(cachedBitmap);
- }
-
- return true;
-
-}
diff --git a/src/gpu/SkGrPixelRef.h b/src/gpu/SkGrPixelRef.h
deleted file mode 100644
index 2bbe48fa09..0000000000
--- a/src/gpu/SkGrPixelRef.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkGrPixelRef_DEFINED
-#define SkGrPixelRef_DEFINED
-
-#include "SkBitmap.h"
-#include "SkPixelRef.h"
-#include "GrTexture.h"
-#include "GrRenderTarget.h"
-
-
-/**
- * Common baseclass that implements onLockPixels() by calling onReadPixels().
- * Since it has a copy, it always returns false for onLockPixelsAreWritable().
- */
-class SK_API SkROLockPixelsPixelRef : public SkPixelRef {
-public:
- SkROLockPixelsPixelRef(const SkImageInfo&);
- virtual ~SkROLockPixelsPixelRef();
-
-protected:
- bool onNewLockPixels(LockRec*) override;
- void onUnlockPixels() override;
- bool onLockPixelsAreWritable() const override; // return false;
-
-private:
- SkBitmap fBitmap;
- typedef SkPixelRef INHERITED;
-};
-
-/**
- * PixelRef that wraps a GrSurface
- */
-class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef {
-public:
- /**
- * Constructs a pixel ref around a GrSurface.
- */
- SkGrPixelRef(const SkImageInfo&, GrSurface*);
- virtual ~SkGrPixelRef();
-
- // override from SkPixelRef
- GrTexture* getTexture() override;
-
-protected:
- // overrides from SkPixelRef
- bool onReadPixels(SkBitmap* dst, SkColorType, const SkIRect* subset) override;
- SkPixelRef* deepCopy(SkColorType, SkColorSpace*, const SkIRect* subset) override;
- void onNotifyPixelsChanged() override;
-
-private:
- GrSurface* fSurface;
- typedef SkROLockPixelsPixelRef INHERITED;
-};
-
-#endif
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index b38ce362c1..ab77dc1e79 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -100,13 +100,6 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
//////////////////////////////////////////////////////////////////////////////
-// Using the dreaded SkGrPixelRef ...
-void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque,
- SkBitmap* dst);
-
-
-//////////////////////////////////////////////////////////////////////////////
-
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&);
bool GrPixelConfigToColorAndColorSpace(GrPixelConfig, SkColorType*, sk_sp<SkColorSpace>*);
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index c01d9af635..f1b902bd84 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -61,12 +61,6 @@ public:
virtual bool onIsLazyGenerated() const { return false; }
- // Return a bitmap suitable for passing to image-filters
- // For now, that means wrapping textures into SkGrPixelRefs...
- virtual bool asBitmapForImageFilters(SkBitmap* bitmap) const {
- return this->getROPixels(bitmap, kAllow_CachingHint);
- }
-
// Call when this image is part of the key to a resourcecache entry. This allows the cache
// to know automatically those entries can be purged when this SkImage deleted.
void notifyAddedToCache() const {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index b3604b999b..9e10dab4a7 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -13,7 +13,6 @@
#include "effects/GrYUVEffect.h"
#include "SkCanvas.h"
#include "SkBitmapCache.h"
-#include "SkGrPixelRef.h"
#include "SkGrPriv.h"
#include "SkImage_Gpu.h"
#include "SkMipMap.h"
@@ -74,13 +73,6 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const {
return true;
}
-bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
- bitmap->setInfo(make_info(this->width(), this->height(), this->isOpaque(), fColorSpace));
- bitmap->setPixelRef(new SkGrPixelRef(bitmap->info(), fTexture))->unref();
- bitmap->pixelRef()->setImmutableWithID(this->uniqueID());
- return true;
-}
-
GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params,
SkSourceGammaTreatment gammaTreatment) const {
return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, gammaTreatment,
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 6206416bce..0e9169d8d0 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -54,8 +54,6 @@ public:
return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::kNo, info);
}
- bool asBitmapForImageFilters(SkBitmap* bitmap) const override;
-
private:
SkAutoTUnref<GrTexture> fTexture;
const SkAlphaType fAlphaType;
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 848a83e45a..639c51a5f1 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -633,88 +633,3 @@ DEF_TEST(BitmapReadPixels, reporter) {
}
}
-#if SK_SUPPORT_GPU
-
-#include "GrContext.h"
-#include "SkGr.h"
-#include "SkColorPriv.h"
-/** Tests calling copyTo on a texture backed bitmap. Tests that all BGRA_8888/RGBA_8888 combinations
- of src and dst work. This test should be removed when SkGrPixelRef is removed. */
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BitmapCopy_Texture, reporter, ctxInfo) {
- static const SkPMColor kData[] = {
- 0xFF112233, 0xAF224499,
- 0xEF004466, 0x80773311
- };
-
- uint32_t swizData[SK_ARRAY_COUNT(kData)];
- for (size_t i = 0; i < SK_ARRAY_COUNT(kData); ++i) {
- swizData[i] = SkSwizzle_RB(kData[i]);
- }
-
- static const GrPixelConfig kSrcConfigs[] = {
- kRGBA_8888_GrPixelConfig,
- kBGRA_8888_GrPixelConfig,
- };
-
- for (size_t srcC = 0; srcC < SK_ARRAY_COUNT(kSrcConfigs); ++srcC) {
- for (int rt = 0; rt < 2; ++rt) {
- GrSurfaceDesc desc;
- desc.fConfig = kSrcConfigs[srcC];
- desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- desc.fWidth = 2;
- desc.fHeight = 2;
- desc.fOrigin = kTopLeft_GrSurfaceOrigin;
-
- const void* srcData = (kSkia8888_GrPixelConfig == desc.fConfig) ? kData : swizData;
-
- SkAutoTUnref<GrTexture> texture(
- ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudgeted::kNo,
- srcData, 0));
-
- if (!texture) {
- continue;
- }
-
- SkBitmap srcBmp;
- GrWrapTextureInBitmap(texture, 2, 2, false, &srcBmp);
- if (srcBmp.isNull()) {
- ERRORF(reporter, "Could not wrap texture in bitmap.");
- continue;
- }
- static const SkColorType kDstCTs[] = { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType };
- for (size_t dCT = 0; dCT < SK_ARRAY_COUNT(kDstCTs); ++dCT) {
- SkBitmap dstBmp;
- if (!srcBmp.copyTo(&dstBmp, kDstCTs[dCT])) {
- ERRORF(reporter, "CopyTo failed.");
- }
- if (dstBmp.colorType() != kDstCTs[dCT]) {
- ERRORF(reporter, "SkBitmap::CopyTo did not respect passed in color type.");
- }
- SkAutoLockPixels alp(dstBmp);
- uint8_t* dstBmpPixels = static_cast<uint8_t*>(dstBmp.getPixels());
- const uint32_t* refData;
-#if defined(SK_PMCOLOR_IS_RGBA)
- refData = (kRGBA_8888_SkColorType == dstBmp.colorType()) ? kData : swizData;
-#elif defined(SK_PMCOLOR_IS_BGRA)
- refData = (kBGRA_8888_SkColorType == dstBmp.colorType()) ? kData : swizData;
-#else
- #error "PM Color must be BGRA or RGBA to use GPU backend."
-#endif
- bool foundError = false;
- for (int y = 0; y < 2 && !foundError; ++y) {
- uint32_t* dstBmpRow = reinterpret_cast<uint32_t*>(dstBmpPixels);
- for (int x = 0; x < 2 && !foundError; ++x) {
- if (refData[2 * y + x] != dstBmpRow[x]) {
- ERRORF(reporter, "Expected pixel 0x%08x, found 0x%08x.",
- refData[2 * y + x], dstBmpRow[x]);
- foundError = true;
- }
- }
- dstBmpPixels += dstBmp.rowBytes();
- }
- }
- }
- }
-}
-
-#endif