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

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

Issue 2900003: Chrome side of converting enums to uppercase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months 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) 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_device_context_2d.h" 5 #include "webkit/glue/plugins/pepper_device_context_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"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (!context.get()) 117 if (!context.get())
118 return false; 118 return false;
119 return context->ReplaceContents(image); 119 return context->ReplaceContents(image);
120 } 120 }
121 121
122 int32_t Flush(PP_Resource device_context, 122 int32_t Flush(PP_Resource device_context,
123 PP_CompletionCallback callback) { 123 PP_CompletionCallback callback) {
124 scoped_refptr<DeviceContext2D> context( 124 scoped_refptr<DeviceContext2D> context(
125 Resource::GetAs<DeviceContext2D>(device_context)); 125 Resource::GetAs<DeviceContext2D>(device_context));
126 if (!context.get()) 126 if (!context.get())
127 return PP_Error_BadResource; 127 return PP_ERROR_BADRESOURCE;
128 return context->Flush(callback); 128 return context->Flush(callback);
129 } 129 }
130 130
131 const PPB_DeviceContext2D ppb_devicecontext2d = { 131 const PPB_DeviceContext2D ppb_devicecontext2d = {
132 &Create, 132 &Create,
133 &IsDeviceContext2D, 133 &IsDeviceContext2D,
134 &Describe, 134 &Describe,
135 &PaintImageData, 135 &PaintImageData,
136 &Scroll, 136 &Scroll,
137 &ReplaceContents, 137 &ReplaceContents,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 QueuedOperation operation(QueuedOperation::REPLACE); 273 QueuedOperation operation(QueuedOperation::REPLACE);
274 operation.replace_image = image_resource; 274 operation.replace_image = image_resource;
275 queued_operations_.push_back(operation); 275 queued_operations_.push_back(operation);
276 276
277 return true; 277 return true;
278 } 278 }
279 279
280 int32_t DeviceContext2D::Flush(const PP_CompletionCallback& callback) { 280 int32_t DeviceContext2D::Flush(const PP_CompletionCallback& callback) {
281 // Don't allow more than one pending flush at a time. 281 // Don't allow more than one pending flush at a time.
282 if (HasPendingFlush()) 282 if (HasPendingFlush())
283 return PP_Error_InProgress; 283 return PP_ERROR_INPROGRESS;
284 284
285 // TODO(brettw) check that the current thread is not the main one and 285 // TODO(brettw) check that the current thread is not the main one and
286 // implement blocking flushes in this case. 286 // implement blocking flushes in this case.
287 if (!callback.func) 287 if (!callback.func)
288 return PP_Error_BadArgument; 288 return PP_ERROR_BADARGUMENT;
289 289
290 gfx::Rect changed_rect; 290 gfx::Rect changed_rect;
291 for (size_t i = 0; i < queued_operations_.size(); i++) { 291 for (size_t i = 0; i < queued_operations_.size(); i++) {
292 QueuedOperation& operation = queued_operations_[i]; 292 QueuedOperation& operation = queued_operations_[i];
293 gfx::Rect op_rect; 293 gfx::Rect op_rect;
294 switch (operation.type) { 294 switch (operation.type) {
295 case QueuedOperation::PAINT: 295 case QueuedOperation::PAINT:
296 ExecutePaintImageData(operation.paint_image.get(), 296 ExecutePaintImageData(operation.paint_image.get(),
297 operation.paint_x, operation.paint_y, 297 operation.paint_x, operation.paint_y,
298 operation.paint_src_rect, 298 operation.paint_src_rect,
(...skipping 22 matching lines...) Expand all
321 visible_changed_rect = bound_instance_->clip().Intersect(changed_rect); 321 visible_changed_rect = bound_instance_->clip().Intersect(changed_rect);
322 322
323 if (bound_instance_ && !visible_changed_rect.IsEmpty()) { 323 if (bound_instance_ && !visible_changed_rect.IsEmpty()) {
324 unpainted_flush_callback_.Set(callback); 324 unpainted_flush_callback_.Set(callback);
325 bound_instance_->InvalidateRect(visible_changed_rect); 325 bound_instance_->InvalidateRect(visible_changed_rect);
326 } else { 326 } else {
327 // There's nothing visible to invalidate so just schedule the callback to 327 // There's nothing visible to invalidate so just schedule the callback to
328 // execute in the next round of the message loop. 328 // execute in the next round of the message loop.
329 ScheduleOffscreenCallback(FlushCallbackData(callback)); 329 ScheduleOffscreenCallback(FlushCallbackData(callback));
330 } 330 }
331 return PP_Error_WouldBlock; 331 return PP_ERROR_WOULDBLOCK;
332 } 332 }
333 333
334 bool DeviceContext2D::ReadImageData(PP_Resource image, int32_t x, int32_t y) { 334 bool DeviceContext2D::ReadImageData(PP_Resource image, int32_t x, int32_t y) {
335 // Get and validate the image object to paint into. 335 // Get and validate the image object to paint into.
336 scoped_refptr<ImageData> image_resource(Resource::GetAs<ImageData>(image)); 336 scoped_refptr<ImageData> image_resource(Resource::GetAs<ImageData>(image));
337 if (!image_resource.get()) 337 if (!image_resource.get())
338 return false; 338 return false;
339 if (image_resource->format() != PP_IMAGEDATAFORMAT_BGRA_PREMUL) 339 if (image_resource->format() != PP_IMAGEDATAFORMAT_BGRA_PREMUL)
340 return false; // Must be in the right format. 340 return false; // Must be in the right format.
341 341
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 data.Execute(PP_OK); 534 data.Execute(PP_OK);
535 } 535 }
536 536
537 bool DeviceContext2D::HasPendingFlush() const { 537 bool DeviceContext2D::HasPendingFlush() const {
538 return !unpainted_flush_callback_.is_null() || 538 return !unpainted_flush_callback_.is_null() ||
539 !painted_flush_callback_.is_null() || 539 !painted_flush_callback_.is_null() ||
540 offscreen_flush_pending_; 540 offscreen_flush_pending_;
541 } 541 }
542 542
543 } // namespace pepper 543 } // namespace pepper
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_entrypoints.cc ('k') | webkit/glue/plugins/pepper_directory_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698