| 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 WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class PPB_ImageData_Impl; | 26 class PPB_ImageData_Impl; |
| 27 class PluginInstance; | 27 class PluginInstance; |
| 28 | 28 |
| 29 class PPB_Graphics2D_Impl : public ::ppapi::Resource, | 29 class PPB_Graphics2D_Impl : public ::ppapi::Resource, |
| 30 public ::ppapi::thunk::PPB_Graphics2D_API { | 30 public ::ppapi::thunk::PPB_Graphics2D_API { |
| 31 public: | 31 public: |
| 32 virtual ~PPB_Graphics2D_Impl(); | 32 virtual ~PPB_Graphics2D_Impl(); |
| 33 | 33 |
| 34 static PP_Resource Create(PP_Instance instance, | 34 static PP_Resource Create(PP_Instance instance, |
| 35 const PP_Size& size, | 35 const PP_Size& size, |
| 36 PP_Bool is_always_opaque); | 36 PP_Bool is_always_opaque, |
| 37 float scale); |
| 37 | 38 |
| 38 bool is_always_opaque() const { return is_always_opaque_; } | 39 bool is_always_opaque() const { return is_always_opaque_; } |
| 39 | 40 |
| 40 // Resource overrides. | 41 // Resource overrides. |
| 41 virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API(); | 42 virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API(); |
| 42 virtual void LastPluginRefWasDeleted() OVERRIDE; | 43 virtual void LastPluginRefWasDeleted() OVERRIDE; |
| 43 | 44 |
| 44 // PPB_Graphics2D functions. | 45 // PPB_Graphics2D functions. |
| 45 virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE; | 46 virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque) OVERRIDE; |
| 46 virtual void PaintImageData(PP_Resource image_data, | 47 virtual void PaintImageData(PP_Resource image_data, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 // These messages are used to send Flush callbacks to the plugin. | 69 // These messages are used to send Flush callbacks to the plugin. |
| 69 void ViewWillInitiatePaint(); | 70 void ViewWillInitiatePaint(); |
| 70 void ViewInitiatedPaint(); | 71 void ViewInitiatedPaint(); |
| 71 void ViewFlushedPaint(); | 72 void ViewFlushedPaint(); |
| 72 | 73 |
| 73 PPB_ImageData_Impl* image_data() { return image_data_.get(); } | 74 PPB_ImageData_Impl* image_data() { return image_data_.get(); } |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 explicit PPB_Graphics2D_Impl(PP_Instance instance); | 77 explicit PPB_Graphics2D_Impl(PP_Instance instance); |
| 77 | 78 |
| 78 bool Init(int width, int height, bool is_always_opaque); | 79 bool Init(int width, int height, bool is_always_opaque, float scale); |
| 79 | 80 |
| 80 // Tracks a call to flush that requires a callback. | 81 // Tracks a call to flush that requires a callback. |
| 81 class FlushCallbackData { | 82 class FlushCallbackData { |
| 82 public: | 83 public: |
| 83 FlushCallbackData() { | 84 FlushCallbackData() { |
| 84 Clear(); | 85 Clear(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 explicit FlushCallbackData( | 88 explicit FlushCallbackData( |
| 88 scoped_refptr< ::ppapi::TrackedCallback> callback) { | 89 scoped_refptr< ::ppapi::TrackedCallback> callback) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 178 |
| 178 // When doing offscreen flushes, we issue a task that issues the callback | 179 // When doing offscreen flushes, we issue a task that issues the callback |
| 179 // later. This is set when one of those tasks is pending so that we can | 180 // later. This is set when one of those tasks is pending so that we can |
| 180 // enforce the "only one pending flush at a time" constraint in the API. | 181 // enforce the "only one pending flush at a time" constraint in the API. |
| 181 bool offscreen_flush_pending_; | 182 bool offscreen_flush_pending_; |
| 182 | 183 |
| 183 // Set to true if the plugin declares that this device will always be opaque. | 184 // Set to true if the plugin declares that this device will always be opaque. |
| 184 // This allows us to do more optimized painting in some cases. | 185 // This allows us to do more optimized painting in some cases. |
| 185 bool is_always_opaque_; | 186 bool is_always_opaque_; |
| 186 | 187 |
| 188 // Set to the scale between what the plugin considers to be one pixel and one |
| 189 // DIP |
| 190 float scale_; |
| 191 |
| 187 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_; | 192 base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_; |
| 188 | 193 |
| 189 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl); | 194 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl); |
| 190 }; | 195 }; |
| 191 | 196 |
| 192 } // namespace ppapi | 197 } // namespace ppapi |
| 193 } // namespace webkit | 198 } // namespace webkit |
| 194 | 199 |
| 195 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ | 200 #endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_ |
| OLD | NEW |