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

Unified Diff: src/image/SkImage.cpp

Issue 1166993002: Towards removing getTexture() from SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 6 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
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage.cpp
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 4efbc33c1526862016b8f115dc682919c9dd6751..4e563a048e4e0b238d1bdb2fe0d3b587a34e254f 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -13,6 +13,10 @@
#include "SkReadPixelsRec.h"
#include "SkString.h"
#include "SkSurface.h"
+#if SK_SUPPORT_GPU
+#include "GrTexture.h"
+#include "GrContext.h"
+#endif
uint32_t SkImage::NextUniqueID() {
static int32_t gUniqueID;
@@ -46,10 +50,6 @@ bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst
return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY);
}
-GrTexture* SkImage::getTexture() const {
- return as_IB(this)->onGetTexture();
-}
-
SkShader* SkImage::newShader(SkShader::TileMode tileX,
SkShader::TileMode tileY,
const SkMatrix* localMatrix) const {
@@ -109,6 +109,38 @@ SkImage* SkImage::newImage(int newWidth, int newHeight, const SkIRect* subset,
return as_IB(this)->onNewImage(newWidth, newHeight, subset, quality);
}
+#if SK_SUPPORT_GPU
+
+GrTexture* SkImage::getTexture() const {
+ return as_IB(this)->getTexture();
+}
+
+bool SkImage::isTextureBacked() const { return SkToBool(as_IB(this)->getTexture()); }
+
+GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextReads) const {
+ GrTexture* texture = as_IB(this)->getTexture();
+ if (texture) {
+ GrContext* context = texture->getContext();
+ if (context) {
+ if (flushPendingGrContextReads) {
+ context->prepareSurfaceForExternalRead(texture);
+ }
+ }
+ return texture->getTextureHandle();
+ }
+ return 0;
+}
+
+#else
+
+GrTexture* SkImage::getTexture() const { return NULL; }
+
+bool SkImage::isTextureBacked() const { return false; }
+
+GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextReads) const { return 0; }
+
+#endif
+
///////////////////////////////////////////////////////////////////////////////
static bool raster_canvas_supports(const SkImageInfo& info) {
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698