| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_SURFACE_TRANSPORT_DIB_H_ | 5 #ifndef UI_SURFACE_TRANSPORT_DIB_H_ |
| 6 #define UI_SURFACE_TRANSPORT_DIB_H_ | 6 #define UI_SURFACE_TRANSPORT_DIB_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/surface/surface_export.h" | 14 #include "ui/surface/surface_export.h" |
| 15 | 15 |
| 16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 17 #include <windows.h> | 17 #include <windows.h> |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #include <memory> | |
| 21 | |
| 22 class SkCanvas; | 20 class SkCanvas; |
| 23 | 21 |
| 24 // ----------------------------------------------------------------------------- | 22 // ----------------------------------------------------------------------------- |
| 25 // A TransportDIB is a block of memory that is used to transport pixels | 23 // A TransportDIB is a block of memory that is used to transport pixels |
| 26 // between processes: from the renderer process to the browser, and | 24 // between processes: from the renderer process to the browser, and |
| 27 // between renderer and plugin processes. | 25 // between renderer and plugin processes. |
| 28 // ----------------------------------------------------------------------------- | 26 // ----------------------------------------------------------------------------- |
| 29 class SURFACE_EXPORT TransportDIB { | 27 class SURFACE_EXPORT TransportDIB { |
| 30 public: | 28 public: |
| 31 ~TransportDIB(); | 29 ~TransportDIB(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // pointer will be owned by the caller. The bitmap will be of the given size, | 64 // pointer will be owned by the caller. The bitmap will be of the given size, |
| 67 // which should fit inside this memory. Bitmaps returned will be either | 65 // which should fit inside this memory. Bitmaps returned will be either |
| 68 // opaque or have premultiplied alpha. | 66 // opaque or have premultiplied alpha. |
| 69 // | 67 // |
| 70 // On POSIX, this |TransportDIB| will be mapped if not already. On Windows, | 68 // On POSIX, this |TransportDIB| will be mapped if not already. On Windows, |
| 71 // this |TransportDIB| will NOT be mapped and should not be mapped prior, | 69 // this |TransportDIB| will NOT be mapped and should not be mapped prior, |
| 72 // because PlatformCanvas will map the file internally. | 70 // because PlatformCanvas will map the file internally. |
| 73 // | 71 // |
| 74 // Will return NULL on allocation failure. This could be because the image | 72 // Will return NULL on allocation failure. This could be because the image |
| 75 // is too large to map into the current process' address space. | 73 // is too large to map into the current process' address space. |
| 76 std::unique_ptr<SkCanvas> GetPlatformCanvas(int w, int h, bool opaque); | 74 SkCanvas* GetPlatformCanvas(int w, int h, bool opaque); |
| 77 | 75 |
| 78 // Map the DIB into the current process if it is not already. This is used to | 76 // Map the DIB into the current process if it is not already. This is used to |
| 79 // map a DIB that has already been created. Returns true if the DIB is mapped. | 77 // map a DIB that has already been created. Returns true if the DIB is mapped. |
| 80 bool Map(); | 78 bool Map(); |
| 81 | 79 |
| 82 // Return a pointer to the shared memory. | 80 // Return a pointer to the shared memory. |
| 83 void* memory() const; | 81 void* memory() const; |
| 84 | 82 |
| 85 // Return the maximum size of the shared memory. This is not the amount of | 83 // Return the maximum size of the shared memory. This is not the amount of |
| 86 // data which is valid, you have to know that via other means, this is simply | 84 // data which is valid, you have to know that via other means, this is simply |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 | 96 |
| 99 explicit TransportDIB(base::SharedMemoryHandle dib); | 97 explicit TransportDIB(base::SharedMemoryHandle dib); |
| 100 base::SharedMemory shared_memory_; | 98 base::SharedMemory shared_memory_; |
| 101 uint32_t sequence_num_; | 99 uint32_t sequence_num_; |
| 102 size_t size_; // length, in bytes | 100 size_t size_; // length, in bytes |
| 103 | 101 |
| 104 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 102 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
| 105 }; | 103 }; |
| 106 | 104 |
| 107 #endif // UI_SURFACE_TRANSPORT_DIB_H_ | 105 #endif // UI_SURFACE_TRANSPORT_DIB_H_ |
| OLD | NEW |