GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / resources / float_clip_display_item.cc
blobba98fe5bdc0a44b09bf6d798a9cf8555976b9b25
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/float_clip_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"
10 #include "ui/gfx/skia_util.h"
12 namespace cc {
14 FloatClipDisplayItem::FloatClipDisplayItem(gfx::RectF clip_rect)
15 : clip_rect_(clip_rect) {
18 FloatClipDisplayItem::~FloatClipDisplayItem() {
21 void FloatClipDisplayItem::Raster(SkCanvas* canvas,
22 SkDrawPictureCallback* callback) const {
23 canvas->save();
24 canvas->clipRect(gfx::RectFToSkRect(clip_rect_));
27 bool FloatClipDisplayItem::IsSuitableForGpuRasterization() const {
28 return true;
31 int FloatClipDisplayItem::ApproximateOpCount() const {
32 return 1;
35 size_t FloatClipDisplayItem::PictureMemoryUsage() const {
36 return sizeof(gfx::RectF);
39 void FloatClipDisplayItem::AsValueInto(
40 base::trace_event::TracedValue* array) const {
41 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]",
42 clip_rect_.ToString().c_str()));
45 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {
48 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() {
51 void EndFloatClipDisplayItem::Raster(SkCanvas* canvas,
52 SkDrawPictureCallback* callback) const {
53 canvas->restore();
56 bool EndFloatClipDisplayItem::IsSuitableForGpuRasterization() const {
57 return true;
60 int EndFloatClipDisplayItem::ApproximateOpCount() const {
61 return 0;
64 size_t EndFloatClipDisplayItem::PictureMemoryUsage() const {
65 return 0;
68 void EndFloatClipDisplayItem::AsValueInto(
69 base::trace_event::TracedValue* array) const {
70 array->AppendString("EndFloatClipDisplayItem");
73 } // namespace cc