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