| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 // This shim necessary because ImageBufferSurfaces are not allowed to be RefCoun
ted | 39 // This shim necessary because ImageBufferSurfaces are not allowed to be RefCoun
ted |
| 40 class Canvas2DImageBufferSurface final : public ImageBufferSurface { | 40 class Canvas2DImageBufferSurface final : public ImageBufferSurface { |
| 41 public: | 41 public: |
| 42 Canvas2DImageBufferSurface(const IntSize& size, int msaaSampleCount, Opacity
Mode opacityMode, Canvas2DLayerBridge::AccelerationMode accelerationMode) | 42 Canvas2DImageBufferSurface(const IntSize& size, int msaaSampleCount, Opacity
Mode opacityMode, Canvas2DLayerBridge::AccelerationMode accelerationMode) |
| 43 : ImageBufferSurface(size, opacityMode) | 43 : ImageBufferSurface(size, opacityMode) |
| 44 , m_layerBridge(Canvas2DLayerBridge::create(size, msaaSampleCount, opaci
tyMode, accelerationMode)) | 44 , m_layerBridge(Canvas2DLayerBridge::create(size, msaaSampleCount, opaci
tyMode, accelerationMode)) |
| 45 { | 45 { |
| 46 init(); | |
| 47 } | |
| 48 | |
| 49 Canvas2DImageBufferSurface(PassRefPtr<Canvas2DLayerBridge> bridge, const Int
Size& size) | |
| 50 : ImageBufferSurface(size, bridge->opacityMode()) | |
| 51 , m_layerBridge(std::move(bridge)) | |
| 52 { | |
| 53 init(); | |
| 54 } | |
| 55 | |
| 56 void init() | |
| 57 { | |
| 58 clear(); | 46 clear(); |
| 59 if (isValid()) | 47 if (isValid()) |
| 60 m_layerBridge->flush(); | 48 m_layerBridge->flush(); |
| 61 } | 49 } |
| 62 | 50 |
| 63 ~Canvas2DImageBufferSurface() override | 51 ~Canvas2DImageBufferSurface() override |
| 64 { | 52 { |
| 65 if (m_layerBridge) | 53 if (m_layerBridge) |
| 66 m_layerBridge->beginDestruction(); | 54 m_layerBridge->beginDestruction(); |
| 67 } | 55 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 85 bool writePixels(const SkImageInfo& origInfo, const void* pixels, size_t row
Bytes, int x, int y) override { return m_layerBridge->writePixels(origInfo, pixe
ls, rowBytes, x, y); } | 73 bool writePixels(const SkImageInfo& origInfo, const void* pixels, size_t row
Bytes, int x, int y) override { return m_layerBridge->writePixels(origInfo, pixe
ls, rowBytes, x, y); } |
| 86 | 74 |
| 87 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint hint, SnapshotReason r
eason) override { return m_layerBridge->newImageSnapshot(hint, reason); } | 75 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint hint, SnapshotReason r
eason) override { return m_layerBridge->newImageSnapshot(hint, reason); } |
| 88 private: | 76 private: |
| 89 RefPtr<Canvas2DLayerBridge> m_layerBridge; | 77 RefPtr<Canvas2DLayerBridge> m_layerBridge; |
| 90 }; | 78 }; |
| 91 | 79 |
| 92 } // namespace blink | 80 } // namespace blink |
| 93 | 81 |
| 94 #endif | 82 #endif |
| OLD | NEW |