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 CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "ppapi/c/ppb_graphics_2d.h" | 14 #include "ppapi/c/ppb_graphics_2d.h" |
15 #include "ppapi/host/host_message_context.h" | 15 #include "ppapi/host/host_message_context.h" |
16 #include "ppapi/host/resource_host.h" | 16 #include "ppapi/host/resource_host.h" |
17 #include "third_party/WebKit/public/platform/WebCanvas.h" | 17 #include "third_party/WebKit/public/platform/WebCanvas.h" |
18 #include "ui/events/latency_info.h" | 18 #include "ui/events/latency_info.h" |
19 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
20 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
| 23 class SharedBitmap; |
23 class SingleReleaseCallback; | 24 class SingleReleaseCallback; |
24 class TextureMailbox; | 25 class TextureMailbox; |
25 } | 26 } |
26 | 27 |
27 namespace gfx { | 28 namespace gfx { |
28 class Rect; | 29 class Rect; |
29 } | 30 } |
30 | 31 |
31 namespace ppapi { | 32 namespace ppapi { |
32 struct ViewData; | 33 struct ViewData; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // These messages are used to send Flush callbacks to the plugin. | 79 // These messages are used to send Flush callbacks to the plugin. |
79 void ViewInitiatedPaint(); | 80 void ViewInitiatedPaint(); |
80 void ViewFlushedPaint(); | 81 void ViewFlushedPaint(); |
81 | 82 |
82 void SetScale(float scale); | 83 void SetScale(float scale); |
83 float GetScale() const; | 84 float GetScale() const; |
84 bool IsAlwaysOpaque() const; | 85 bool IsAlwaysOpaque() const; |
85 PPB_ImageData_Impl* ImageData(); | 86 PPB_ImageData_Impl* ImageData(); |
86 gfx::Size Size() const; | 87 gfx::Size Size() const; |
87 | 88 |
| 89 void ClearCache(); |
| 90 |
88 private: | 91 private: |
89 PepperGraphics2DHost(RendererPpapiHost* host, | 92 PepperGraphics2DHost(RendererPpapiHost* host, |
90 PP_Instance instance, | 93 PP_Instance instance, |
91 PP_Resource resource); | 94 PP_Resource resource); |
92 | 95 |
93 bool Init(int width, | 96 bool Init(int width, |
94 int height, | 97 int height, |
95 bool is_always_opaque, | 98 bool is_always_opaque, |
96 scoped_refptr<PPB_ImageData_Impl> backing_store); | 99 scoped_refptr<PPB_ImageData_Impl> backing_store); |
97 | 100 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 153 |
151 // Scale |op_rect| to logical pixels, taking care to include partially- | 154 // Scale |op_rect| to logical pixels, taking care to include partially- |
152 // covered logical pixels (aka DIPs). Also scale optional |delta| to logical | 155 // covered logical pixels (aka DIPs). Also scale optional |delta| to logical |
153 // pixels as well for scrolling cases. Returns false for scrolling cases where | 156 // pixels as well for scrolling cases. Returns false for scrolling cases where |
154 // scaling either |op_rect| or |delta| would require scrolling to fall back to | 157 // scaling either |op_rect| or |delta| would require scrolling to fall back to |
155 // invalidation due to rounding errors, true otherwise. | 158 // invalidation due to rounding errors, true otherwise. |
156 static bool ConvertToLogicalPixels(float scale, | 159 static bool ConvertToLogicalPixels(float scale, |
157 gfx::Rect* op_rect, | 160 gfx::Rect* op_rect, |
158 gfx::Point* delta); | 161 gfx::Point* delta); |
159 | 162 |
| 163 void ReleaseCallback(scoped_ptr<cc::SharedBitmap> bitmap, |
| 164 const gfx::Size& bitmap_size, |
| 165 uint32 sync_point, |
| 166 bool lost_resource); |
| 167 |
160 RendererPpapiHost* renderer_ppapi_host_; | 168 RendererPpapiHost* renderer_ppapi_host_; |
161 | 169 |
162 scoped_refptr<PPB_ImageData_Impl> image_data_; | 170 scoped_refptr<PPB_ImageData_Impl> image_data_; |
163 | 171 |
164 // Non-owning pointer to the plugin instance this context is currently bound | 172 // Non-owning pointer to the plugin instance this context is currently bound |
165 // to, if any. If the context is currently unbound, this will be NULL. | 173 // to, if any. If the context is currently unbound, this will be NULL. |
166 PepperPluginInstanceImpl* bound_instance_; | 174 PepperPluginInstanceImpl* bound_instance_; |
167 | 175 |
168 // Keeps track of all drawing commands queued before a Flush call. | 176 // Keeps track of all drawing commands queued before a Flush call. |
169 struct QueuedOperation; | 177 struct QueuedOperation; |
(...skipping 16 matching lines...) Expand all Loading... |
186 // DIP | 194 // DIP |
187 float scale_; | 195 float scale_; |
188 | 196 |
189 ppapi::host::ReplyMessageContext flush_reply_context_; | 197 ppapi::host::ReplyMessageContext flush_reply_context_; |
190 | 198 |
191 bool is_running_in_process_; | 199 bool is_running_in_process_; |
192 | 200 |
193 bool texture_mailbox_modified_; | 201 bool texture_mailbox_modified_; |
194 bool is_using_texture_layer_; | 202 bool is_using_texture_layer_; |
195 | 203 |
| 204 // This is a bitmap that was recently released by the compositor and may be |
| 205 // used to transfer bytes to the compositor again. |
| 206 scoped_ptr<cc::SharedBitmap> cached_bitmap_; |
| 207 gfx::Size cached_bitmap_size_; |
| 208 |
196 friend class PepperGraphics2DHostTest; | 209 friend class PepperGraphics2DHostTest; |
197 DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost); | 210 DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost); |
198 }; | 211 }; |
199 | 212 |
200 } // namespace content | 213 } // namespace content |
201 | 214 |
202 #endif // CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ | 215 #endif // CONTENT_RENDERER_PEPPER_PEPPER_GRAPHICS_2D_HOST_H_ |
OLD | NEW |