aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-31 15:45:27 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-31 15:45:27 +0000
commit5d4ba8869476831ee73b15a052af8003d0a1fa2e (patch)
tree00412261a2737750b426301eed006187255b9441 /src/image/SkImage_Gpu.cpp
parent0982d35187da7e1ed6c0eba5951bbdadca8b33e7 (diff)
check-point for gpu support in SkImage/SkSurface
git-svn-id: http://skia.googlecode.com/svn/trunk@4859 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r--src/image/SkImage_Gpu.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
new file mode 100644
index 0000000000..6ccf10bfd8
--- /dev/null
+++ b/src/image/SkImage_Gpu.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImage_Base.h"
+#include "SkImagePriv.h"
+#include "SkBitmap.h"
+#include "SkCanvas.h"
+#include "SkData.h"
+#include "SkDataPixelRef.h"
+
+class SkImage_Gpu : public SkImage_Base {
+public:
+ static bool ValidArgs(GrContext* context,
+ const GrPlatformTextureDesc& desc) {
+ if (0 == desc.fTextureHandle) {
+ return false;
+ }
+ if (desc.fWidth < 0 || desc.fHeight < 0) {
+ return false;
+ }
+ return true;
+ }
+
+ SkImage_Gpu(GrContext* context, const GrPlatformTextureDesc& desc);
+ virtual ~SkImage_Gpu();
+
+ virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRIDE;
+
+private:
+ SkBitmap fBitmap;
+
+ typedef SkImage_Base INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkImage_Gpu::SkImage_Gpu(GrContext* context, const GrPlatformTextureDesc& desc)
+ : INHERITED(desc.fWidth, desc.fHeight) {
+#if 0
+ bool isOpaque;
+ SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
+
+ fBitmap.setConfig(config, info.fWidth, info.fHeight, rowBytes);
+ fBitmap.setPixelRef(SkNEW_ARGS(SkDataPixelRef, (data)))->unref();
+ fBitmap.setIsOpaque(isOpaque);
+ fBitmap.setImmutable();
+#endif
+}
+
+SkImage_Gpu::~SkImage_Gpu() {}
+
+void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) {
+ canvas->drawBitmap(fBitmap, x, y, paint);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkImage* SkImage::NewRasterCopy(NewTexture(GrContext* context,
+ const GrPlatformTextureDesc& desc) {
+ if (NULL == context) {
+ return NULL;
+ }
+ if (!SkImage_Gpu::ValidArgs(context, desc)) {
+ return NULL;
+ }
+
+ return SkNEW_ARGS(SkImage_Gpu, (context, desc));
+}
+