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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp

Issue 1887733003: Remove redundant DecodingImageGenerator::m_generationId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sharedBufferInterface6
Patch Set: Remove dependency Created 4 years, 8 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "platform/graphics/ImageFrameGenerator.h" 31 #include "platform/graphics/ImageFrameGenerator.h"
32 #include "platform/image-decoders/ImageDecoder.h" 32 #include "platform/image-decoders/ImageDecoder.h"
33 #include "third_party/skia/include/core/SkData.h" 33 #include "third_party/skia/include/core/SkData.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> f rameGenerator, const SkImageInfo& info, size_t index) 37 DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> f rameGenerator, const SkImageInfo& info, size_t index)
38 : SkImageGenerator(info) 38 : SkImageGenerator(info)
39 , m_frameGenerator(frameGenerator) 39 , m_frameGenerator(frameGenerator)
40 , m_frameIndex(index) 40 , m_frameIndex(index)
41 , m_generationId(0)
42 , m_canYUVDecode(false) 41 , m_canYUVDecode(false)
43 { 42 {
44 } 43 }
45 44
46 DecodingImageGenerator::~DecodingImageGenerator() 45 DecodingImageGenerator::~DecodingImageGenerator()
47 { 46 {
48 } 47 }
49 48
50 SkData* DecodingImageGenerator::onRefEncodedData() 49 SkData* DecodingImageGenerator::onRefEncodedData()
51 { 50 {
52 TRACE_EVENT0("blink", "DecodingImageGenerator::refEncodedData"); 51 TRACE_EVENT0("blink", "DecodingImageGenerator::refEncodedData");
53 52
54 return m_frameGenerator->refEncodedData(); 53 return m_frameGenerator->refEncodedData();
55 } 54 }
56 55
57 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor table[], int* tableCount) 56 bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor table[], int* tableCount)
58 { 57 {
59 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", st atic_cast<int>(m_frameIndex)); 58 TRACE_EVENT1("blink", "DecodingImageGenerator::getPixels", "frame index", st atic_cast<int>(m_frameIndex));
60 59
61 // Implementation doesn't support scaling yet so make sure we're not given a different size. 60 // Implementation doesn't support scaling yet so make sure we're not given a different size.
62 if (info.width() != getInfo().width() || info.height() != getInfo().height() ) 61 if (info.width() != getInfo().width() || info.height() != getInfo().height() )
63 return false; 62 return false;
64 63
65 if (info.colorType() != getInfo().colorType()) { 64 if (info.colorType() != getInfo().colorType()) {
66 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA lphaType after fully decoding the image frame, 65 // blink::ImageFrame may have changed the owning SkBitmap to kOpaque_SkA lphaType after fully decoding the image frame,
67 // so if we see a request for opaque, that is ok even if our initial alp ha type was not opaque. 66 // so if we see a request for opaque, that is ok even if our initial alp ha type was not opaque.
68 return false; 67 return false;
69 } 68 }
70 69
71 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); 70 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID());
72 bool decoded = m_frameGenerator->decodeAndScale(m_frameIndex, getInfo(), pix els, rowBytes); 71 bool decoded = m_frameGenerator->decodeAndScale(m_frameIndex, getInfo(), pix els, rowBytes);
73 PlatformInstrumentation::didDecodeLazyPixelRef(); 72 PlatformInstrumentation::didDecodeLazyPixelRef();
74 73
75 return decoded; 74 return decoded;
76 } 75 }
77 76
78 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpac e* colorSpace) const 77 bool DecodingImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpac e* colorSpace) const
79 { 78 {
80 if (!m_canYUVDecode) 79 if (!m_canYUVDecode)
81 return false; 80 return false;
82 81
83 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", static_c ast<int>(m_frameIndex)); 82 TRACE_EVENT1("blink", "DecodingImageGenerator::queryYUV8", "sizes", static_c ast<int>(m_frameIndex));
84 83
85 if (colorSpace) 84 if (colorSpace)
86 *colorSpace = kJPEG_SkYUVColorSpace; 85 *colorSpace = kJPEG_SkYUVColorSpace;
87 86
88 return m_frameGenerator->getYUVComponentSizes(sizeInfo); 87 return m_frameGenerator->getYUVComponentSizes(sizeInfo);
89 } 88 }
90 89
91 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void * planes[3]) 90 bool DecodingImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void * planes[3])
92 { 91 {
93 ASSERT(m_canYUVDecode); 92 ASSERT(m_canYUVDecode);
94 93
95 TRACE_EVENT1("blink", "DecodingImageGenerator::getYUV8Planes", "frame index" , static_cast<int>(m_frameIndex)); 94 TRACE_EVENT1("blink", "DecodingImageGenerator::getYUV8Planes", "frame index" , static_cast<int>(m_frameIndex));
96 95
97 PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId); 96 PlatformInstrumentation::willDecodeLazyPixelRef(uniqueID());
98 bool decoded = m_frameGenerator->decodeToYUV(m_frameIndex, sizeInfo.fSizes, planes, sizeInfo.fWidthBytes); 97 bool decoded = m_frameGenerator->decodeToYUV(m_frameIndex, sizeInfo.fSizes, planes, sizeInfo.fWidthBytes);
99 PlatformInstrumentation::didDecodeLazyPixelRef(); 98 PlatformInstrumentation::didDecodeLazyPixelRef();
100 99
101 return decoded; 100 return decoded;
102 } 101 }
103 102
104 SkImageGenerator* DecodingImageGenerator::create(SkData* data) 103 SkImageGenerator* DecodingImageGenerator::create(SkData* data)
105 { 104 {
106 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data->bytes(), data->size ()); 105 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data->bytes(), data->size ());
107 106
(...skipping 11 matching lines...) Expand all
119 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t()); 118 const SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.heigh t());
120 119
121 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), buffer, true, false); 120 RefPtr<ImageFrameGenerator> frame = ImageFrameGenerator::create(SkISize::Mak e(size.width(), size.height()), buffer, true, false);
122 if (!frame) 121 if (!frame)
123 return 0; 122 return 0;
124 123
125 return new DecodingImageGenerator(frame, info, 0); 124 return new DecodingImageGenerator(frame, info, 0);
126 } 125 }
127 126
128 } // namespace blink 127 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698