| OLD | NEW |
| 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/renderer/browser_plugin/browser_plugin_backing_store.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" |
| 6 | 6 |
| 7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
| 8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" |
| 9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
| 10 #include "ui/gfx/size_conversions.h" | 10 #include "ui/gfx/size_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 bitmap_.allocPixels(); | 27 bitmap_.allocPixels(); |
| 28 canvas_.reset(new SkCanvas(bitmap_)); | 28 canvas_.reset(new SkCanvas(bitmap_)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 BrowserPluginBackingStore::~BrowserPluginBackingStore() { | 31 BrowserPluginBackingStore::~BrowserPluginBackingStore() { |
| 32 } | 32 } |
| 33 | 33 |
| 34 void BrowserPluginBackingStore::PaintToBackingStore( | 34 void BrowserPluginBackingStore::PaintToBackingStore( |
| 35 const gfx::Rect& bitmap_rect, | 35 const gfx::Rect& bitmap_rect, |
| 36 const std::vector<gfx::Rect>& copy_rects, | 36 const std::vector<gfx::Rect>& copy_rects, |
| 37 TransportDIB* dib) { | 37 void* bitmap) { |
| 38 if (bitmap_rect.IsEmpty()) | 38 if (bitmap_rect.IsEmpty()) |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 gfx::Rect pixel_bitmap_rect = gfx::ToFlooredRectDeprecated( | 41 gfx::Rect pixel_bitmap_rect = gfx::ToFlooredRectDeprecated( |
| 42 gfx::ScaleRect(bitmap_rect, scale_factor_)); | 42 gfx::ScaleRect(bitmap_rect, scale_factor_)); |
| 43 | 43 |
| 44 const int width = pixel_bitmap_rect.width(); | 44 const int width = pixel_bitmap_rect.width(); |
| 45 const int height = pixel_bitmap_rect.height(); | 45 const int height = pixel_bitmap_rect.height(); |
| 46 | 46 |
| 47 if (width <= 0 || width > kMaxSize || | 47 if (width <= 0 || width > kMaxSize || |
| 48 height <= 0 || height > kMaxSize) | 48 height <= 0 || height > kMaxSize) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 if (!dib) | 51 if (!bitmap) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 SkPaint copy_paint; | 54 SkPaint copy_paint; |
| 55 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 55 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 56 | 56 |
| 57 SkBitmap sk_bitmap; | 57 SkBitmap sk_bitmap; |
| 58 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 58 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 59 sk_bitmap.setPixels(dib->memory()); | 59 sk_bitmap.setPixels(bitmap); |
| 60 for (size_t i = 0; i < copy_rects.size(); i++) { | 60 for (size_t i = 0; i < copy_rects.size(); i++) { |
| 61 const gfx::Rect& pixel_copy_rect = gfx::ToEnclosingRect( | 61 const gfx::Rect& pixel_copy_rect = gfx::ToEnclosingRect( |
| 62 gfx::ScaleRect(copy_rects[i], scale_factor_)); | 62 gfx::ScaleRect(copy_rects[i], scale_factor_)); |
| 63 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); | 63 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); |
| 64 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); | 64 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); |
| 65 SkIRect srcrect = SkIRect::MakeXYWH(x, y, | 65 SkIRect srcrect = SkIRect::MakeXYWH(x, y, |
| 66 pixel_copy_rect.width(), | 66 pixel_copy_rect.width(), |
| 67 pixel_copy_rect.height()); | 67 pixel_copy_rect.height()); |
| 68 | 68 |
| 69 SkRect dstrect = SkRect::MakeXYWH( | 69 SkRect dstrect = SkRect::MakeXYWH( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 int h = pixel_rect.height() + abs(pixel_delta.y()); | 90 int h = pixel_rect.height() + abs(pixel_delta.y()); |
| 91 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); | 91 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); |
| 92 bitmap_.scrollRect(&rect, pixel_delta.x(), pixel_delta.y()); | 92 bitmap_.scrollRect(&rect, pixel_delta.x(), pixel_delta.y()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void BrowserPluginBackingStore::Clear(SkColor clear_color) { | 95 void BrowserPluginBackingStore::Clear(SkColor clear_color) { |
| 96 canvas_->clear(clear_color); | 96 canvas_->clear(clear_color); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| OLD | NEW |