| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace | 96 } // namespace |
| 97 | 97 |
| 98 // If either of these pointers is non-null, both must be valid and point to | 98 // If either of these pointers is non-null, both must be valid and point to |
| 99 // bitmaps of the same size. | 99 // bitmaps of the same size. |
| 100 class TransparencyWin::OwnedBuffers { | 100 class TransparencyWin::OwnedBuffers { |
| 101 public: | 101 public: |
| 102 OwnedBuffers(const IntSize& size, bool needReferenceBuffer) | 102 OwnedBuffers(const IntSize& size, bool needReferenceBuffer) |
| 103 { | 103 { |
| 104 m_destBitmap = ImageBuffer::create(size, 1); | 104 m_destBitmap = ImageBuffer::create(size); |
| 105 | 105 |
| 106 if (needReferenceBuffer) { | 106 if (needReferenceBuffer) { |
| 107 m_referenceBitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(
), size.height()); | 107 m_referenceBitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(
), size.height()); |
| 108 m_referenceBitmap.allocPixels(); | 108 m_referenceBitmap.allocPixels(); |
| 109 m_referenceBitmap.eraseARGB(0, 0, 0, 0); | 109 m_referenceBitmap.eraseARGB(0, 0, 0, 0); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 ImageBuffer* destBitmap() { return m_destBitmap.get(); } | 113 ImageBuffer* destBitmap() { return m_destBitmap.get(); } |
| 114 | 114 |
| 115 // This bitmap will be empty if you don't specify needReferenceBuffer to the | 115 // This bitmap will be empty if you don't specify needReferenceBuffer to the |
| 116 // constructor. | 116 // constructor. |
| 117 SkBitmap* referenceBitmap() { return &m_referenceBitmap; } | 117 SkBitmap* referenceBitmap() { return &m_referenceBitmap; } |
| 118 | 118 |
| 119 // Returns whether the current layer will fix a buffer of the given size. | 119 // Returns whether the current layer will fix a buffer of the given size. |
| 120 bool canHandleSize(const IntSize& size) const | 120 bool canHandleSize(const IntSize& size) const |
| 121 { | 121 { |
| 122 return m_destBitmap->internalSize().width() >= size.width() && m_destBit
map->internalSize().height() >= size.height(); | 122 return m_destBitmap->size().width() >= size.width() && m_destBitmap->siz
e().height() >= size.height(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 // The destination bitmap we're drawing into. | 126 // The destination bitmap we're drawing into. |
| 127 OwnPtr<ImageBuffer> m_destBitmap; | 127 OwnPtr<ImageBuffer> m_destBitmap; |
| 128 | 128 |
| 129 // This could be an ImageBuffer but this is an optimization. Since this is | 129 // This could be an ImageBuffer but this is an optimization. Since this is |
| 130 // only ever used as a reference, we don't need to make a full | 130 // only ever used as a reference, we don't need to make a full |
| 131 // PlatformCanvas using Skia on Windows. Just allocating a regular SkBitmap | 131 // PlatformCanvas using Skia on Windows. Just allocating a regular SkBitmap |
| 132 // is much faster since it's just a Malloc rather than a GDI call. | 132 // is much faster since it's just a Malloc rather than a GDI call. |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 505 |
| 506 SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->layerBitmap(Graphics
Context::ReadWrite)); | 506 SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->layerBitmap(Graphics
Context::ReadWrite)); |
| 507 for (int y = 0; y < m_layerSize.height(); y++) { | 507 for (int y = 0; y < m_layerSize.height(); y++) { |
| 508 uint32_t* row = bitmap.getAddr32(0, y); | 508 uint32_t* row = bitmap.getAddr32(0, y); |
| 509 for (int x = 0; x < m_layerSize.width(); x++) | 509 for (int x = 0; x < m_layerSize.width(); x++) |
| 510 row[x] |= 0xFF000000; | 510 row[x] |= 0xFF000000; |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 | 513 |
| 514 } // namespace WebCore | 514 } // namespace WebCore |
| OLD | NEW |