OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM
ode, sk_sp<SkColorSpace> colorSpace) | 43 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM
ode, sk_sp<SkColorSpace> colorSpace) |
44 : m_opacityMode(opacityMode) | 44 : m_opacityMode(opacityMode) |
45 , m_size(size) | 45 , m_size(size) |
46 , m_colorSpace(colorSpace) | 46 , m_colorSpace(colorSpace) |
47 { | 47 { |
48 setIsHidden(false); | 48 setIsHidden(false); |
49 } | 49 } |
50 | 50 |
51 ImageBufferSurface::~ImageBufferSurface() { } | 51 ImageBufferSurface::~ImageBufferSurface() { } |
52 | 52 |
53 PassRefPtr<SkPicture> ImageBufferSurface::getPicture() | 53 sk_sp<SkPicture> ImageBufferSurface::getPicture() |
54 { | 54 { |
55 return nullptr; | 55 return nullptr; |
56 } | 56 } |
57 | 57 |
58 void ImageBufferSurface::clear() | 58 void ImageBufferSurface::clear() |
59 { | 59 { |
60 // Clear the background transparent or opaque, as required. It would be nice
if this wasn't | 60 // Clear the background transparent or opaque, as required. It would be nice
if this wasn't |
61 // required, but the canvas is currently filled with the magic transparency | 61 // required, but the canvas is currently filled with the magic transparency |
62 // color. Can we have another way to manage this? | 62 // color. Can we have another way to manage this? |
63 if (isValid()) { | 63 if (isValid()) { |
64 if (m_opacityMode == Opaque) { | 64 if (m_opacityMode == Opaque) { |
65 canvas()->clear(SK_ColorBLACK); | 65 canvas()->clear(SK_ColorBLACK); |
66 } else { | 66 } else { |
67 canvas()->clear(SK_ColorTRANSPARENT); | 67 canvas()->clear(SK_ColorTRANSPARENT); |
68 } | 68 } |
69 didDraw(FloatRect(FloatPoint(0, 0), FloatSize(size()))); | 69 didDraw(FloatRect(FloatPoint(0, 0), FloatSize(size()))); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void ImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRec
t, const FloatRect& srcRect, SkXfermode::Mode op) | 73 void ImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRec
t, const FloatRect& srcRect, SkXfermode::Mode op) |
74 { | 74 { |
75 RefPtr<SkImage> snapshot = newImageSnapshot(PreferNoAcceleration, SnapshotRe
asonPaint); | 75 sk_sp<SkImage> snapshot = newImageSnapshot(PreferNoAcceleration, SnapshotRea
sonPaint); |
76 if (!snapshot) | 76 if (!snapshot) |
77 return; | 77 return; |
78 | 78 |
79 RefPtr<Image> image = StaticBitmapImage::create(snapshot.release()); | 79 RefPtr<Image> image = StaticBitmapImage::create(std::move(snapshot)); |
80 context.drawImage(image.get(), destRect, &srcRect, op); | 80 context.drawImage(image.get(), destRect, &srcRect, op); |
81 } | 81 } |
82 | 82 |
83 void ImageBufferSurface::flush(FlushReason) | 83 void ImageBufferSurface::flush(FlushReason) |
84 { | 84 { |
85 canvas()->flush(); | 85 canvas()->flush(); |
86 } | 86 } |
87 | 87 |
88 bool ImageBufferSurface::writePixels(const SkImageInfo& origInfo, const void* pi
xels, size_t rowBytes, int x, int y) | 88 bool ImageBufferSurface::writePixels(const SkImageInfo& origInfo, const void* pi
xels, size_t rowBytes, int x, int y) |
89 { | 89 { |
90 return canvas()->writePixels(origInfo, pixels, rowBytes, x, y); | 90 return canvas()->writePixels(origInfo, pixels, rowBytes, x, y); |
91 } | 91 } |
92 | 92 |
93 } // namespace blink | 93 } // namespace blink |
OLD | NEW |