| 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 "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/macros.h" |
| 9 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "build/build_config.h" |
| 10 #include "ui/surface/surface_export.h" | 14 #include "ui/surface/surface_export.h" |
| 11 | 15 |
| 12 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 13 #include <windows.h> | 17 #include <windows.h> |
| 14 #endif | 18 #endif |
| 15 | 19 |
| 16 class SkCanvas; | 20 class SkCanvas; |
| 17 | 21 |
| 18 // ----------------------------------------------------------------------------- | 22 // ----------------------------------------------------------------------------- |
| 19 // 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 36 | 40 |
| 37 // Create a new TransportDIB, returning NULL on failure. | 41 // Create a new TransportDIB, returning NULL on failure. |
| 38 // | 42 // |
| 39 // The size is the minimum size in bytes of the memory backing the transport | 43 // The size is the minimum size in bytes of the memory backing the transport |
| 40 // DIB (we may actually allocate more than that to give us better reuse when | 44 // DIB (we may actually allocate more than that to give us better reuse when |
| 41 // cached). | 45 // cached). |
| 42 // | 46 // |
| 43 // The sequence number is used to uniquely identify the transport DIB. It | 47 // The sequence number is used to uniquely identify the transport DIB. It |
| 44 // should be unique for all transport DIBs ever created in the same | 48 // should be unique for all transport DIBs ever created in the same |
| 45 // renderer. | 49 // renderer. |
| 46 static TransportDIB* Create(size_t size, uint32 sequence_num); | 50 static TransportDIB* Create(size_t size, uint32_t sequence_num); |
| 47 | 51 |
| 48 // Map the referenced transport DIB. The caller owns the returned object. | 52 // Map the referenced transport DIB. The caller owns the returned object. |
| 49 // Returns NULL on failure. | 53 // Returns NULL on failure. |
| 50 static TransportDIB* Map(Handle transport_dib); | 54 static TransportDIB* Map(Handle transport_dib); |
| 51 | 55 |
| 52 // Create a new |TransportDIB| with a handle to the shared memory. This | 56 // Create a new |TransportDIB| with a handle to the shared memory. This |
| 53 // always returns a valid pointer. The DIB is not mapped. | 57 // always returns a valid pointer. The DIB is not mapped. |
| 54 static TransportDIB* CreateWithHandle(Handle handle); | 58 static TransportDIB* CreateWithHandle(Handle handle); |
| 55 | 59 |
| 56 // Returns true if the handle is valid. | 60 // Returns true if the handle is valid. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 base::SharedMemory* shared_memory(); | 89 base::SharedMemory* shared_memory(); |
| 86 | 90 |
| 87 private: | 91 private: |
| 88 TransportDIB(); | 92 TransportDIB(); |
| 89 | 93 |
| 90 // Verifies that the dib can hold a canvas of the requested dimensions. | 94 // Verifies that the dib can hold a canvas of the requested dimensions. |
| 91 bool VerifyCanvasSize(int w, int h); | 95 bool VerifyCanvasSize(int w, int h); |
| 92 | 96 |
| 93 explicit TransportDIB(base::SharedMemoryHandle dib); | 97 explicit TransportDIB(base::SharedMemoryHandle dib); |
| 94 base::SharedMemory shared_memory_; | 98 base::SharedMemory shared_memory_; |
| 95 uint32 sequence_num_; | 99 uint32_t sequence_num_; |
| 96 size_t size_; // length, in bytes | 100 size_t size_; // length, in bytes |
| 97 | 101 |
| 98 DISALLOW_COPY_AND_ASSIGN(TransportDIB); | 102 DISALLOW_COPY_AND_ASSIGN(TransportDIB); |
| 99 }; | 103 }; |
| 100 | 104 |
| 101 #endif // UI_SURFACE_TRANSPORT_DIB_H_ | 105 #endif // UI_SURFACE_TRANSPORT_DIB_H_ |
| OLD | NEW |