Dirty rects always contain full tiles with delegated rendering.
[chromium-blink-merge.git] / gin / array_buffer.h
blob3169fd021b3b4c2f51b39772f076f5f9b41ac96c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GIN_ARRAY_BUFFER_H_
6 #define GIN_ARRAY_BUFFER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "gin/converter.h"
12 #include "v8/include/v8.h"
14 namespace gin {
16 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
17 public:
18 virtual void* Allocate(size_t length) OVERRIDE;
19 virtual void* AllocateUninitialized(size_t length) OVERRIDE;
20 virtual void Free(void* data, size_t length) OVERRIDE;
22 static ArrayBufferAllocator* SharedInstance();
25 class ArrayBuffer {
26 public:
27 ArrayBuffer();
28 explicit ArrayBuffer(v8::Isolate* isolate);
29 ArrayBuffer(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
30 ~ArrayBuffer();
32 void* bytes() const { return bytes_; }
33 size_t num_bytes() const { return num_bytes_; }
35 private:
36 class Private;
38 scoped_refptr<Private> private_;
39 void* bytes_;
40 size_t num_bytes_;
42 DISALLOW_COPY(ArrayBuffer);
45 template<>
46 struct Converter<ArrayBuffer> {
47 static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
48 ArrayBuffer* out);
51 class ArrayBufferView {
52 public:
53 ArrayBufferView();
54 ArrayBufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view);
55 ~ArrayBufferView();
57 void* bytes() const {
58 return static_cast<uint8_t*>(array_buffer_.bytes()) + offset_;
60 size_t num_bytes() const { return num_bytes_; }
62 private:
63 ArrayBuffer array_buffer_;
64 size_t offset_;
65 size_t num_bytes_;
67 DISALLOW_COPY(ArrayBufferView);
70 template<>
71 struct Converter<ArrayBufferView> {
72 static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
73 ArrayBufferView* out);
76 } // namespace gin
78 #endif // GIN_ARRAY_BUFFER_H_