JSFiddle - React, Tailwind, and code Playground

by Abhijeet Kandalkar

HTML

diff --git a/gpu/skia_bindings/gl_bindings_skia_cmd_buffer.cc b/gpu/skia_bindings/gl_bindings_skia_cmd_buffer.cc
index 2894cf7..1688ae0 100644
--- a/gpu/skia_bindings/gl_bindings_skia_cmd_buffer.cc
+++ b/gpu/skia_bindings/gl_bindings_skia_cmd_buffer.cc
@@ -140,6 +140,12 @@ GrGLInterface* CreateCommandBufferSkiaGLBinding() {
   functions->fBindUniformLocation = glBindUniformLocationCHROMIUM;
   functions->fBlitFramebuffer = glBlitFramebufferCHROMIUM;
   functions->fGenerateMipmap = glGenerateMipmap;
+#if 0
+functions->fCreateImage = glCreateImageCHROMIUM;
+functions->fMapImage = glMapImageCHROMIUM;
+functions->fUnMapImage = glUnmapImageCHROMIUM;
+functions->fBindImage = glBindTexImage2DCHROMIUM;
+#endif
 
   return interface;
 }
diff --git a/skia/ext/SkDiscardableMemory_chrome.cc b/skia/ext/SkDiscardableMemory_chrome.cc
index 7103100..e1a03fa 100644
--- a/skia/ext/SkDiscardableMemory_chrome.cc
+++ b/skia/ext/SkDiscardableMemory_chrome.cc
@@ -4,6 +4,8 @@
 
 #include "SkDiscardableMemory_chrome.h"
 
+#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
+
 SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
 
 bool SkDiscardableMemoryChrome::lock() {
@@ -33,6 +35,34 @@ SkDiscardableMemoryChrome::SkDiscardableMemoryChrome(
     : discardable_(memory.Pass()) {
 }
 
+//Abhijeet
+#if 1
+SkGrDiscardableMemoryChrome::~SkGrDiscardableMemoryChrome() {}
+
+bool SkGrDiscardableMemoryChrome::lock() {
+    return false;
+}
+
+void* SkGrDiscardableMemoryChrome::data() {
+  //return discardable_->Memory();
+    void* memory = malloc(width_);
+    memset(memory, 0, width_);
+    return memory;
+}
+
+void SkGrDiscardableMemoryChrome::unlock() {
+  //discardable_->Unlock();
+}
+
+SkGrDiscardableMemoryChrome::SkGrDiscardableMemoryChrome(
+GLInterface* interface, size_t width, size_t height)
+    : interface_(interface)
+    , width_(width)
+    , height_(height){
+    imgId_ = 0; // createImageChromium here
+}
+#endif
+//Abhijeet
 SkDiscardableMemory*...

CSS

diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 0e847f2..4de42d2 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -157,6 +157,15 @@ public:
     */
     size_t getSize() const { return fInfo.fHeight * fRowBytes; }
 
+    unsigned image() const { return imgId; }
+    void setImage(unsigned img) { imgId = img; }
+
+    void* context3D() const { return context; }
+    void setContext3D(void* ctx) { context = ctx; }
+
+    bool isGLBackedBitmap() { return isGLBacked; }
+    void setIsGLBackedBitmap(bool b) { isGLBacked = b; }
+
     /** Return the number of bytes from the pointer returned by getPixels()
         to the end of the allocated space in the buffer. Required in
         cases where extractSubset has been called.
@@ -308,7 +317,7 @@ public:
         @param ctable   ColorTable (or null) that matches the specified pixels
     */
     void setPixels(void* p, SkColorTable* ctable = NULL);
-
+    void setGrPixels(void* p, SkImageInfo info, GrTexture* tex);
     /** Copies the bitmap's pixels to the location pointed at by dst and returns
         true if possible, returns false otherwise.
 
@@ -753,6 +762,12 @@ private:
     static void WriteRawPixels(SkWriteBuffer*, const SkBitmap&);
     static bool ReadRawPixels(SkReadBuffer*, SkBitmap*);
 
+    //id here
+    unsigned imgId;
+    void* context;
+    bool isGLBacked;
+    //void* grCtx;
+
     friend class SkBitmapSource;    // unflatten
     friend class SkReadBuffer;      // unflatten, rawpixels
     friend class SkWriteBuffer;     // rawpixels
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 3d82dc8..901b2da 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -140,10 +140,14 @@ struct SkImageInfo {
     int         fHeight;
     SkColorType fColorType;
     SkAlphaType fAlphaType;
+    bool isGLBacked;
+	unsigned imgId;
+    void* grCtx;
+
 
     static SkImageInfo Make(int width, int height, SkColorType ct,...

JavaScript

diff --git a/Source/core/html/HTMLCanvasElement.cpp b/Source/core/html/HTMLCanvasElement.cpp
index 25fbe5b..5091152 100644
--- a/Source/core/html/HTMLCanvasElement.cpp
+++ b/Source/core/html/HTMLCanvasElement.cpp
@@ -426,6 +426,8 @@ SecurityOrigin* HTMLCanvasElement::securityOrigin() const
 
 bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const
 {
+    return true;
+
     if (m_context && !m_context->is2d())
         return false;
 
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 8db3e3b..d4270b5 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -61,6 +61,7 @@
 #include "core/rendering/RenderTheme.h"
 #include "platform/fonts/FontCache.h"
 #include "platform/geometry/FloatQuad.h"
+#include "platform/graphics/Canvas2DImageBufferSurface.h"
 #include "platform/graphics/DrawLooperBuilder.h"
 #include "platform/graphics/GraphicsContextStateSaver.h"
 #include "platform/text/TextRun.h"
@@ -1492,6 +1493,15 @@ void CanvasRenderingContext2D::drawImageInternal(CanvasImageSource* imageSource,
     GraphicsContext* c = drawingContext();
     if (!c)
         return;
+#if 0
+    Canvas2DImageBufferSurface* surface = static_cast<Canvas2DImageBufferSurface*>(canvas()->buffer()->surface());
+    void* ctxProvider = 0;
+
+    if (surface)
+        ctxProvider = surface->contextProvider3D();
+
+    image->setContext3D(ctxProvider);
+#endif
 
     if (!state().m_invertibleCTM)
         return;
@@ -1520,6 +1530,9 @@ void CanvasRenderingContext2D::drawImageInternal(CanvasImageSource* imageSource,
         drawVideo(static_cast<HTMLVideoElement*>(imageSource), srcRect, dstRect);
         computeDirtyRect(dstRect, clipBounds, &dirtyRect);
     } else {
+
+        image->setGLBackedImage(true);
+
         if (rectContainsTransformedRect(dstRect, clipBounds)) {
             c->drawImage(image.get(), dstRect, srcRect,...