1 /*
2 * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
44 }
45
46 public boolean matches(SurfaceType src,
47 CompositeType comp,
48 SurfaceType dst)
49 {
50 // bug 4725045: using equals() causes different SurfaceType
51 // objects with the same strings to match in the cache, which is
52 // not the behavior we want. Constrain the match to succeed only
53 // on object matches instead.
54 return ((this.src == src) &&
55 (this.comp == comp) &&
56 (this.dst == dst));
57 }
58
59 public Object getValue() {
60 return value;
61 }
62 }
63
64 private Entry entries[];
65
66 public RenderCache(int size) {
67 entries = new Entry[size];
68 }
69
70 public synchronized Object get(SurfaceType src,
71 CompositeType comp,
72 SurfaceType dst)
73 {
74 int max = entries.length - 1;
75 for (int i = max; i >= 0; i--) {
76 Entry e = entries[i];
77 if (e == null) {
78 break;
79 }
80 if (e.matches(src, comp, dst)) {
81 if (i < max - 4) {
82 System.arraycopy(entries, i+1, entries, i, max - i);
83 entries[max] = e;
84 }
|
1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
44 }
45
46 public boolean matches(SurfaceType src,
47 CompositeType comp,
48 SurfaceType dst)
49 {
50 // bug 4725045: using equals() causes different SurfaceType
51 // objects with the same strings to match in the cache, which is
52 // not the behavior we want. Constrain the match to succeed only
53 // on object matches instead.
54 return ((this.src == src) &&
55 (this.comp == comp) &&
56 (this.dst == dst));
57 }
58
59 public Object getValue() {
60 return value;
61 }
62 }
63
64 private Entry[] entries;
65
66 public RenderCache(int size) {
67 entries = new Entry[size];
68 }
69
70 public synchronized Object get(SurfaceType src,
71 CompositeType comp,
72 SurfaceType dst)
73 {
74 int max = entries.length - 1;
75 for (int i = max; i >= 0; i--) {
76 Entry e = entries[i];
77 if (e == null) {
78 break;
79 }
80 if (e.matches(src, comp, dst)) {
81 if (i < max - 4) {
82 System.arraycopy(entries, i+1, entries, i, max - i);
83 entries[max] = e;
84 }
|