| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/test/skia_common.h" | 5 #include "cc/test/skia_common.h" |
| 6 | 6 |
| 7 #include "cc/resources/picture.h" | 7 #include "cc/resources/picture.h" |
| 8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
| 9 #include "third_party/skia/include/core/SkBitmapDevice.h" | 9 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 gfx::Rect layer_rect, | 62 gfx::Rect layer_rect, |
| 63 scoped_refptr<Picture> picture) { | 63 scoped_refptr<Picture> picture) { |
| 64 SkBitmap bitmap; | 64 SkBitmap bitmap; |
| 65 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 65 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 66 layer_rect.width(), | 66 layer_rect.width(), |
| 67 layer_rect.height()); | 67 layer_rect.height()); |
| 68 bitmap.setPixels(buffer); | 68 bitmap.setPixels(buffer); |
| 69 SkBitmapDevice device(bitmap); | 69 SkBitmapDevice device(bitmap); |
| 70 SkCanvas canvas(&device); | 70 SkCanvas canvas(&device); |
| 71 canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 71 canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 72 picture->Raster(&canvas, NULL, layer_rect, 1.0f); | 72 picture->Raster(&canvas, layer_rect, 1.0f); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { | 75 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { |
| 76 SkImageInfo info = { | 76 SkImageInfo info = { |
| 77 size.width(), | 77 size.width(), |
| 78 size.height(), | 78 size.height(), |
| 79 kPMColor_SkColorType, | 79 kPMColor_SkColorType, |
| 80 kPremul_SkAlphaType | 80 kPremul_SkAlphaType |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = | 83 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = |
| 84 skia::AdoptRef(new TestLazyPixelRef(info)); | 84 skia::AdoptRef(new TestLazyPixelRef(info)); |
| 85 lazy_pixel_ref->setURI(uri); | 85 lazy_pixel_ref->setURI(uri); |
| 86 | 86 |
| 87 bitmap->setConfig(info); | 87 bitmap->setConfig(info); |
| 88 bitmap->setPixelRef(lazy_pixel_ref.get()); | 88 bitmap->setPixelRef(lazy_pixel_ref.get()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 } // namespace cc | 92 } // namespace cc |
| OLD | NEW |