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

Unified Diff: src/gpu/SkGr.cpp

Issue 1121813002: new image from backend desc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: set samplecount to 0 (for now) Created 5 years, 7 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.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 5df8c53febfbd2738a663f529e6c09d82a6c17d3..2fc0996d84cf2d42bb6c913c3ebe622807eaac75 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -12,6 +12,7 @@
#include "SkConfig8888.h"
#include "SkData.h"
#include "SkErrorInternals.h"
+#include "SkGrPixelRef.h"
#include "SkMessageBus.h"
#include "SkPixelRef.h"
#include "SkResourceCache.h"
@@ -737,3 +738,25 @@ bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPa
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint);
}
+
+SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) {
+#ifdef SK_DEBUG
+ const GrSurfaceDesc& desc = tex->desc();
+ SkASSERT(w <= desc.fWidth);
+ SkASSERT(h <= desc.fHeight);
+#endif
+ const GrPixelConfig config = tex->config();
+ SkColorType ct;
+ SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
+ if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) {
+ ct = kUnknown_SkColorType;
+ }
+ return SkImageInfo::Make(w, h, ct, at);
+}
+
+
+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(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
+}
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698