| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "third_party/skia/include/gpu/GrContext.h" | 54 #include "third_party/skia/include/gpu/GrContext.h" |
| 55 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 55 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
| 56 #include "wtf/MathExtras.h" | 56 #include "wtf/MathExtras.h" |
| 57 #include "wtf/text/Base64.h" | 57 #include "wtf/text/Base64.h" |
| 58 #include "wtf/text/WTFString.h" | 58 #include "wtf/text/WTFString.h" |
| 59 | 59 |
| 60 using namespace std; | 60 using namespace std; |
| 61 | 61 |
| 62 namespace WebCore { | 62 namespace WebCore { |
| 63 | 63 |
| 64 static SkCanvas* createAcceleratedCanvas(const IntSize& size, OwnPtr<Canvas2DLay
erBridge>* outLayerBridge, OpacityMode opacityMode) | 64 static SkCanvas* createAcceleratedCanvas(const IntSize& size, RefPtr<Canvas2DLay
erBridge>* outLayerBridge, OpacityMode opacityMode) |
| 65 { | 65 { |
| 66 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); | 66 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); |
| 67 if (!context3D) | 67 if (!context3D) |
| 68 return 0; | 68 return 0; |
| 69 Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ?
Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; | 69 Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ?
Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; |
| 70 *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri
dgeOpacityMode); | 70 *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bri
dgeOpacityMode); |
| 71 // If canvas buffer allocation failed, debug build will have asserted | 71 // If canvas buffer allocation failed, debug build will have asserted |
| 72 // For release builds, we must verify whether the device has a render target | 72 // For release builds, we must verify whether the device has a render target |
| 73 return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; | 73 return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; |
| 74 } | 74 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // We're using context acquisition as a signal that someone is about to
render into our buffer and we need | 167 // We're using context acquisition as a signal that someone is about to
render into our buffer and we need |
| 168 // to be ready. This isn't logically const-correct, hence the cast. | 168 // to be ready. This isn't logically const-correct, hence the cast. |
| 169 const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired()
; | 169 const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->contextAcquired()
; |
| 170 } | 170 } |
| 171 return m_context.get(); | 171 return m_context.get(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 | 174 |
| 175 bool ImageBuffer::isValid() const | 175 bool ImageBuffer::isValid() const |
| 176 { | 176 { |
| 177 if (m_layerBridge.get()) | 177 if (m_layerBridge) |
| 178 return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid(); | 178 return const_cast<Canvas2DLayerBridge*>(m_layerBridge.get())->isValid(); |
| 179 return true; | 179 return true; |
| 180 } | 180 } |
| 181 | 181 |
| 182 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) | 182 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) |
| 183 { | 183 { |
| 184 SkBitmap tmp; | 184 SkBitmap tmp; |
| 185 if (!bitmap.deepCopyTo(&tmp, bitmap.config())) | 185 if (!bitmap.deepCopyTo(&tmp, bitmap.config())) |
| 186 bitmap.copyTo(&tmp, bitmap.config()); | 186 bitmap.copyTo(&tmp, bitmap.config()); |
| 187 | 187 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 489 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 490 return "data:,"; | 490 return "data:,"; |
| 491 | 491 |
| 492 Vector<char> base64Data; | 492 Vector<char> base64Data; |
| 493 base64Encode(encodedImage, base64Data); | 493 base64Encode(encodedImage, base64Data); |
| 494 | 494 |
| 495 return "data:" + mimeType + ";base64," + base64Data; | 495 return "data:" + mimeType + ";base64," + base64Data; |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace WebCore | 498 } // namespace WebCore |
| OLD | NEW |