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

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 741763002: add SkImage::newSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/image/SkImage_Base.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index de49d1e33973f6f3e3dbd3f33e291fe4213ae931..b172a705405c17bd796218a5c83cf1317bc3c0da 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -9,6 +9,7 @@
#include "SkImagePriv.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkSurface.h"
#include "GrContext.h"
#include "GrTexture.h"
@@ -19,19 +20,20 @@ public:
explicit SkImage_Gpu(const SkBitmap&);
virtual ~SkImage_Gpu();
- virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVERRIDE;
- virtual void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst,
- const SkPaint*) const SK_OVERRIDE;
- virtual GrTexture* onGetTexture() const SK_OVERRIDE;
- virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
+ void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const SK_OVERRIDE;
+ void onDrawRect(SkCanvas*, const SkRect* src, const SkRect& dst,
+ const SkPaint*) const SK_OVERRIDE;
+ SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const SK_OVERRIDE;
+ GrTexture* onGetTexture() const SK_OVERRIDE;
+ bool getROPixels(SkBitmap*) const SK_OVERRIDE;
GrTexture* getTexture() const { return fBitmap.getTexture(); }
- virtual SkShader* onNewShader(SkShader::TileMode,
+ SkShader* onNewShader(SkShader::TileMode,
SkShader::TileMode,
const SkMatrix* localMatrix) const SK_OVERRIDE;
- virtual bool isOpaque() const SK_OVERRIDE;
+ bool isOpaque() const SK_OVERRIDE;
private:
SkBitmap fBitmap;
@@ -42,7 +44,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap)
- : INHERITED(bitmap.width(), bitmap.height())
+ : INHERITED(bitmap.width(), bitmap.height(), NULL)
, fBitmap(bitmap) {
SkASSERT(fBitmap.getTexture());
}
@@ -66,6 +68,12 @@ void SkImage_Gpu::onDrawRect(SkCanvas* canvas, const SkRect* src, const SkRect&
canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
}
+SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) const {
+ GrContext* ctx = this->getTexture()->getContext();
+ const int sampleCount = 0; // TODO: extract this from this image...
bsalomon 2014/11/21 14:45:44 why not just do this as part of this CL?
reed1 2014/11/21 16:33:06 Done.
+ return SkSurface::NewRenderTarget(ctx, info, sampleCount, &props);
+}
+
GrTexture* SkImage_Gpu::onGetTexture() const {
return fBitmap.getTexture();
}
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698