| OLD | NEW |
| 1 // Copyright (c) 2011 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_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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 |
| 32 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, | 32 void BackingStoreSkia::SkiaShowRect(const gfx::Point& point, |
| 33 gfx::Canvas* canvas) { | 33 gfx::CanvasSkia* canvas) { |
| 34 canvas->GetSkCanvas()->drawBitmap(bitmap_, | 34 canvas->GetSkCanvas()->drawBitmap(bitmap_, |
| 35 SkIntToScalar(point.x()), SkIntToScalar(point.y())); | 35 SkIntToScalar(point.x()), SkIntToScalar(point.y())); |
| 36 } | 36 } |
| 37 | 37 |
| 38 size_t BackingStoreSkia::MemorySize() { | 38 size_t BackingStoreSkia::MemorySize() { |
| 39 // NOTE: The computation may be different when the canvas is a subrectangle of | 39 // NOTE: The computation may be different when the canvas is a subrectangle of |
| 40 // a larger bitmap. | 40 // a larger bitmap. |
| 41 return size().GetArea() * 4; | 41 return size().GetArea() * 4; |
| 42 } | 42 } |
| 43 | 43 |
| (...skipping 58 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 |