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/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 gfx::Rect layer_rect, | 57 gfx::Rect layer_rect, |
58 scoped_refptr<Picture> picture) { | 58 scoped_refptr<Picture> picture) { |
59 SkBitmap bitmap; | 59 SkBitmap bitmap; |
60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
61 layer_rect.width(), | 61 layer_rect.width(), |
62 layer_rect.height()); | 62 layer_rect.height()); |
63 bitmap.setPixels(buffer); | 63 bitmap.setPixels(buffer); |
64 SkDevice device(bitmap); | 64 SkDevice device(bitmap); |
65 SkCanvas canvas(&device); | 65 SkCanvas canvas(&device); |
66 canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 66 canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
67 picture->Raster(&canvas, NULL, layer_rect, 1.0f, false); | 67 picture->Raster(&canvas, NULL, layer_rect, 1.0f); |
68 } | 68 } |
69 | 69 |
70 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { | 70 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { |
71 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = | 71 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = |
72 skia::AdoptRef(new TestLazyPixelRef(size.width(), size.height())); | 72 skia::AdoptRef(new TestLazyPixelRef(size.width(), size.height())); |
73 lazy_pixel_ref->setURI(uri); | 73 lazy_pixel_ref->setURI(uri); |
74 | 74 |
75 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 75 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
76 size.width(), | 76 size.width(), |
77 size.height()); | 77 size.height()); |
78 bitmap->setPixelRef(lazy_pixel_ref.get()); | 78 bitmap->setPixelRef(lazy_pixel_ref.get()); |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 } // namespace cc | 82 } // namespace cc |
OLD | NEW |