OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_entry_screenshot_manager.h" | 5 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/threading/worker_pool.h" | 8 #include "base/threading/worker_pool.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 9 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 scoped_refptr<base::RefCountedBytes> data() const { return data_; } | 47 scoped_refptr<base::RefCountedBytes> data() const { return data_; } |
48 | 48 |
49 private: | 49 private: |
50 friend class base::RefCountedThreadSafe<ScreenshotData>; | 50 friend class base::RefCountedThreadSafe<ScreenshotData>; |
51 virtual ~ScreenshotData() { | 51 virtual ~ScreenshotData() { |
52 } | 52 } |
53 | 53 |
54 void EncodeOnWorker(const SkBitmap& bitmap) { | 54 void EncodeOnWorker(const SkBitmap& bitmap) { |
55 std::vector<unsigned char> data; | 55 std::vector<unsigned char> data; |
56 // Paint |bitmap| to a kA8_Config SkBitmap | 56 // Paint |bitmap| to a kAlpha_8_SkColorType SkBitmap |
57 SkBitmap a8Bitmap; | 57 SkBitmap a8Bitmap; |
58 a8Bitmap.allocPixels(SkImageInfo::MakeA8(bitmap.width(), bitmap.height())); | 58 a8Bitmap.allocPixels(SkImageInfo::MakeA8(bitmap.width(), bitmap.height())); |
59 SkCanvas canvas(a8Bitmap); | 59 SkCanvas canvas(a8Bitmap); |
60 SkPaint paint; | 60 SkPaint paint; |
61 SkColorFilter* filter = SkLumaColorFilter::Create(); | 61 SkColorFilter* filter = SkLumaColorFilter::Create(); |
62 paint.setColorFilter(filter); | 62 paint.setColorFilter(filter); |
63 filter->unref(); | 63 filter->unref(); |
64 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); | 64 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); |
65 // Encode the a8Bitmap to grayscale PNG treating alpha as color intensity | 65 // Encode the a8Bitmap to grayscale PNG treating alpha as color intensity |
66 if (gfx::PNGCodec::EncodeA8SkBitmap(a8Bitmap, &data)) | 66 if (gfx::PNGCodec::EncodeA8SkBitmap(a8Bitmap, &data)) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 owner_->GetEntryAtIndex(forward)); | 283 owner_->GetEntryAtIndex(forward)); |
284 if (ClearScreenshot(entry)) | 284 if (ClearScreenshot(entry)) |
285 --screenshot_count; | 285 --screenshot_count; |
286 ++forward; | 286 ++forward; |
287 } | 287 } |
288 CHECK_GE(screenshot_count, 0); | 288 CHECK_GE(screenshot_count, 0); |
289 CHECK_LE(screenshot_count, kMaxScreenshots); | 289 CHECK_LE(screenshot_count, kMaxScreenshots); |
290 } | 290 } |
291 | 291 |
292 } // namespace content | 292 } // namespace content |
OLD | NEW |