diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 20:42:26 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 20:42:26 +0000 |
commit | 9c86b30ed5284d66a20e9c81c5ee2f3b8722ea76 (patch) | |
tree | e7f90ee7833ad07babfba631222a2b0f517ea7fb /chrome/browser/renderer_host | |
parent | a405a1ca397ddcc7195269371e816bd39f62d575 (diff) | |
download | chromium_src-9c86b30ed5284d66a20e9c81c5ee2f3b8722ea76.zip chromium_src-9c86b30ed5284d66a20e9c81c5ee2f3b8722ea76.tar.gz chromium_src-9c86b30ed5284d66a20e9c81c5ee2f3b8722ea76.tar.bz2 |
Add CanAccuratelyCopyFromBackingStore() to the backing store class.
Use the new method to avoid using CopyFromBackingStore() for screen captures when CopyFromBackingStore() will not give a flawless copy.
BUG=35204
TEST=Manual testing with example screenshot extension.
Review URL: http://codereview.chromium.org/830001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/backing_store_x.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/backing_store_x.cc b/chrome/browser/renderer_host/backing_store_x.cc index 4ef8bb3..62f3ebc 100644 --- a/chrome/browser/renderer_host/backing_store_x.cc +++ b/chrome/browser/renderer_host/backing_store_x.cc @@ -274,6 +274,15 @@ void BackingStoreX::PaintToBackingStore( bool BackingStoreX::CopyFromBackingStore(const gfx::Rect& rect, skia::PlatformCanvas* output) { base::TimeTicks begin_time = base::TimeTicks::Now(); + + if (visual_depth_ < 24) { + // CopyFromBackingStore() copies pixels out of the XImage + // in a way that assumes that each component (red, green, + // blue) is a byte. This doesn't work on visuals which + // encode a pixel color with less than a byte per color. + return false; + } + const int width = std::min(size().width(), rect.width()); const int height = std::min(size().height(), rect.height()); @@ -328,6 +337,8 @@ bool BackingStoreX::CopyFromBackingStore(const gfx::Rect& rect, // The X image might have a different row stride, so iterate through it and // copy each row out, only up to the pixels we're actually using. + // This code assumes a visual mode where a pixel is represented using + // a byte for each component. SkBitmap bitmap = output->getTopPlatformDevice().accessBitmap(true); for (int y = 0; y < height; y++) { uint32* dest_row = bitmap.getAddr32(0, y); |