Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: cc/test/skia_common.cc

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/SkBitmapDevice.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/skia_util.h" 11 #include "ui/gfx/skia_util.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 TestPixelRef::TestPixelRef(int width, int height) 15 TestPixelRef::TestPixelRef(int width, int height)
16 : pixels_(new char[4 * width * height]) {} 16 : pixels_(new char[4 * width * height]) {}
17 17
18 TestPixelRef::~TestPixelRef() {} 18 TestPixelRef::~TestPixelRef() {}
19 19
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void DrawPicture(unsigned char* buffer, 60 void DrawPicture(unsigned char* buffer,
61 gfx::Rect layer_rect, 61 gfx::Rect layer_rect,
62 scoped_refptr<Picture> picture) { 62 scoped_refptr<Picture> picture) {
63 SkBitmap bitmap; 63 SkBitmap bitmap;
64 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 64 bitmap.setConfig(SkBitmap::kARGB_8888_Config,
65 layer_rect.width(), 65 layer_rect.width(),
66 layer_rect.height()); 66 layer_rect.height());
67 bitmap.setPixels(buffer); 67 bitmap.setPixels(buffer);
68 SkDevice device(bitmap); 68 SkBitmapDevice device(bitmap);
69 SkCanvas canvas(&device); 69 SkCanvas canvas(&device);
70 canvas.clipRect(gfx::RectToSkRect(layer_rect)); 70 canvas.clipRect(gfx::RectToSkRect(layer_rect));
71 picture->Raster(&canvas, NULL, layer_rect, 1.0f); 71 picture->Raster(&canvas, NULL, layer_rect, 1.0f);
72 } 72 }
73 73
74 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { 74 void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
75 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = 75 skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref =
76 skia::AdoptRef(new TestLazyPixelRef(size.width(), size.height())); 76 skia::AdoptRef(new TestLazyPixelRef(size.width(), size.height()));
77 lazy_pixel_ref->setURI(uri); 77 lazy_pixel_ref->setURI(uri);
78 78
79 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 79 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
80 size.width(), 80 size.width(),
81 size.height()); 81 size.height());
82 bitmap->setPixelRef(lazy_pixel_ref.get()); 82 bitmap->setPixelRef(lazy_pixel_ref.get());
83 } 83 }
84 84
85 85
86 } // namespace cc 86 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool_unittest.cc ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698