GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / clip_path_display_item.cc
blob275a7effd7b16d808835b7c1fe335bbb06e5f30e
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/resources/clip_path_display_item.h"
7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
11 namespace cc {
13 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path,
14 SkRegion::Op clip_op,
15 bool antialias)
16 : clip_path_(clip_path), clip_op_(clip_op), antialias_(antialias) {
19 ClipPathDisplayItem::~ClipPathDisplayItem() {
22 void ClipPathDisplayItem::Raster(SkCanvas* canvas,
23 SkDrawPictureCallback* callback) const {
24 canvas->save();
25 canvas->clipPath(clip_path_, clip_op_, antialias_);
28 bool ClipPathDisplayItem::IsSuitableForGpuRasterization() const {
29 return true;
32 int ClipPathDisplayItem::ApproximateOpCount() const {
33 return 1;
36 size_t ClipPathDisplayItem::PictureMemoryUsage() const {
37 size_t total_size = sizeof(SkPath) + sizeof(SkRegion::Op) + sizeof(bool);
38 return total_size;
41 void ClipPathDisplayItem::AsValueInto(
42 base::trace_event::TracedValue* array) const {
43 array->AppendString(base::StringPrintf("ClipPathDisplayItem length: %d",
44 clip_path_.countPoints()));
47 EndClipPathDisplayItem::EndClipPathDisplayItem() {
50 EndClipPathDisplayItem::~EndClipPathDisplayItem() {
53 void EndClipPathDisplayItem::Raster(SkCanvas* canvas,
54 SkDrawPictureCallback* callback) const {
55 canvas->restore();
58 bool EndClipPathDisplayItem::IsSuitableForGpuRasterization() const {
59 return true;
62 int EndClipPathDisplayItem::ApproximateOpCount() const {
63 return 0;
66 size_t EndClipPathDisplayItem::PictureMemoryUsage() const {
67 return 0;
70 void EndClipPathDisplayItem::AsValueInto(
71 base::trace_event::TracedValue* array) const {
72 array->AppendString("EndClipPathDisplayItem");
75 } // namespace cc