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

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

Issue 2160683003: Fix MultiPictureDraw issues with GpuImageDecodeController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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
« no previous file with comments | « cc/raster/raster_buffer_provider_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/playback/display_item_list.h" 9 #include "cc/playback/display_item_list.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkImageGenerator.h" 11 #include "third_party/skia/include/core/SkImageGenerator.h"
12 #include "third_party/skia/include/core/SkPixmap.h"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/skia_util.h" 14 #include "ui/gfx/skia_util.h"
14 15
15 namespace cc { 16 namespace cc {
16 17
17 namespace { 18 namespace {
18 19
19 class TestImageGenerator : public SkImageGenerator { 20 class TestImageGenerator : public SkImageGenerator {
20 public: 21 public:
21 explicit TestImageGenerator(const SkImageInfo& info) 22 explicit TestImageGenerator(const SkImageInfo& info)
22 : SkImageGenerator(info) {} 23 : SkImageGenerator(info),
24 image_backing_memory_(info.getSafeSize(info.minRowBytes()), 0),
25 image_pixmap_(info, image_backing_memory_.data(), info.minRowBytes()) {}
26
27 protected:
28 bool onGetPixels(const SkImageInfo& info,
29 void* pixels,
30 size_t rowBytes,
31 SkPMColor ctable[],
32 int* ctableCount) override {
33 return image_pixmap_.readPixels(info, pixels, rowBytes, 0, 0);
34 }
35
36 private:
37 std::vector<uint8_t> image_backing_memory_;
38 SkPixmap image_pixmap_;
23 }; 39 };
24 40
25 } // anonymous namespace 41 } // anonymous namespace
26 42
27 void DrawDisplayList(unsigned char* buffer, 43 void DrawDisplayList(unsigned char* buffer,
28 const gfx::Rect& layer_rect, 44 const gfx::Rect& layer_rect,
29 scoped_refptr<const DisplayItemList> list) { 45 scoped_refptr<const DisplayItemList> list) {
30 SkImageInfo info = 46 SkImageInfo info =
31 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 47 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
32 SkBitmap bitmap; 48 SkBitmap bitmap;
(...skipping 17 matching lines...) Expand all
50 66
51 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size); 67 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size);
52 } 68 }
53 69
54 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) { 70 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) {
55 return SkImage::MakeFromGenerator(new TestImageGenerator( 71 return SkImage::MakeFromGenerator(new TestImageGenerator(
56 SkImageInfo::MakeN32Premul(size.width(), size.height()))); 72 SkImageInfo::MakeN32Premul(size.width(), size.height())));
57 } 73 }
58 74
59 } // namespace cc 75 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_buffer_provider_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698