| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (c) 2008, Google Inc. All rights reserved. | 2  * Copyright (c) 2008, Google Inc. All rights reserved. | 
| 3  * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3  * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 
| 4  * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4  * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 
| 5  * | 5  * | 
| 6  * Redistribution and use in source and binary forms, with or without | 6  * Redistribution and use in source and binary forms, with or without | 
| 7  * modification, are permitted provided that the following conditions are | 7  * modification, are permitted provided that the following conditions are | 
| 8  * met: | 8  * met: | 
| 9  * | 9  * | 
| 10  *     * Redistributions of source code must retain the above copyright | 10  *     * Redistributions of source code must retain the above copyright | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55 #include "third_party/skia/include/gpu/GrContext.h" | 55 #include "third_party/skia/include/gpu/GrContext.h" | 
| 56 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 56 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 
| 57 #include "wtf/MathExtras.h" | 57 #include "wtf/MathExtras.h" | 
| 58 #include "wtf/text/Base64.h" | 58 #include "wtf/text/Base64.h" | 
| 59 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" | 
| 60 | 60 | 
| 61 using namespace std; | 61 using namespace std; | 
| 62 | 62 | 
| 63 namespace WebCore { | 63 namespace WebCore { | 
| 64 | 64 | 
| 65 static SkCanvas* createAcceleratedCanvas(const IntSize& size, OwnPtr<Canvas2DLay
     erBridge>* outLayerBridge, OpacityMode opacityMode) | 65 static SkCanvas* createAcceleratedCanvas(const IntSize& size, Canvas2DLayerBridg
     ePtr* outLayerBridge, OpacityMode opacityMode) | 
| 66 { | 66 { | 
| 67     RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); | 67     RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); | 
| 68     if (!context3D) | 68     if (!context3D) | 
| 69         return 0; | 69         return 0; | 
| 70     Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ?
      Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; | 70     Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ?
      Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; | 
| 71     *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri
     dgeOpacityMode); | 71     *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri
     dgeOpacityMode); | 
| 72     // If canvas buffer allocation failed, debug build will have asserted | 72     // If canvas buffer allocation failed, debug build will have asserted | 
| 73     // For release builds, we must verify whether the device has a render target | 73     // For release builds, we must verify whether the device has a render target | 
| 74     return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; | 74     return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; | 
| 75 } | 75 } | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168         // We're using context acquisition as a signal that someone is about to 
     render into our buffer and we need | 168         // We're using context acquisition as a signal that someone is about to 
     render into our buffer and we need | 
| 169         // to be ready. This isn't logically const-correct, hence the cast. | 169         // to be ready. This isn't logically const-correct, hence the cast. | 
| 170         const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired()
     ; | 170         const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired()
     ; | 
| 171     } | 171     } | 
| 172     return m_context.get(); | 172     return m_context.get(); | 
| 173 } | 173 } | 
| 174 | 174 | 
| 175 | 175 | 
| 176 bool ImageBuffer::isValid() const | 176 bool ImageBuffer::isValid() const | 
| 177 { | 177 { | 
| 178     if (m_layerBridge.get()) | 178     if (m_layerBridge) | 
| 179         return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid(); | 179         return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid(); | 
| 180     return true; | 180     return true; | 
| 181 } | 181 } | 
| 182 | 182 | 
| 183 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) | 183 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) | 
| 184 { | 184 { | 
| 185     SkBitmap tmp; | 185     SkBitmap tmp; | 
| 186     if (!bitmap.deepCopyTo(&tmp, bitmap.config())) | 186     if (!bitmap.deepCopyTo(&tmp, bitmap.config())) | 
| 187         bitmap.copyTo(&tmp, bitmap.config()); | 187         bitmap.copyTo(&tmp, bitmap.config()); | 
| 188 | 188 | 
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 490     if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 490     if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 
| 491         return "data:,"; | 491         return "data:,"; | 
| 492 | 492 | 
| 493     Vector<char> base64Data; | 493     Vector<char> base64Data; | 
| 494     base64Encode(encodedImage, base64Data); | 494     base64Encode(encodedImage, base64Data); | 
| 495 | 495 | 
| 496     return "data:" + mimeType + ";base64," + base64Data; | 496     return "data:" + mimeType + ";base64," + base64Data; | 
| 497 } | 497 } | 
| 498 | 498 | 
| 499 } // namespace WebCore | 499 } // namespace WebCore | 
| OLD | NEW | 
|---|