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

Side by Side Diff: webkit/glue/plugins/pepper_graphics_2d.cc

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « webkit/glue/plugins/pepper_graphics_2d.h ('k') | webkit/glue/plugins/pepper_graphics_3d.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "webkit/glue/plugins/pepper_graphics_2d.h" 5 #include "webkit/glue/plugins/pepper_graphics_2d.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "gfx/blit.h" 12 #include "gfx/blit.h"
13 #include "gfx/point.h" 13 #include "gfx/point.h"
14 #include "gfx/rect.h" 14 #include "gfx/rect.h"
15 #include "skia/ext/platform_canvas.h" 15 #include "skia/ext/platform_canvas.h"
16 #include "ppapi/c/pp_errors.h" 16 #include "ppapi/c/pp_errors.h"
17 #include "ppapi/c/pp_module.h" 17 #include "ppapi/c/pp_module.h"
18 #include "ppapi/c/pp_rect.h" 18 #include "ppapi/c/pp_rect.h"
19 #include "ppapi/c/pp_resource.h" 19 #include "ppapi/c/pp_resource.h"
20 #include "ppapi/c/ppb_graphics_2d.h" 20 #include "ppapi/c/ppb_graphics_2d.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "webkit/glue/plugins/pepper_common.h"
22 #include "webkit/glue/plugins/pepper_image_data.h" 23 #include "webkit/glue/plugins/pepper_image_data.h"
23 #include "webkit/glue/plugins/pepper_plugin_instance.h" 24 #include "webkit/glue/plugins/pepper_plugin_instance.h"
24 #include "webkit/glue/plugins/pepper_plugin_module.h" 25 #include "webkit/glue/plugins/pepper_plugin_module.h"
25 26
26 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
27 #include "base/mac_util.h" 28 #include "base/mac_util.h"
28 #include "base/mac/scoped_cftyperef.h" 29 #include "base/mac/scoped_cftyperef.h"
29 #endif 30 #endif
30 31
31 namespace pepper { 32 namespace pepper {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 static_cast<int>(src_rect.fTop + y)), 106 static_cast<int>(src_rect.fTop + y)),
106 src_rect.width(), 107 src_rect.width(),
107 dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft), 108 dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft),
108 static_cast<int>(dest_rect.fTop + y))); 109 static_cast<int>(dest_rect.fTop + y)));
109 } 110 }
110 } 111 }
111 } 112 }
112 113
113 PP_Resource Create(PP_Module module_id, 114 PP_Resource Create(PP_Module module_id,
114 const PP_Size* size, 115 const PP_Size* size,
115 bool is_always_opaque) { 116 PP_Bool is_always_opaque) {
116 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); 117 PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
117 if (!module) 118 if (!module)
118 return 0; 119 return 0;
119 120
120 scoped_refptr<Graphics2D> context(new Graphics2D(module)); 121 scoped_refptr<Graphics2D> context(new Graphics2D(module));
121 if (!context->Init(size->width, size->height, is_always_opaque)) 122 if (!context->Init(size->width, size->height, PPBoolToBool(is_always_opaque)))
122 return 0; 123 return 0;
123 return context->GetReference(); 124 return context->GetReference();
124 } 125 }
125 126
126 bool IsGraphics2D(PP_Resource resource) { 127 PP_Bool IsGraphics2D(PP_Resource resource) {
127 return !!Resource::GetAs<Graphics2D>(resource); 128 return BoolToPPBool(!!Resource::GetAs<Graphics2D>(resource));
128 } 129 }
129 130
130 bool Describe(PP_Resource graphics_2d, 131 PP_Bool Describe(PP_Resource graphics_2d,
131 PP_Size* size, 132 PP_Size* size,
132 bool* is_always_opaque) { 133 PP_Bool* is_always_opaque) {
133 scoped_refptr<Graphics2D> context( 134 scoped_refptr<Graphics2D> context(
134 Resource::GetAs<Graphics2D>(graphics_2d)); 135 Resource::GetAs<Graphics2D>(graphics_2d));
135 if (!context) 136 if (!context)
136 return false; 137 return PP_FALSE;
137 return context->Describe(size, is_always_opaque); 138 return context->Describe(size, is_always_opaque);
138 } 139 }
139 140
140 void PaintImageData(PP_Resource graphics_2d, 141 void PaintImageData(PP_Resource graphics_2d,
141 PP_Resource image_data, 142 PP_Resource image_data,
142 const PP_Point* top_left, 143 const PP_Point* top_left,
143 const PP_Rect* src_rect) { 144 const PP_Rect* src_rect) {
144 scoped_refptr<Graphics2D> context( 145 scoped_refptr<Graphics2D> context(
145 Resource::GetAs<Graphics2D>(graphics_2d)); 146 Resource::GetAs<Graphics2D>(graphics_2d));
146 if (context) 147 if (context)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 image_data_ = new ImageData(module()); 236 image_data_ = new ImageData(module());
236 if (!image_data_->Init(ImageData::GetNativeImageDataFormat(), width, height, 237 if (!image_data_->Init(ImageData::GetNativeImageDataFormat(), width, height,
237 true) || !image_data_->Map()) { 238 true) || !image_data_->Map()) {
238 image_data_ = NULL; 239 image_data_ = NULL;
239 return false; 240 return false;
240 } 241 }
241 is_always_opaque_ = is_always_opaque; 242 is_always_opaque_ = is_always_opaque;
242 return true; 243 return true;
243 } 244 }
244 245
245 bool Graphics2D::Describe(PP_Size* size, bool* is_always_opaque) { 246 PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) {
246 size->width = image_data_->width(); 247 size->width = image_data_->width();
247 size->height = image_data_->height(); 248 size->height = image_data_->height();
248 *is_always_opaque = false; // TODO(brettw) implement this. 249 *is_always_opaque = PP_FALSE; // TODO(brettw) implement this.
249 return true; 250 return PP_TRUE;
250 } 251 }
251 252
252 void Graphics2D::PaintImageData(PP_Resource image_data, 253 void Graphics2D::PaintImageData(PP_Resource image_data,
253 const PP_Point* top_left, 254 const PP_Point* top_left,
254 const PP_Rect* src_rect) { 255 const PP_Rect* src_rect) {
255 if (!top_left) 256 if (!top_left)
256 return; 257 return;
257 258
258 scoped_refptr<ImageData> image_resource( 259 scoped_refptr<ImageData> image_resource(
259 Resource::GetAs<ImageData>(image_data)); 260 Resource::GetAs<ImageData>(image_data));
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 data.Execute(PP_OK); 628 data.Execute(PP_OK);
628 } 629 }
629 630
630 bool Graphics2D::HasPendingFlush() const { 631 bool Graphics2D::HasPendingFlush() const {
631 return !unpainted_flush_callback_.is_null() || 632 return !unpainted_flush_callback_.is_null() ||
632 !painted_flush_callback_.is_null() || 633 !painted_flush_callback_.is_null() ||
633 offscreen_flush_pending_; 634 offscreen_flush_pending_;
634 } 635 }
635 636
636 } // namespace pepper 637 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_graphics_2d.h ('k') | webkit/glue/plugins/pepper_graphics_3d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698