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

Side by Side Diff: content/browser/renderer_host/backing_store_gtk.cc

Issue 10821045: Lock SkBitmap's pixels before calling SkBitmap::getAddr32. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | 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) 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 #include "content/browser/renderer_host/backing_store_gtk.h" 5 #include "content/browser/renderer_host/backing_store_gtk.h"
6 6
7 #include <cairo-xlib.h> 7 #include <cairo-xlib.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/ipc.h> 10 #include <sys/ipc.h>
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 else 556 else
557 XDestroyImage(image); 557 XDestroyImage(image);
558 return false; 558 return false;
559 } 559 }
560 560
561 // The X image might have a different row stride, so iterate through 561 // The X image might have a different row stride, so iterate through
562 // it and copy each row out, only up to the pixels we're actually 562 // it and copy each row out, only up to the pixels we're actually
563 // using. This code assumes a visual mode where a pixel is 563 // using. This code assumes a visual mode where a pixel is
564 // represented using a 32-bit unsigned int, with a byte per component. 564 // represented using a 32-bit unsigned int, with a byte per component.
565 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); 565 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
566 SkAutoLockPixels alp(bitmap);
567
566 for (int y = 0; y < height; y++) { 568 for (int y = 0; y < height; y++) {
567 const uint32* src_row = reinterpret_cast<uint32*>( 569 const uint32* src_row = reinterpret_cast<uint32*>(
568 &image->data[image->bytes_per_line * y]); 570 &image->data[image->bytes_per_line * y]);
569 uint32* dest_row = bitmap.getAddr32(0, y); 571 uint32* dest_row = bitmap.getAddr32(0, y);
570 for (int x = 0; x < width; ++x, ++dest_row) { 572 for (int x = 0; x < width; ++x, ++dest_row) {
571 // Force alpha to be 0xff, because otherwise it causes rendering problems. 573 // Force alpha to be 0xff, because otherwise it causes rendering problems.
572 *dest_row = src_row[x] | 0xff000000; 574 *dest_row = src_row[x] | 0xff000000;
573 } 575 }
574 } 576 }
575 577
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 659
658 cairo_identity_matrix(cr); 660 cairo_identity_matrix(cr);
659 661
660 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height()); 662 cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
661 cairo_fill(cr); 663 cairo_fill(cr);
662 cairo_destroy(cr); 664 cairo_destroy(cr);
663 } 665 }
664 #endif 666 #endif
665 667
666 } // namespace content 668 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698