Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: content/renderer/pepper/ppb_image_data_impl.h

Issue 61813003: Allow PPB_ImageData_Impl to be created in a way that is compatible with unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 virtual SkCanvas* GetCanvas() = 0; 47 virtual SkCanvas* GetCanvas() = 0;
48 virtual const SkBitmap* GetMappedBitmap() const = 0; 48 virtual const SkBitmap* GetMappedBitmap() const = 0;
49 }; 49 };
50 50
51 // If you call this constructor, you must also call Init before use. Normally 51 // If you call this constructor, you must also call Init before use. Normally
52 // you should use the static Create function, but this constructor is needed 52 // you should use the static Create function, but this constructor is needed
53 // for some internal uses of ImageData (like Graphics2D). 53 // for some internal uses of ImageData (like Graphics2D).
54 PPB_ImageData_Impl(PP_Instance instance, 54 PPB_ImageData_Impl(PP_Instance instance,
55 PPB_ImageData_Shared::ImageDataType type); 55 PPB_ImageData_Shared::ImageDataType type);
56 56
57 // Constructor used for unittests. The ImageData is always allocated locally.
58 struct ForTest {};
59 PPB_ImageData_Impl(PP_Instance instance,
60 ForTest);
61
57 bool Init(PP_ImageDataFormat format, 62 bool Init(PP_ImageDataFormat format,
58 int width, int height, 63 int width, int height,
59 bool init_to_zero); 64 bool init_to_zero);
60 65
61 static PP_Resource Create(PP_Instance pp_instance, 66 static PP_Resource Create(PP_Instance pp_instance,
62 PPB_ImageData_Shared::ImageDataType type, 67 PPB_ImageData_Shared::ImageDataType type,
63 PP_ImageDataFormat format, 68 PP_ImageDataFormat format,
64 const PP_Size& size, 69 const PP_Size& size,
65 PP_Bool init_to_zero); 70 PP_Bool init_to_zero);
66 71
(...skipping 28 matching lines...) Expand all
95 PP_ImageDataFormat format_; 100 PP_ImageDataFormat format_;
96 int width_; 101 int width_;
97 int height_; 102 int height_;
98 scoped_ptr<Backend> backend_; 103 scoped_ptr<Backend> backend_;
99 104
100 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl); 105 DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl);
101 }; 106 };
102 107
103 class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend { 108 class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend {
104 public: 109 public:
105 ImageDataPlatformBackend(); 110 // |is_browser_allocated| indicates whether the backing shared memory should
111 // be allocated by the browser process.
112 ImageDataPlatformBackend(bool is_browser_allocated);
106 virtual ~ImageDataPlatformBackend(); 113 virtual ~ImageDataPlatformBackend();
107 114
108 // PPB_ImageData_Impl::Backend implementation. 115 // PPB_ImageData_Impl::Backend implementation.
109 virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, 116 virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format,
110 int width, int height, bool init_to_zero) OVERRIDE; 117 int width, int height, bool init_to_zero) OVERRIDE;
111 virtual bool IsMapped() const OVERRIDE; 118 virtual bool IsMapped() const OVERRIDE;
112 virtual TransportDIB* GetTransportDIB() const OVERRIDE; 119 virtual TransportDIB* GetTransportDIB() const OVERRIDE;
113 virtual void* Map() OVERRIDE; 120 virtual void* Map() OVERRIDE;
114 virtual void Unmap() OVERRIDE; 121 virtual void Unmap() OVERRIDE;
115 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; 122 virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
116 virtual SkCanvas* GetPlatformCanvas() OVERRIDE; 123 virtual SkCanvas* GetPlatformCanvas() OVERRIDE;
117 virtual SkCanvas* GetCanvas() OVERRIDE; 124 virtual SkCanvas* GetCanvas() OVERRIDE;
118 virtual const SkBitmap* GetMappedBitmap() const OVERRIDE; 125 virtual const SkBitmap* GetMappedBitmap() const OVERRIDE;
119 126
120 private: 127 private:
121 // This will be NULL before initialization, and if this PPB_ImageData_Impl is 128 // This will be NULL before initialization, and if this PPB_ImageData_Impl is
122 // swapped with another. 129 // swapped with another.
123 int width_; 130 int width_;
124 int height_; 131 int height_;
125 scoped_ptr<TransportDIB> dib_; 132 scoped_ptr<TransportDIB> dib_;
126 133
134 bool is_browser_allocated_;
135
127 // When the device is mapped, this is the image. Null when umapped. 136 // When the device is mapped, this is the image. Null when umapped.
128 scoped_ptr<SkCanvas> mapped_canvas_; 137 scoped_ptr<SkCanvas> mapped_canvas_;
129 138
130 DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend); 139 DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend);
131 }; 140 };
132 141
133 class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { 142 class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend {
134 public: 143 public:
135 ImageDataSimpleBackend(); 144 ImageDataSimpleBackend();
136 virtual ~ImageDataSimpleBackend(); 145 virtual ~ImageDataSimpleBackend();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 PPB_ImageData_Impl* image_data_; 201 PPB_ImageData_Impl* image_data_;
193 bool is_valid_; 202 bool is_valid_;
194 bool needs_unmap_; 203 bool needs_unmap_;
195 204
196 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper); 205 DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper);
197 }; 206 };
198 207
199 } // namespace content 208 } // namespace content
200 209
201 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_ 210 #endif // CONTENT_RENDERER_PEPPER_PPB_IMAGE_DATA_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_graphics_2d_host.cc ('k') | content/renderer/pepper/ppb_image_data_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698