| OLD | NEW |
| 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 "content/browser/renderer_host/backing_store_skia.h" | 5 #include "content/browser/renderer_host/backing_store_skia.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/render_process_host_impl.h" | 7 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 8 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/canvas_skia.h" | 11 #include "ui/gfx/canvas_skia.h" |
| 12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
| 13 | 13 |
| 14 // Assume that somewhere along the line, someone will do width * height * 4 | 14 // Assume that somewhere along the line, someone will do width * height * 4 |
| 15 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = | 15 // with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = |
| 16 // 2**29 and floor(sqrt(2**29)) = 23170. | 16 // 2**29 and floor(sqrt(2**29)) = 23170. |
| 17 | 17 |
| 18 // Max height and width for layers | 18 // Max height and width for layers |
| 19 static const int kMaxVideoLayerSize = 23170; | 19 static const int kMaxVideoLayerSize = 23170; |
| 20 | 20 |
| 21 BackingStoreSkia::BackingStoreSkia(RenderWidgetHost* widget, | 21 BackingStoreSkia::BackingStoreSkia(content::RenderWidgetHost* widget, |
| 22 const gfx::Size& size) | 22 const gfx::Size& size) |
| 23 : BackingStore(widget, size) { | 23 : BackingStore(widget, size) { |
| 24 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 24 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
| 25 bitmap_.allocPixels(); | 25 bitmap_.allocPixels(); |
| 26 canvas_.reset(new SkCanvas(bitmap_)); | 26 canvas_.reset(new SkCanvas(bitmap_)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 BackingStoreSkia::~BackingStoreSkia() { | 29 BackingStoreSkia::~BackingStoreSkia() { |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 return false; | 102 return false; |
| 103 | 103 |
| 104 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); | 104 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); |
| 105 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); | 105 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); |
| 106 SkBitmap b; | 106 SkBitmap b; |
| 107 if (!canvas_->readPixels(skrect, &b)) | 107 if (!canvas_->readPixels(skrect, &b)) |
| 108 return false; | 108 return false; |
| 109 output->writePixels(b, rect.x(), rect.y()); | 109 output->writePixels(b, rect.x(), rect.y()); |
| 110 return true; | 110 return true; |
| 111 } | 111 } |
| OLD | NEW |