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

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc

Issue 7215030: Don't copy the Graphics2D when binding a new one. This brings the (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugins/ppapi/ppb_graphics_2d_impl.h" 5 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 bounds.size.height = plugin_rect.height(); 467 bounds.size.height = plugin_rect.height();
468 468
469 CGContextClipToRect(canvas, bounds); 469 CGContextClipToRect(canvas, bounds);
470 470
471 // TODO(brettw) bug 56673: do a direct memcpy instead of going through CG 471 // TODO(brettw) bug 56673: do a direct memcpy instead of going through CG
472 // if the is_always_opaque_ flag is set. Must ensure bitmap is still clipped. 472 // if the is_always_opaque_ flag is set. Must ensure bitmap is still clipped.
473 473
474 CGContextDrawImage(canvas, bitmap_rect, image); 474 CGContextDrawImage(canvas, bitmap_rect, image);
475 CGContextRestoreGState(canvas); 475 CGContextRestoreGState(canvas);
476 #else 476 #else
477 SkRect sk_plugin_rect = SkRect::MakeXYWH(
478 SkIntToScalar(plugin_rect.origin().x()),
479 SkIntToScalar(plugin_rect.origin().y()),
480 SkIntToScalar(plugin_rect.width()),
481 SkIntToScalar(plugin_rect.height()));
482 canvas->save();
483 canvas->clipRect(sk_plugin_rect);
484
485 if (instance()->IsFullPagePlugin()) {
486 // When we're resizing a window with a full-frame plugin, the plugin may
487 // not yet have bound a new device, which will leave parts of the
488 // background exposed if the window is getting larger. We want this to
489 // show white (typically less jarring) rather than black or uninitialized.
490 // We don't do this for non-full-frame plugins since we specifically want
491 // the page background to show through.
492 canvas->save();
493 SkRect image_data_rect = SkRect::MakeXYWH(
494 SkIntToScalar(plugin_rect.origin().x()),
495 SkIntToScalar(plugin_rect.origin().y()),
496 SkIntToScalar(image_data_->width()),
497 SkIntToScalar(image_data_->height()));
498 canvas->clipRect(image_data_rect, SkRegion::kDifference_Op);
499
500 SkPaint paint;
501 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
502 paint.setColor(SK_ColorWHITE);
503 canvas->drawRect(sk_plugin_rect, paint);
504 canvas->restore();
505 }
506
477 SkPaint paint; 507 SkPaint paint;
478 if (is_always_opaque_) { 508 if (is_always_opaque_) {
479 // When we know the device is opaque, we can disable blending for slightly 509 // When we know the device is opaque, we can disable blending for slightly
480 // more optimized painting. 510 // more optimized painting.
481 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 511 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
482 } 512 }
483
484 canvas->save();
485 SkRect clip_rect = SkRect::MakeXYWH(SkIntToScalar(plugin_rect.origin().x()),
486 SkIntToScalar(plugin_rect.origin().y()),
487 SkIntToScalar(plugin_rect.width()),
488 SkIntToScalar(plugin_rect.height()));
489 canvas->clipRect(clip_rect);
490 canvas->drawBitmap(backing_bitmap, 513 canvas->drawBitmap(backing_bitmap,
491 SkIntToScalar(plugin_rect.x()), 514 SkIntToScalar(plugin_rect.x()),
492 SkIntToScalar(plugin_rect.y()), 515 SkIntToScalar(plugin_rect.y()),
493 &paint); 516 &paint);
494 canvas->restore(); 517 canvas->restore();
495 #endif 518 #endif
496 } 519 }
497 520
498 void PPB_Graphics2D_Impl::ViewInitiatedPaint() { 521 void PPB_Graphics2D_Impl::ViewInitiatedPaint() {
499 // Move any "unpainted" callback to the painted state. See 522 // Move any "unpainted" callback to the painted state. See
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 } 630 }
608 631
609 bool PPB_Graphics2D_Impl::HasPendingFlush() const { 632 bool PPB_Graphics2D_Impl::HasPendingFlush() const {
610 return !unpainted_flush_callback_.is_null() || 633 return !unpainted_flush_callback_.is_null() ||
611 !painted_flush_callback_.is_null() || 634 !painted_flush_callback_.is_null() ||
612 offscreen_flush_pending_; 635 offscreen_flush_pending_;
613 } 636 }
614 637
615 } // namespace ppapi 638 } // namespace ppapi
616 } // namespace webkit 639 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698